VBA Selenium Chrome:如何更改鏈接 (VBA Selenium Chrome : How to Change Link)


問題描述

VBA Selenium Chrome:如何更改鏈接 (VBA Selenium Chrome : How to Change Link)

我剛開始使用 VBA Selenium。我通過 Chrome 使用密碼/用戶名登錄網站。

我想:

1‑ 我必須在登錄後更改鏈接。

2‑ Chrome會在連接改變時記住我的密碼和用戶名(它不記得連接和用戶名/密碼,所以當我更新它時,它會返回主屏幕並要求輸入用戶名/密碼)(<‑‑‑‑ ‑ 我不能)

3‑從連接接收數據。

請幫忙!

Private Keys As New Selenium.Keys
Private driver As New Selenium.ChromeDriver

Sub test100()
  Const JS_NEW_WINDOW = "window.open(arguments[0], name);"

  driver.Get "https://ybs.hmb.gov.tr/"
  driver.FindElementById("identification", timeout:=10000).Clear
  driver.FindElementById("identification").SendKeys "UserName"
  driver.FindElementById("password").SendKeys "Pass*"
  driver.FindElementByClass("mly‑login‑button").Click
  driver.ExecuteScript JS_NEW_WINDOW, "https://ybs.hmb.gov.tr/ybs/raporlar/tasinir/tasinir‑il‑icmal"
  driver.SwitchToNextWindow
 Stop


End Sub

試過了但不工作的代碼

Driver.get(“https://ybs.hmb.gov.tr/ybs/raporlar/tasinir/tasinir‑il‑icmal”)


參考解法

方法 1:

ExecuteScript will always invoke the new url in the adjacent tab or within a new window.

Try to invoke the new url in the same tab / window as follows:

driver.Get "https://ybs.hmb.gov.tr/"
driver.FindElementById("identification", timeout:=10000).Clear
driver.FindElementById("identification").SendKeys "UserName"
driver.FindElementById("password").SendKeys "Pass"
driver.FindElementByClass("mly‑login‑button").Click
driver.Get "https://ybs.hmb.gov.tr/ybs/raporlar/tasinir/tasinir‑il‑icmal"

(by Ahmetundetected Selenium)

參考文件

  1. VBA Selenium Chrome : How to Change Link (CC BY‑SA 2.5/3.0/4.0)

#google-chrome #selenium #excel #vba






相關問題

chrome 可以播放 html5 mp4 視頻但 html5test 說 chrome 不支持 mp4 視頻編解碼器 (chrome could play html5 mp4 video but html5test said chrome did not support mp4 video codec)

向 Sencha Touch 谷歌地圖添加標記 (Adding Marker to Sencha Touch Google Maps)

Mathjax 方程在每個公式上都有符號 `|` (Mathjax equation got sign `|` on every formula)

Google Chrome 中 zip 文件的 Mime 類型 (Mime type for zip file in Google Chrome)

Chrome 擴展:popup.html 通過 contentscript.js 動態創建 (Chrome Extension: popup.html dynamically create via contentscript.js)

CSS 3漸變不適用於chrome / firefox (CSS 3 gradient not working on chrome/firefox)

如何訪問網頁 DOM 而不是擴展頁面 DOM? (How to access the webpage DOM rather than the extension page DOM?)

覆蓋 navigator.bluetooth.requestDevice() 的默認行為 (Override default behavior of navigator.bluetooth.requestDevice())

VBA Selenium Chrome:如何更改鏈接 (VBA Selenium Chrome : How to Change Link)

鼠標懸停在 Chrome 瀏覽器上的日期和時間選擇器圖標上時的光標指針 (Cursor pointer when mouse-over on date and time picker icon on chrome browser)

更改 HTML 選擇箭頭背景顏色 (Change HTML Select arrow background color)

旋轉的圖像無法在 Google Chrome 瀏覽器中正確顯示 (Rotated images not displaying correctly in Google Chrome browser)







留言討論