Jump to content

Recommended Posts

Posted
  On 3/21/2023 at 9:57 PM, mLipok said:

Have you tried with FireFox or MS EDGE?
What about these browsers?

Expand  

I did not. The first time i used webdriver i had trouble with Firefox and Edge. Chrome worked so i never looked back.
i try to test it in the next days with Firefox and Edge.

 

I have one more question.

 

I try to click the highlighted button in a shadow root.

html.PNG.09c33efc4aa48461e110bf567933b9b

I tried this so far.

$sRoot = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='usercentrics-root']")
ConsoleWrite("$sRoot = " & $sRoot & @CRLF)

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[contains(text(),'Alles akzeptieren')], $sRoot, "", True)
ConsoleWrite("$sElement = " & $sElement & @CRLF)

_WD_ElementAction($sSession, $sElement, "click")

 

_WD_GetShadowRoot seems to work but i cant find the button to click on.
_WD_FindElement does not return any value. The XPath query is working on other websites with no shadow root folder if i change the 'Alles akzeptieren' to the right button text value.

 

__WD_Post ==> Success [0] : HTTP status = 200
_WD_FindElement ==> Success [0] : Parameters:   Strategy=xpath   Selector=//*[@id='usercentrics-root']   StartNodeID=   Multiple=Default   ShadowRoot=Default
__WD_Get ==> Success [0] : HTTP status = 200
_WD_ElementAction ==> Success [0] : Parameters:   Command=shadow   Option=Default
_WD_GetShadowRoot ==> Success [0] : Parameters:    Strategy=xpath    Selector=//*[@id='usercentrics-root']    StartElement=Default
$sRoot = 88c20f5f-4724-442b-ac39-2a7ae1202573
_WD_FindElement ==> Invalid Expression [11] : Parameters:   Strategy=xpath   Selector=//button[contains(text(),'Alles akzeptieren')]   StartNodeID=88c20f5f-4724-442b-ac39-2a7ae1202573   Multiple=   ShadowRoot=True
$sElement =
__WD_Post ==> No match [8] : HTTP status = 404
_WD_ElementAction ==> No match [8] : Parameters:   Command=click   Option=Default

 

Posted

You have issue in your code:

$sRoot = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='usercentrics-root']")
ConsoleWrite("$sRoot = " & $sRoot & @CRLF)

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[contains(text(),'Alles akzeptieren')], $sRoot, "", True)
ConsoleWrite("$sElement = " & $sElement & @CRLF)

_WD_ElementAction($sSession, $sElement, "click")

there is lack of double quotes should be:

$sRoot = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='usercentrics-root']")
ConsoleWrite("$sRoot = " & $sRoot & @CRLF)

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[contains(text(),'Alles akzeptieren')]", $sRoot, "", True)
ConsoleWrite("$sElement = " & $sElement & @CRLF)

_WD_ElementAction($sSession, $sElement, "click")

 

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
  On 3/22/2023 at 1:26 PM, mLipok said:

You have issue in your code:

$sRoot = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='usercentrics-root']")
ConsoleWrite("$sRoot = " & $sRoot & @CRLF)

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[contains(text(),'Alles akzeptieren')], $sRoot, "", True)
ConsoleWrite("$sElement = " & $sElement & @CRLF)

_WD_ElementAction($sSession, $sElement, "click")

there is lack of double quotes should be:

$sRoot = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='usercentrics-root']")
ConsoleWrite("$sRoot = " & $sRoot & @CRLF)

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[contains(text(),'Alles akzeptieren')]", $sRoot, "", True)
ConsoleWrite("$sElement = " & $sElement & @CRLF)

_WD_ElementAction($sSession, $sElement, "click")
Expand  

Hi i saw this after my post was submitted. The " is not missing in my real code, its still not working, the console output is the same.

$sElement dont get any value.

Posted

Ah you have ShadowRoot. Which browser do you use ? If this is FireFox that I want to say to you that this is a know bug:

 

https://github.com/Danp2/au3WebDriver/issues/26#issuecomment-1473758459

 

 

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

@Danp2 Thx for your reply. i tried to modifie my script and have something like this.

 

