Quorie Posted September 14, 2022 Share Posted September 14, 2022 I had the issue previously with version 100 where it crashes upon opening Edge. 101, 102, 103, and 104 all behave nicely, but I'm starting to see 105 in my environment and it's crashing as soon as Edge opens. Here's my code if that's relevant: expandcollapse popup#include "wd_core.au3" #include "wd_helper.au3" #include <wd_capabilities.au3> #include <AD.au3> ;Detects which version of Edge is installed and selects the respective version of msedgedriver. ShellExecute("C:\senthelp\AutoIT Drivers\version.bat") $oEdgeVersion = FileReadLine("C:\senthelp\AutoIT Drivers\version.txt", 2) $oEdgeVersionArray = StringSplit($oEdgeVersion, ".") $oEdgeVersion = $oEdgeVersionArray[1] $oMSDriverPath = "C:\senthelp\AutoIT Drivers\" if($oEdgeVersion == 100) Then $oMSDriverPath &= "msedgedriver100.exe" if($oEdgeVersion == 101) Then $oMSDriverPath &= "msedgedriver101.exe" if($oEdgeVersion == 102) Then $oMSDriverPath &= "msedgedriver102.exe" if($oEdgeVersion == 103) Then $oMSDriverPath &= "msedgedriver103.exe" if($oEdgeVersion == 104) Then $oMSDriverPath &= "msedgedriver104.exe" if($oEdgeVersion == 105) Then $oMSDriverPath &= "msedgedriver105.exe" ;Runs the Edge driver setup and opens a controlled session to Epic. Local $sDesiredCapabilities, $sSession, $sElement SetupEdge() _WD_Startup() _WD_ConsoleVisible() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "website") ;Checks every .25 seconds for the Username and Password variables to tell when the page loads. $oPageLoad = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="Enter user name"]') For $var = 10000 to 0 Step -1 If($oPageLoad) Then ExitLoop sleep(250) $oPageLoad = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="Enter user name"]') Next ;Gets the computer description from Active Directory. _AD_Open() $sCompDescription = _AD_GetObjectAttribute(@ComputerName & "$", "Description") _AD_Close() ;Locates the username, password, and log on fields from the webpage. Local $oUserName = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="Enter user name"]') Local $oPassword = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="passwd"]') Local $oSubmit = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="Log_On"]') ;Instantiates the login information to be entered on the site. Local $sUserName = $sCompDescription Local $sPassword = "password" ;Enter Username and Password from variables above _WD_SetElementValue($sSession, $oUserName, $sUserName) _WD_SetElementValue($sSession, $oPassword, $sPassword) _WD_ElementAction($sSession, $oSubmit, "click") ;Looks for the "Detect citrix receiver" button on the next page to tell when it's loaded and then clicks. $oDetectCitrix = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="protocolhandler-welcome-installButton"]') For $var = 10000 to 0 Step -1 If(_WD_ElementAction($sSession, $oDetectCitrix, 'click')) Then ExitLoop sleep(250) $oDetectCitrix = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="protocolhandler-welcome-installButton"]') Next ;Looks for the "Already installed" button on the next page to tell when it's loaded and then clicks. $oInstalled = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="protocolhandler-detect-alreadyInstalledLink"]') For $var = 10000 to 0 Step -1 $oPageLoad_2 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//img[@alt="Production"]') If($oPageLoad_2) Then ExitLoop sleep(250) _WD_ElementAction($sSession, $oInstalled, 'click') $oInstalled = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="protocolhandler-detect-alreadyInstalledLink"]') Next ;Looks for the Production icon and clicks once loaded. $oLaunchEpic = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//img[@alt="Production"]') For $var = 10000 to 0 Step -1 If(_WD_ElementAction($sSession, $oLaunchEpic, 'click')) Then ExitLoop sleep(250) $oLaunchEpic = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//img[@alt="Production"]') Next ;Waits for connector to download and open before closing Edge / the session. Sleep(15000) _WD_DeleteSession($sSession) _WD_Shutdown() ;Sets the run parameters for Edge to be controlled by the Edge driver. Func SetupEdge() _WD_Option('Driver', $oMSDriverPath) _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose, --remote-debugging=false') _WD_Option('console', "C:\senthelp\AutoIT Drivers\log.txt") $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"binary": "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe", "args": ["safe-mode=true", "start-maximized=true"], "excludeSwitches": [ "enable-automation"]}}}}' EndFunc Link to comment Share on other sites More sharing options...
Danp2 Posted September 14, 2022 Share Posted September 14, 2022 No... I just checked and it ran ok AFAICS. Can you show us the complete results from the Scite output panel? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted September 14, 2022 Share Posted September 14, 2022 Also, you should check out _WD_WaitElement, which could be used to eliminate all of your For..Next loops. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Quorie Posted September 14, 2022 Author Share Posted September 14, 2022 Here's the output from Scite: >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\me\Desktop\Epic Login - Default.au3" _WD_Option ==> Success [0] : Parameters: Option=Driver Value=C:\senthelp\AutoIT Drivers\msedgedriver105.exe _WD_Option ==> Success [0] : Parameters: Option=Port Value=9515 _WD_Option ==> Success [0] : Parameters: Option=DriverParams Value=--verbose, --remote-debugging=false And that's it. Here's the log I have from the edge driver: _WD_IsLatestRelease ==> Success [0] : False _WD_Startup: OS: WIN_10 WIN32_NT 22000 _WD_Startup: AutoIt: 3.3.14.5 _WD_Startup: Webdriver UDF: 0.10.0 (Update available) _WD_Startup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>) _WD_Startup: Driver: C:\senthelp\AutoIT Drivers\msedgedriver105.exe (64 Bit) _WD_Startup: Params: --verbose, --remote-debugging=false _WD_Startup: Port: 9515 _WD_Startup: Command: "C:\senthelp\AutoIT Drivers\msedgedriver105.exe" --verbose, --remote-debugging=false _WD_Startup ==> Success [0] __WD_Post ==> Webdriver Exception [10] : HTTP status = 500 _WD_CreateSession ==> Webdriver Exception [10] __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_Navigate ==> Invalid session ID [15] : Parameters: URL=<url> __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_FindElement ==> Invalid session ID [15] : Parameters: Strategy=xpath Selector=//*[@id="Enter user name"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_FindElement ==> Invalid session ID [15] : Parameters: Strategy=xpath Selector=//*[@id="Enter user name"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_FindElement ==> Invalid session ID [15] : Parameters: Strategy=xpath Selector=//*[@id="Enter user name"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_FindElement ==> Invalid session ID [15] : Parameters: Strategy=xpath Selector=//*[@id="Enter user name"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Invalid session ID [15] : HTTP status = 404 Link to comment Share on other sites More sharing options...
Quorie Posted September 14, 2022 Author Share Posted September 14, 2022 Just now, Danp2 said: Also, you should check out _WD_WaitElement, which could be used to eliminate all of your For..Next loops. I'll check that out. It would be a lot cleaner than the hard coding for sure. Link to comment Share on other sites More sharing options...
Danp2 Posted September 15, 2022 Share Posted September 15, 2022 1 hour ago, Quorie said: _WD_Startup: Webdriver UDF: 0.10.0 (Update available) _WD_Startup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>) You should update both of these UDFs. 1 hour ago, Quorie said: __WD_Post ==> Webdriver Exception [10] : HTTP status = 500 _WD_CreateSession ==> Webdriver Exception [10] FWIW, I saw similar behavior when using mismatched versions of the browser / webdriver. You should manually verify the version numbers involved. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Quorie Posted September 15, 2022 Author Share Posted September 15, 2022 (edited) 16 minutes ago, Danp2 said: You should update both of these UDFs. FWIW, I saw similar behavior when using mismatched versions of the browser / webdriver. You should manually verify the version numbers involved. Unfortunately that yielded the same results. I downloaded the newest stable msedgedriver, updated my webdriver to 10.1, and downloaded the newest WinHTTP files. Here are those results from the log: _WD_IsLatestRelease ==> Success [0] : True _WD_Startup: OS: WIN_10 WIN32_NT 22000 _WD_Startup: AutoIt: 3.3.14.5 _WD_Startup: Webdriver UDF: 0.10.1 (Up to date) _WD_Startup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>) _WD_Startup: Driver: C:\senthelp\AutoIT Drivers\msedgedriver105.exe (64 Bit) _WD_Startup: Params: --verbose, --remote-debugging=false _WD_Startup: Port: 9515 _WD_Startup: Command: "C:\senthelp\AutoIT Drivers\msedgedriver105.exe" --verbose, --remote-debugging=false _WD_Startup ==> Success [0] __WD_Post ==> Webdriver Exception [10] : HTTP status = 500 _WD_CreateSession ==> Webdriver Exception [10] __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_Navigate ==> Invalid session ID [15] : Parameters: URL=<url> __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_FindElement ==> Invalid session ID [15] : Parameters: Strategy=xpath Selector=//*[@id="Enter user name"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_FindElement ==> Invalid session ID [15] : Parameters: Strategy=xpath Selector=//*[@id="Enter user name"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_FindElement ==> Invalid session ID [15] : Parameters: Strategy=xpath Selector=//*[@id="Enter user name"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_FindElement ==> Invalid session ID [15] : Parameters: Strategy=xpath Selector=//*[@id="Enter user name"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Invalid session ID [15] : HTTP status = 404 Edited September 15, 2022 by Quorie Link to comment Share on other sites More sharing options...
Quorie Posted September 15, 2022 Author Share Posted September 15, 2022 Here is another log from switching back to Edge v.104 and running: _WD_IsLatestRelease ==> Success [0] : True _WD_Startup: OS: WIN_10 WIN32_NT 22000 _WD_Startup: AutoIt: 3.3.14.5 _WD_Startup: Webdriver UDF: 0.10.1 (Up to date) _WD_Startup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>) _WD_Startup: Driver: C:\senthelp\AutoIT Drivers\msedgedriver104.exe (64 Bit) _WD_Startup: Params: --verbose, --remote-debugging=false _WD_Startup: Port: 9515 _WD_Startup: Command: "C:\senthelp\AutoIT Drivers\msedgedriver104.exe" --verbose, --remote-debugging=false _WD_Startup ==> Success [0] __WD_Post ==> Success [0] : HTTP status = 200 _WD_CreateSession ==> Success [0] : 567de4ae48d7cc201ac36748f3486a59 __WD_Post ==> Success [0] : HTTP status = 200 _WD_Navigate ==> Success [0] : Parameters: URL=<url> __WD_Post ==> No match [8] : HTTP status = 404 _WD_FindElement ==> No match [8] : Parameters: Strategy=xpath Selector=//*[@id="Enter user name"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//*[@id="Enter user name"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//*[@id="Enter user name"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//*[@id="passwd"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Success [0] : HTTP status = 200 _WD_FindElement ==> Success [0] : Parameters: Strategy=xpath Selector=//*[@id="Log_On"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Success [0] : HTTP status = 200 Link to comment Share on other sites More sharing options...
Danp2 Posted September 15, 2022 Share Posted September 15, 2022 11 minutes ago, Quorie said: _WD_Startup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>) You need to manually grab the source from this link and update your local copy. 2 hours ago, Quorie said: _WD_Option('DriverParams', '--verbose, --remote-debugging=false') Have you tried removing the comma? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Quorie Posted September 15, 2022 Author Share Posted September 15, 2022 15 hours ago, Danp2 said: You need to manually grab the source from this link and update your local copy. Have you tried removing the comma? I copy and pasted the file from that link and replaced it in the include file, and I also removed that comma from the debug call. Same results. _WD_IsLatestRelease ==> Success [0] : True _WD_Startup: OS: WIN_10 WIN32_NT 22000 _WD_Startup: AutoIt: 3.3.14.5 _WD_Startup: Webdriver UDF: 0.10.1 (Up to date) _WD_Startup: WinHTTP: 1.6.4.2 _WD_Startup: Driver: C:\senthelp\AutoIT Drivers\msedgedriver105.exe (64 Bit) _WD_Startup: Params: --verbose --remote-debugging=false _WD_Startup: Port: 9515 _WD_Startup: Command: "C:\senthelp\AutoIT Drivers\msedgedriver105.exe" --verbose --remote-debugging=false _WD_Startup ==> Success [0] __WD_Post ==> Webdriver Exception [10] : HTTP status = 500 _WD_CreateSession ==> Webdriver Exception [10] __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_Navigate ==> Invalid session ID [15] : Parameters: URL=<url> __WD_Post ==> Invalid session ID [15] : HTTP status = 404 _WD_FindElement ==> Invalid session ID [15] : Parameters: Strategy=xpath Selector=//*[@id="Enter user name"] StartNodeID=Default Multiple=Default ShadowRoot=Default __WD_Post ==> Invalid session ID [15] : HTTP status = 404 Link to comment Share on other sites More sharing options...
Danp2 Posted September 15, 2022 Share Posted September 15, 2022 @QuorieYour setup is unique, so we can only guess at what the issue might be. Here are some ideas for you to try -- As previously mentioned, you should manually verify the version numbers involved for both the browser and the webdriver Add debugging code to your script so that you can observe the value of variables Try removing the "binary" portion of your desiredCapabilities string Test with a different script, such as wd_demo, that doesn't depend on the logic / results associated with version.bat Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Quorie Posted September 15, 2022 Author Share Posted September 15, 2022 5 minutes ago, Danp2 said: @QuorieYour setup is unique, so we can only guess at what the issue might be. Here are some ideas for you to try -- As previously mentioned, you should manually verify the version numbers involved for both the browser and the webdriver Add debugging code to your script so that you can observe the value of variables Try removing the "binary" portion of your desiredCapabilities string Test with a different script, such as wd_demo, that doesn't depend on the logic / results associated with version.bat Removing binary worked! I'm going to package this up and test on the computers running different versions to make sure. Thank you so much! Link to comment Share on other sites More sharing options...
Quorie Posted September 15, 2022 Author Share Posted September 15, 2022 Unfortunately it's failing on any computer other than mine but I'll troubleshooting that myself and report back if I'm not able to figure out what's going on. Link to comment Share on other sites More sharing options...
Danp2 Posted September 15, 2022 Share Posted September 15, 2022 Check out _WD_GetBrowserPath to see if it will work in your environment. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Quorie Posted September 16, 2022 Author Share Posted September 16, 2022 It ended up being a bit of sloppiness on my part. My initial check for the Edge version was being superseded too fast by _WD_Startup and it would pull the wrong version. What I think happened after that is even though the second run would get the right version, the wrong driver from the first run would still be running in the background since the script wouldn't progress and never get to _WD_DeleteSession / _WD_Shutdown at the end. I switched my ShellExecute at the beginning of the code to RunWait and that resolved the weird interaction. I also tested using _WD_WaitElement but the site I'm using generates the fields before it makes them interactable. Due to that, I need to loop using _WD_ElementAction as a boolean to tell when the page is ready to move on. Otherwise with just _WD_WaitElement it clicks on basically an image and doesn't progress. Link to comment Share on other sites More sharing options...
Danp2 Posted September 16, 2022 Share Posted September 16, 2022 48 minutes ago, Quorie said: I also tested using _WD_WaitElement but the site I'm using generates the fields before it makes them interactable. Did you try using the $iOptions parameter? Instead of this -- ;Looks for the Production icon and clicks once loaded. $oLaunchEpic = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//img[@alt="Production"]') For $var = 10000 to 0 Step -1 If(_WD_ElementAction($sSession, $oLaunchEpic, 'click')) Then ExitLoop sleep(250) $oLaunchEpic = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//img[@alt="Production"]') Next It would look something like this -- ;Looks for the Production icon and clicks once loaded. $oLaunchEpic = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, '//img[@alt="Production"]', Default, Default, $_WD_OPTION_Visible + $_WD_OPTION_Enabled) If @error = $_WD_ERROR_Success Then _WD_ElementAction($sSession, $oLaunchEpic, 'click') EndIf Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Quorie Posted September 16, 2022 Author Share Posted September 16, 2022 1 hour ago, Danp2 said: It would look something like this -- ;Looks for the Production icon and clicks once loaded. $oLaunchEpic = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, '//img[@alt="Production"]', Default, Default, $_WD_OPTION_Visible + $_WD_OPTION_Enabled) If @error = $_WD_ERROR_Success Then _WD_ElementAction($sSession, $oLaunchEpic, 'click') EndIf Yup, that works! I went ahead and replaced all my loops and it works wonderfully. Thanks Dan! Danp2 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now