Jump to content

Recommended Posts

Posted
  On 5/26/2021 at 7:18 PM, seadoggie01 said:

Here's the simplest reproducer I have

Expand  

That mimics the error, but not exactly a reproducer of the issue you described. Are you doing anything like utilizing an existing profile or loading any extensions?

  Quote

Edge is discarding my tab when it is minimized

Expand  

Have you checked to see if there's a way to disable this feature under Webdriver?

Posted

The original method is to load the webpage, wait an unknown amount of time while it's minimized (likely 5 minutes?) for it to be discarded, then attempt to navigate to the webpage again. Both methods return an error 10, extended 404, so I figured the faster method would be appreciated :)

I have no extensions and I'm using the default profile.

I've tried to find a method to avoid discarding, but it doesn't seem to be available. Chromium has a command-line option under Chrome OS, but it doesn't work for Edge on Windows. There's an option for aggressive discarding, but nothing I've seen to turn it off

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

  Reveal hidden contents
Posted

While I don't receive an error about those capabilities, it doesn't stop the tab from being discarded

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

  Reveal hidden contents
Posted (edited)

Hello,

Me and @mLipok we have problem with creating a sessions.

There is no problem on our local computers. We only have a problem on some computers at customer's premises but not at all.

Below is the function:

Func _MY__WD_SetupChrome($b_Headless)
    $_WD_DEBUG = $_WD_DEBUG_Error
    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)

    Local $s_Desired_Capabilities
    If $b_Headless Then
        $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless", "start-maximized", "disable-infobars","user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Default"]}}}}'
;~      $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless", "start-maximized", "disable-infobars","user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Default", "--no-sandbox"]}}}}'
;~      $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless", "start-maximized", "disable-infobars"]}}}}'
    Else
        $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars","user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Default"]}}}}'
;~      $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars","user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Default", "--no-sandbox"]}}}}'
;~      $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars"]}}}}'
    EndIf

    _WD_Startup()

    Local $WD_SESSION = _WD_CreateSession($s_Desired_Capabilities)

    Return SetError(@error, @extended, $WD_SESSION)
EndFunc   ;==>_MY__WD_SetupChrome

We tried with diffrent Capabilities :

1. With this Capabilites

$s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless", "start-maximized", "disable-infobars","user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Default"]}}}}'

we have such an error:

! @error=10 @extended=500

2. With this Capabilites:

$s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless", "start-maximized", "disable-infobars"]}}}}'

;~      $s_Desired_Capabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--headless", "start-maximized", "disable-infobars","user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Default", "--no-sandbox"]}}}}'

we have such an error:

! @error=10 @extended=0

Maybe someone has encountered the above errors and knows how to solve the problem??
 

Edited by dPilar
Posted

@Danp2 Thank you for the answer and advice.

 

I found a solution. The computers had an updated version of Google Chrome to the latest version. Which made my chromedriver.exe unable to start.

I download the lastes version chromedriver.exe and it started working. 

I have to write a function that checks Google Chrome version and update it automatically.

Posted (edited)

Hi Dan,

with the new version (91.) of chrome and chromedriver I sometimes get an error "no such window ... / already closed" when opening several new windows with

$sNewHandle= _WD_Window($sSess, 'new', '{"type":"window"}')

2021-05-26 15:04:35 : _WD_Window new: err:10
{"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unknown error: web view not found\n  (Session info: chrome=91.0.4472.77)","stacktrace":"Backtrace:\n\tOrdinal0 [0x0085C013+2474003]\n\tOrdinal0 [0x007F29C1+2042305]\n\tOrdinal0 [0x00702F68+1060712]\n\tOrdinal0 [0x006EC406+967686]\n\tOrdinal0 [0x00748459+1344601]\n\tOrdinal0 [0x00754C82+1395842]\n\tOrdinal0 [0x007466DB+1337051]\n\tOrdinal0 [0x00723427+1192999]\n\tOrdinal0 [0x007242EE+1196782]\n\tOrdinal0 [0x00724279+1196665]\n\tGetHandleVerifier [0x009E96FC+1590332]\n\tGetHandleVerifier [0x00A98614+2306900]\n\tGetHandleVerifier [0x008E9E93+543699]\n\tGetHandleVerifier [0x008E92CE+540686]\n\tOrdinal0 [0x007F86BA+2066106]\n\tOrdinal0 [0x007FD1C8+2085320]\n\tOrdinal0 [0x007FD308+2085640]\n\tOrdinal0 [0x008067F3+2123763]\n\tBaseThreadInitThunk [0x75E3FA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77AA7A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77AA7A4E+238]\n"}}