$sRoot = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='usercentrics-root']")
ConsoleWrite("$sRoot = " & $sRoot & @CRLF)

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/.div/div/div[2]/div/div[2]/div/div[2]/div/div/div[2]/div/button[3]", $sRoot, "", True)
ConsoleWrite("$sElement = " & $sElement & @CRLF)

This is the output from the console:

__WD_Post ==> Success [0] : HTTP status = 200
_WD_FindElement ==> Success [0] : Parameters:   Strategy=xpath   Selector=//*[@id='usercentrics-root']   StartNodeID=   Multiple=Default   ShadowRoot=Default
__WD_Get ==> Success [0] : HTTP status = 200
_WD_ElementAction ==> Success [0] : Parameters:   Command=shadow   Option=Default
_WD_GetShadowRoot ==> Success [0] : Parameters:    Strategy=xpath    Selector=//*[@id='usercentrics-root']    StartElement=Default
$sRoot = 203a1715-8eeb-4795-8c72-cb4834cf7276
_WD_FindElement ==> Invalid Expression [11] : Parameters:   Strategy=xpath   Selector=/.div/div/div[2]/div/div[2]/div/div[2]/div/div/div[2]/div/button[3]   StartNodeID=203a1715-8eeb-4795-8c72-cb4834cf7276   Multiple=   ShadowRoot=True
$sElement =

I dont know if the xpath string is correct, i cant test it anywhere before running the script.

i try to click the cookie accept button on this website
https://www.na-kd.com/de

Posted (edited)

Do not have his full code but he will need to add some sleep after page load or some other func _WD_WaitElement maybe?. Shadow root main element is maybe defined on page load but its html content is generated later probably on document ready with js/jquery. Some sleep after page load will result in correct selector.

 

_WD_Navigate($sSession, "https://www.na-kd.com/de")
Sleep(10000)
$sRoot = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByCSSSelector, "#usercentrics-root")
$sHTML = _WD_ElementAction($sSession, $sRoot, 'property', 'innerHTML')
ConsoleWrite("source: [" & $sHTML & "]" & @CRLF)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "button:last-child", $sRoot, Default, True)
_WD_ElementAction($sSession, $sElement, "click")

 

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)

  Reveal hidden contents


460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Posted

@bogQ Thanks.
Based on your information, I think it works like multiple nested frames where each document can be generated separately.

Currently _WD_WaitLoad() waits only on current document (usually main document not any frames), and such behavior is true as long as you wont switch to other frames and use _WD_WaitLoad() for the other frames too.

So I wonder if ShadowRoot should be considered as separate document which also should be checked for ReadyState.

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

@mLipok Its nothing wrong to wait for element to spawn in existence. So I do not think it will never need ReadyState, read below.

I think it all depends of site code and its implementation of shadow doom. For this specific case I am presuming (from logs) that site created shadow doom from the start as this structure representation...

<div id="usercentrics-root" data-created-at="1679569636197" style="">
    #shadow-root (open)
        <div data-nosnippet="1" data-testid="uc-app-container"></div>
</div>

and only after that on page load event he populated its data inside attribute testid="uc-app-container" div element when he detected that user did not have cookie where he accepted cookies.

I do not think that await/promises can count that page still is not loaded if used in this case, so that is why ReadyState (in my head) should not happen for shadow doom.

Think this site was a specific case and nothing else. If you asked me (if i coeede with selenium in python) I would just remove that element with js so that it whud not interfere with other automation or just use js.click instead selenium.click. Who need to accept cookies this dayes 😀 ...

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)

  Reveal hidden contents


460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Posted

@bogQ

Please take a look on:

https://github.com/Danp2/au3WebDriver/issues/353

Especially:

  Quote

wondering if such readyState checking is possible:

document.querySelector("body > print-preview-app").shadowRoot.querySelector("#sidebar").shadowRoot.document.readyState
Expand  

 

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)

as so far I'm not familiar with ShadowRoot

So I want to ask about your snippet

  On 3/23/2023 at 11:23 AM, bogQ said:

 

