0
我有Excel中的VBA代碼,應該登錄到網站並使用Selenium下載一些文件。我有我的代碼使用ChromeDriver
工作,並試圖修改它與PhantomJSDriver
一起工作,所以我可以在程序運行時運行其他程序(它運行約45分鐘)。問題是,當我嘗試對登錄按鈕,我收到了超時錯誤硒點擊:PhantomJSDriverTimes熄滅按鈕單擊Selenium中的事件
Run-time error '101':
WebRequestTimeout:
No response from the server within 30000 seconds
有趣的是,超時之後,我可以使用即時窗口進行屏幕截圖,它是清楚該按鈕已被點擊並且瀏覽器已進入下一頁。
Dim D As New PhantomJSDriver
With D
.ExecuteScript ("window.resizeTo(1920,1080)")
.SendKeys MyKeys.Control, "0" 'Set zoom to 100% (causes errors if not 100%)
.Get "LoginPage.com"
.FindElementByName("username").SendKeys "UserName"
.FindElementByXPath("/html/body/div[@class='centreContent']/form[@id='loginForm']/input[@id='passwordDummy']").Click
.FindElementByXPath("/html/body/div[@class='centreContent']/form[@id='loginForm']/input[@id='password']").SendKeys "Password"
.TakeScreenShot.SaveAs "C:\Users\110SidedHexagon\Downloads\Capture.png" '<---Takes screenshot of login screen with uesername and password filled in
.FindElementByName("loginSubmitButton", 0.1).Click '<---Error occurs here
<--Using the immediate window taking a picture after the error breaks code execution shows login was successful-->
End With