The error comes just after New_Window withou any URL. Do you have an idea what could be the reason?

Edited by HJL
Posted (edited)

Is there a way to change HTML element to my own ?
I mean I want to change one <DIV> with my own content.


Most of them I hide but I need to change one of them to add my own header to document, just before I print them to PDF.

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

hmm... Do you mean that I could use _WD_ExecuteScript() ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

 _WD_ExecuteScript()
+

  Quote

window.document.getElementsByClassName("grey-box yellow-box")[0].outerHTML="<div>MY OWN CONTENT</div>"

Expand  

do the tricks.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 5/31/2021 at 1:21 PM, Danp2 said:

@HJL I've read where others have encountered issues with Chrome v91. Are you able to consistently reproduce the issue? If so, then please post a short reproducer.

Expand  

Got it:

#include "wd_core.au3"
#include "wd_helper.au3"

$_WD_DEBUG = $_WD_DEBUG_Info

Local $sDesiredCapabilities, $sSession
Local $sWebDriverFileChrome = @ScriptDir & "\chromedriver.exe"

TestNewWindow()

_WD_DeleteSession($sSession)
_WD_Shutdown()

Func TestNewWindow()
    SetupChrome()
    _WD_Startup()
    $sSession = _WD_CreateSession($sDesiredCapabilities)
    Local $sHnd1 = _WD_Window($sSession, 'new', '{"type":"window"}')
    ConsoleWrite('>>WD_Window new: error:' & @error & "  new window ok" & @CRLF)
    _WD_Window($sSession, 'Switch', '{"handle":"' & $sHnd1 & '"}')
    _WD_Navigate($sSession, "https:\\wdr5.de")
    Sleep(3000)
    WinClose("Startseite")
    Sleep(3000)
    $sHnd1 = _WD_Window($sSession, 'new', '{"type":"window"}')
    If @error > 0 Then ConsoleWrite('>>WD_Window new: error:' & @error & " new window: 'no such window: window was already closed'" & @CRLF)
EndFunc   ;==>TestWindows

Func SetupChrome()
    _WD_Option('Driver', $sWebDriverFileChrome)
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')
    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"]}}}}'
EndFunc   ;==>SetupChrome

Result:

>>WD_Window new: error:0  new window ok
__WD_Post: URL=HTTP://127.0.0.1:9515/session/40f35e5cc0be368ee5e59cf6cb6c000a/window; $sData={"handle":"CDwindow-C673FF9062F1C103795815A6E449867E"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Window: {"value":null}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/40f35e5cc0be368ee5e59cf6cb6c000a/url; $sData={"url":"https:\\wdr5.de"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Navigate: {"value":null}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/40f35e5cc0be368ee5e59cf6cb6c000a/window/new; $sData={"type":"window"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such window","message":"no such window: window was already closed\n  (Session ...
__WD_Post ==> Webdriver Exception: {"value":{"error":"no such window","message":"no such window: window was already closed\n  (Session info: chrome=91.0.4472.77)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00D72DB3+2502067]\n\tOrdinal0 [0x00D0C5B1+2082225]\n\tOrdinal0 [0x00C12498+1057944]\n\tOrdinal0 [0x00C08371+1016689]\n\tOrdinal0 [0x00C09345+1020741]\n\tOrdinal0 [0x00C03466+996454]\n\tOrdinal0 [0x00C136A0+1062560]\n\tOrdinal0 [0x00C64272+1393266]\n\tOrdinal0 [0x00C55BEB+1334251]\n\tOrdinal0 [0x00C32174+1188212]\n\tOrdinal0 [0x00C33009+1191945]\n\tGetHandleVerifier [0x00EEEC5C+1511084]\n\tGetHandleVerifier [0x00F98522+2205554]\n\tGetHandleVerifier [0x00DF3393+480739]\n\tGetHandleVerifier [0x00DF2579+477129]\n\tOrdinal0 [0x00D11E5D+2104925]\n\tOrdinal0 [0x00D163F8+2122744]\n\tOrdinal0 [0x00D16537+2123063]\n\tOrdinal0 [0x00D1EE53+2158163]\n\tBaseThreadInitThunk [0x7588FA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x777A7A7E+286]\n\tRtlGetAppContainerNamedObjectPath [0x777A7A4E+238]\n"}}
_WD_Window: {"value":{"error":"no such window","message":"no such window: window was already closed\n  (Session ...
_WD_Window ==> Webdriver Exception: HTTP status = 404
>>WD_Window new: error:10 new window: 'no such window: window was already closed'

 

Edited by HJL
Posted

New script, "no such window" happens with all 3 drivers...

 

#include "wd_core.au3"
#include "wd_helper.au3"

$_WD_DEBUG = $_WD_DEBUG_Info

Local $sDesiredCapabilities, $sSession
Local $sWebDriverFileChrome = @ScriptDir & "\chromedriver.exe"
Local $sWebDriverFileGecko  = @ScriptDir & "\geckodriver.exe"
Local $sWebDriverFileEdge   = @ScriptDir & "\msedgedriver.exe"

TestNewWindow("Chrome")
TestNewWindow("Gecko")
TestNewWindow("Edge")

Func TestNewWindow($sBrowser)
    Local $sHnd1
    Switch $sBrowser
        Case "Chrome"
            SetupChrome()
        Case "Gecko"
            SetupGecko()
        Case "Edge"
            SetupEdge()
    EndSwitch
    _WD_Startup()

    $sSession = _WD_CreateSession($sDesiredCapabilities)
    $sHnd1 = _WD_Window($sSession, 'new', '{"type":"window"}')
    ConsoleWrite('>>WD_Window ' & $sBrowser & ' new: error:' & @error & '  new window ok' & @CRLF)
    _WD_Window($sSession, 'Switch', '{"handle":"' & $sHnd1 & '"}')
    _WD_Navigate($sSession, "https:\\wdr5.de")
    Sleep(2000)
    WinClose("Startseite")
    Sleep(2000)
    $sHnd1 = _WD_Window($sSession, 'new', '{"type":"window"}')
    If @error > 0 Then ConsoleWrite('>>WD_Window ' & $sBrowser & ' new: error:' & @error & ' new window: "no such window"' & @CRLF)
    MsgBox($MB_TOPMOST, 'Test New Window', $sBrowser & 'Driver' & @CRLF & 'Press OK to continue')
    _WD_DeleteSession($sSession)
    _WD_Shutdown()

EndFunc   ;==>TestWindows

Func SetupChrome()
    _WD_Option('Driver', $sWebDriverFileChrome)
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')
    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"]}}}}'
EndFunc   ;==>SetupChrome

Func SetupGecko()
    Local $sFuncName = "SetupGecko"
    _WD_Option('Driver', $sWebDriverFileGecko)
    _WD_Option('DriverParams', '--log trace --marionette-port 2828')
    _WD_Option('Port', 4444)
    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}'
EndFunc

Func SetupEdge()
    _WD_Option('Driver', $sWebDriverFileEdge)
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\msedge.log"')
    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"binary": "' & StringReplace(@ProgramFilesDir, "\", "/") & '/Microsoft/Edge/Application/msedge.exe", "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false}}}}'
EndFunc   ;==>SetupEdge

 

Posted

@HJL From the W3C specs --

  Quote
Expand  

so what you are encountering is by design. You need to switch to another valid window before the command will succeed --

Func TestNewWindow($sBrowser)
    Local $sHnd1
    Switch $sBrowser
        Case "Chrome"
            SetupChrome()
        Case "Gecko"
            SetupGecko()
        Case "Edge"
            SetupEdge()
    EndSwitch
    _WD_Startup()

    $sSession = _WD_CreateSession($sDesiredCapabilities)
    $sHnd1 = _WD_Window($sSession, 'window')
    $sHnd2 = _WD_Window($sSession, 'new', '{"type":"window"}')
    ConsoleWrite('>>WD_Window ' & $sBrowser & ' new: error:' & @error & '  new window ok' & @CRLF)
    _WD_Window($sSession, 'Switch', '{"handle":"' & $sHnd2 & '"}')
    _WD_Navigate($sSession, "https:\\wdr5.de")
    Sleep(2000)
    WinClose("Startseite")
    Sleep(2000)
    _WD_Window($sSession, 'Switch', '{"handle":"' & $sHnd1 & '"}')
    $sHnd1 = _WD_Window($sSession, 'new', '{"type":"window"}')
    If @error > 0 Then ConsoleWrite('>>WD_Window ' & $sBrowser & ' new: error:' & @error & ' new window: "no such window"' & @CRLF)
    MsgBox($MB_TOPMOST, 'Test New Window', $sBrowser & 'Driver' & @CRLF & 'Press OK to continue')
    _WD_DeleteSession($sSession)
    _WD_Shutdown()

EndFunc   ;==>TestWindows

 

Posted

If I close all before opened windows  _WD_Window($sSession 'new', '{"type":"window"}'produces always an error?

What do I have to do when a user discards all before openened windows? I can check the list of handles (empty in this case) - but what to do then? Again start a session with $sSession = _WD_CreateSession($sDesiredCapabilities)?

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...