<div id="usercentrics-root" data-created-at="1679569636197" style="">
    #shadow-root (open)
        <div data-nosnippet="1" data-testid="uc-app-container"></div>
</div>

 

Expand  

In this scenario you (open) #shadow-root and I wonder where it closes.

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 (edited)
  On 3/23/2023 at 11:24 AM, mLipok said:

@bogQ

Please take a look on:

https://github.com/Danp2/au3WebDriver/issues/353

Especially:

 

Expand  

that is why in selenium there is for example: 

  Quote

WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "myDynamicElement"))

Expand  

So i presume that "_WD_WaitElement" is equivalent of that in WebDriver UDF?

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)

  Reveal hidden contents


460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Posted
  On 3/23/2023 at 11:29 AM, bogQ said:

So i presume that "_WD_WaitElement" is equivalent of that in WebDriver UDF?

Expand  

I think that you did correct comparition, but @Danp2 have better experience to confirm (especially that I do not know selenium).

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 3/23/2023 at 11:28 AM, mLipok said:

as so far I'm not familiar with ShadowRoot

So I want to ask about your snippet

In this scenario you (open) #shadow-root and I wonder where it closes.

Expand  

I think it does not close, to me its just a info block that say "hey there is something below me" but represanted with that text. Most of the time i had to interact with shadow it was because of Carbon Design.

Eather way you can read some basic info about shadow on this link https://javascript.info/shadow-dom (its not too long and explanation is good and breaf)

and on this page if your interested is css cove with some handeling for "::part()" https://css-tricks.com/styling-in-the-shadow-dom-with-css-shadow-parts/

and for ":host()"  https://developer.mozilla.org/en-US/docs/Web/CSS/:host

 

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)

  Reveal hidden contents


460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Posted (edited)
  On 3/23/2023 at 11:28 AM, mLipok said:

as so far I'm not familiar with ShadowRoot

So I want to ask about your snippet

In this scenario you (open) #shadow-root and I wonder where it closes.

Expand  

Maybe i misunderstood, this is not a snippet this is just structure representation. I do not think you can create it with html. As far as i know it is created only with js and attached with it to some html element. "#shadow-root (open)" text is just there to inform you that it exist.

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)

  Reveal hidden contents


460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Posted
  On 3/22/2023 at 11:42 PM, Danp2 said:

@naixZ94You've got the period in the wrong location. It goes before the first slash, not after it.

P.S. You could also try locating it with CSS instead of xpath

Expand  

@Danp2 its not working with xpath,even with the period in the right location.

But i got it to working with a different selector.

$sRoot = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='usercentrics-root']")
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".sc-eDvSVe.jIuKWg", $sRoot, "", True)
_WD_ElementAction($sSession, $sElement, "click")

 

  • 2 weeks later...
Posted

Hello All,

I dont undestand, before a few day or week ago, when I made a:

_WD_Window($sSession, 'Switch', '{"handle":"' & $sCurrentTabHandle & '"}')

the FF or Edge windows was put at foreground, but today only the Edge windows is put at foreground and FF stay at the back of the other windows !!

I also tried with :

_WD_ExecuteScript($sSession, "window.focus();", Default, Default, $_WD_JSON_Value) ;

But no way!

Here my last updates for webdriver, winhttp !! and    "geckodriver-v0.33.0-win64"

_WD_GetFreePort ==> Success [0] : 4444
_WD_IsLatestRelease ==> Success [0] : True
_WD_Startup: OS:    WIN_10 WIN32_NT 19044 
_WD_Startup: AutoIt:    3.3.16.0
_WD_Startup: Webdriver UDF: 0.13.0 (Up to date)
_WD_Startup: WinHTTP:   1.6.4.2
_WD_Startup: Driver:    geckodriver.exe (64 Bit)
_WD_Startup: Params:    --log trace
_WD_Startup: Port:  4444
_WD_Startup: Command:   "geckodriver.exe" --log trace 
_WD_Startup ==> Success [0]
> capabilities OUT = {
    "capabilities":{
        "alwaysMatch":{
            "browserName":"firefox",
            "acceptInsecureCerts":true
        }
    }
}

Thanks a lot for your help

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

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