Kelv Posted Monday at 09:01 AM Posted Monday at 09:01 AM Hello, I'm using two scripts to control differents tabs in a edge session The first one serves as a setup (launchs the Webdriver, opens the tabs, shuts down the webdriver) The second one is called on a user action and is used to navigate to the correct tab in the edge session (launches the WD, attaches it to the session, navigates to and in the right tab) Everything worked fined until recently, when, for some users, the second script doesn't succeed to attach the session. The case doesn't happen to every body (i wasn't able to reproduce), but seems spreading. It looks like an environment issue but i'm stuck on what issue it can be. extract from the 1st script (works fine) if $first Then $_MY__WD_SESSION = SetupEdge(0,False) $_MY__WD_SESSION = SetupEdge(0,True) _WD_Navigate($_MY__WD_SESSION, $strArg) $first=False Else _WD_Attach($_MY__WD_SESSION,$strArg,"URL") If @error Then _WD_NewTab($_MY__WD_SESSION) _WD_Navigate($_MY__WD_SESSION, $strArg) EndIf EndIf where setupEdge is as follow expandcollapse popupFunc SetupEdge($bHeadless,$bTryAttach) _WD_UpdateDriver('msedge') If @error Then Return SetError(@error, @extended, '') _WD_Option('Driver', 'msedgedriver.exe') _WD_Option('Port', 9515) _WD_Option('console', $strLog) $_WD_CONSOLE = $strLog _WD_Option('DriverParams', ' --port=9515') ; _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('firstMatch', 'msedge') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('detach', False) _WD_CapabilitiesAdd('binary', "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe") _WD_CapabilitiesAdd('args','user-data-dir=' & $DriverDir) _WD_CapabilitiesAdd('args','start-maximized') ; If $bTryAttach Then _WD_CapabilitiesAdd('debuggerAddress', '127.0.0.1:9222') Else _WD_CapabilitiesAdd('args', '--remote-debugging-port=9222') EndIf ; Local $iWebDriverPID = _WD_Startup() If @error Then Return SetError(@error, @extended, '') Local $s_Capabilities = _WD_CapabilitiesGet() Local $WD_SESSION = _WD_CreateSession($s_Capabilities) If @error Then Msgbox(16,"Erreur", "Erreur création session") Exit EndIf Local $iBrowserPID = _WD_GetBrowserPID($iWebDriverPID, 'msedge') ConsoleWrite("! $iBrowserPID=" & $iBrowserPID & @CRLF) Return SetError(@error, @extended, $WD_SESSION) ; EndFunc ;==>SetupEdge and extract from the second script _Testing_AttachSession() WriteLog("recherche session err - " & @error) If $relance Then _Testing_AttachSession() EndIf with expandcollapse popup; --------------------- fonction webdriver --------------- ; create webdriver session Func _Testing_CreateSession() $_MY__WD_SESSION = _MY__WD_SetupMsEdge(False, $__g_sDownloadDir, False) EndFunc ;==>_Testing_CreateSession ; link to existing session Func _Testing_AttachSession() $_MY__WD_SESSION = _MY__WD_SetupMsEdge(False, $__g_sDownloadDir, True) EndFunc ;==>_Testing_AttachSession ; gestion msedge Func _MY__WD_SetupMsEdge($b_Headless, $s_Download_dir = Default, $bTryAttach = False) ; _WD_UpdateDriver('msedge') ; If @error Then Return SetError(@error, @extended, '') _WD_Option('Driver', 'msedgedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', ' --port=9515') _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('firstMatch', 'msedge') _WD_CapabilitiesAdd('w3c', True) _WD_CapabilitiesAdd('detach', False) _WD_CapabilitiesAdd('binary', "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe") _WD_CapabilitiesAdd('args','start-maximized') _WD_CapabilitiesAdd('args','user-data-dir=' & $LocalDir) If $bTryAttach Then _WD_CapabilitiesAdd('debuggerAddress', '127.0.0.1:9222') Else _WD_CapabilitiesAdd('args', '--remote-debugging-port=9222') EndIf If $b_Headless Then _ _WD_CapabilitiesAdd('args', '--headless') If $s_Download_dir Then _ _WD_CapabilitiesAdd('prefs', 'download.default_directory', $s_Download_dir) _WD_CapabilitiesDump(@ScriptLineNumber & ' :WebDriver:Capabilities:') Local $iWebDriverPID = _WD_Startup() If @error Then WriteLog(@error & " " & @extended & " erreur wd_startup") Return SetError(@error, @extended, '') EndIf Local $s_Capabilities = _WD_CapabilitiesGet() Local $WD_SESSION = _WD_CreateSession($s_Capabilities) ; -- relance webdriver If @error Then WriteLog(@error & " " & @extended & " erreur wd_Create") If $bTryAttach Then WriteLog("relance webdriver") _Testing_CreateSession() _Testing_AttachSession() $Relance = True Else WriteLog("Erreur création session après couplage") Msgbox(16,"Erreur", "Erreur création session après couplage") Exit EndIf EndIf Local $iBrowserPID = _WD_GetBrowserPID($iWebDriverPID, 'msedge') ConsoleWrite("! $iBrowserPID=" & $iBrowserPID & @CRLF) Return SetError(@error, @extended, $WD_SESSION) EndFunc ;==>_MY__WD_SetupMsEdge logs from an error : expandcollapse popup_WD_CapabilitiesStartup: #-1 : > {"capabilities":"{}"} > IsObj = 1 _WD_CapabilitiesAdd: #-1 : $key = firstMatch $value1 = msedge $value2 = _WD_CapabilitiesAdd: #-1 : $_WD_NOTATION__MATCHTYPE = [capabilities][firstMatch][0] $_WD_NOTATION__SPECIFICVENDOR = ["ms:edgeOptions"] _WD_CapabilitiesAdd ==> Success [0] : Successfully used [firstMatch] with specified browser: msedge _WD_CapabilitiesAdd: #-1 : $key = w3c $value1 = True $value2 = _WD_CapabilitiesAdd: #-1 #-1 : $key = w3c $value1 = True $value2 = $s_Notation = [capabilities][firstMatch][0]["ms:edgeOptions"]["w3c"] <<<< True _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_CapabilitiesAdd: #-1 : $key = detach $value1 = False $value2 = _WD_CapabilitiesAdd: #-1 #-1 : $key = detach $value1 = False $value2 = $s_Notation = [capabilities][firstMatch][0]["ms:edgeOptions"] <<<< False _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_CapabilitiesAdd: #-1 : $key = binary $value1 = C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe $value2 = _WD_CapabilitiesAdd: #-1 #-1 : $key = binary $value1 = C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe $value2 = $s_Notation = [capabilities][firstMatch][0]["ms:edgeOptions"]["binary"] <<<< C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_CapabilitiesAdd: #-1 : $key = args $value1 = start-maximized $value2 = _WD_CapabilitiesAdd: #-1 #-1 : $key = args $value1 = start-maximized $value2 = $s_Notation = [capabilities][firstMatch][0]["ms:edgeOptions"]["args"][0] <<<< start-maximized _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_CapabilitiesAdd: #-1 : $key = args $value1 = user-data-dir=C:\Users\xxxxxx\AppData\Local\Microsoft\Edge\Driver Data $value2 = _WD_CapabilitiesAdd: #-1 #-1 : $key = args $value1 = user-data-dir=C:\Users\xxxxxx\AppData\Local\Microsoft\Edge\Driver Data $value2 = $s_Notation = [capabilities][firstMatch][0]["ms:edgeOptions"]["args"][1] <<<< user-data-dir=C:\Users\xxxxxx\AppData\Local\Microsoft\Edge\Driver Data _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_CapabilitiesAdd: #-1 : $key = debuggerAddress $value1 = 127.0.0.1:9222 $value2 = _WD_CapabilitiesAdd: #-1 #-1 : $key = debuggerAddress $value1 = 127.0.0.1:9222 $value2 = $s_Notation = [capabilities][firstMatch][0]["ms:edgeOptions"]["debuggerAddress"] <<<< 127.0.0.1:9222 _WD_CapabilitiesAdd ==> Success [0] : Successfully added capability _WD_CapabilitiesDump: JSON structure starts below: -1 :WebDriver:Capabilities: { "capabilities":{ "firstMatch":[ { "ms:edgeOptions":{ "binary":"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe", "args":[ "start-maximized", "user-data-dir=C:\\Users\\xxxxxx\\AppData\\Local\\Microsoft\\Edge\\Driver Data" ], "debuggerAddress":"127.0.0.1:9222" } } ] } } _WD_CapabilitiesDump: JSON structure ends above. _WD_GetFreePort ==> Success [0 / 9515] : Parameters: MinPort=9515 MaxPort=Default _WD_IsLatestRelease ==> Success [0] : False _WD_Startup: OS: WIN_10 X64 19045 _WD_Startup: AutoIt: 3.3.16.0 _WD_Startup: Webdriver UDF: 1.3.1 (Update available) _WD_Startup: WinHTTP: 1.6.4.2 _WD_Startup: Driver: msedgedriver.exe (32 Bit) _WD_Startup: Params: --port=9515 _WD_Startup: Port: 9515 _WD_Startup: Command: "msedgedriver.exe" --port=9515 _WD_Startup ==> Success [0] __WD_Post: URL=HTTP://127.0.0.1:9515/session; Data={ "capabilities":{ "firstMatch":[ { "ms:edgeOptions":{ "binary":"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe", "args":[ "start-maximized", "user-data-dir=C:\\Users\\xxxxxx\\AppData\\Local\\Microsoft\\Edge\\Driver Data" ], "debuggerAddress":"127.0.0.1:9222" } } ] } } __WD_Post ==> Send / Recv error [6] : HTTP status = 0 ResponseText=WinHTTP request timed out before Webdriver _WD_CreateSession ==> Webdriver Exception [10] it has the same vibe as this post, but i'm online
Danp2 Posted Monday at 02:24 PM Posted Monday at 02:24 PM As you stated, it's likely an environmental issue on the user's side. I see that you aren't running the latest version of the UDF, so you should probably address that. Does the issue occur with all browsers or only Edge? Latest Webdriver UDF Release Webdriver Wiki FAQs
Kelv Posted 19 hours ago Author Posted 19 hours ago Hello, thanks for your reply I tried with an up to date version of the UDF, without any changes. I didn't try with an other browser, i'll check if i can do that. A thing i don't understand is why my first script work when the retry on the second one (if the _wd_CreateSession failed) does not.
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