Jump to content

Recommended Posts

Hi, I am trying to automate clicks in a web page using Google Chrome. I know it is possible with keystrokes but i want it to be more specific, and to avoid risk.

I am able to access the first shadow root, but not the second one when the dropdown is clicked. I also have a spreadsheet that I have reading into an array variable that is used to select it using the _WD_ElementOptionSelect($sSession, $test4,  $aArray4Test[$i]) I did not put the for loop in as that's not what the issue is. 

So far, i have:

HTML Tree:

<mds-select selected-index="-1" accessible-text-cardinality-separator="of" accessible-text-collapsed="collapsed" accessible-text-expanded="expanded" value-key="value" label-key="label" error-messages="[]" value="" required="false" label-style="vertical" label-columns="" input-columns="" inactive="false" error-message-prefix="Error:" error-message="" variant="box" placeholder="Select one" options="[{"label":"Monkey","value":"Monkey","index":0},{"label":"Mochi","value":"Mochi","index":1}]" label="Object" id="" class="col-md-3 link-section mds-select--cpo"><input type="hidden" name="undefined" value="" disabled="disabled"><input type="hidden" name="undefined" value="" disabled="">
<!--1st Shadow Root, open-->
    <div class="mds-select__label-wrap">
        <label class="mds-select__label mds-select__label--box" id="select-linkCategoryId-label">Object</label>
    </div>
    <div class="mds-select__select-wrap mds-select__select-wrap--vertical-label">
        <div class="mds-select__menu mds-select__menu--hidden">
            <div class="mds-select__menu-list">
                <mds-select-option data-index="0" data-setsize="6" value="Monkey" label="Monkey" selected="false" data-accessible-text-cardinality-separator="of" inactive="false" class="mds-select-option--cpo">
                <!--2nd Shadow Root within, open-->
                
                    <div class="option option--hidden" tabindex="-1" role="option" aria-disabled="false" aria-posinset="1" aria-setsize="6">
                        <div class="option__label">
                            <span class="option__accessible-text">Monkey</span>
                            <span class="option__label-primary" aria-hidden="true">Monkey</span>
                            <div class="option__slot-container" aria-hidden="true">
                                <slot></slot>
                            </div>
                        </div>
                    </div>
                
                </mds-select-option>
                
                <mds-select-option data-index="1" data-setsize="6" value="Mochi" label="Mochi" selected="false" data-accessible-text-cardinality-separator="of" inactive="false" class="mds-select-option--cpo">
                <!--2nd Shadow Root within, open-->
                
                    <div class="option option--hidden" tabindex="-1" role="option" aria-disabled="false" aria-posinset="1" aria-setsize="6">
                        <div class="option__label">
                            <span class="option__accessible-text">Mochi</span>
                            <span class="option__label-primary" aria-hidden="true">Mochi</span>
                            <div class="option__slot-container" aria-hidden="true">
                                <slot></slot>
                            </div>
                        </div>
                    </div>
                
                </mds-select-option>
            </div>
        </div>
    </div>
</mds-select>

AutoIt script:

#Include "Chrome.au3"

#Include "wd_core.au3"

#Include "wd_helper.au3"

#Include "Excel.au3"

 

 

Local $sDesiredCapabilities, $sSession

SetupChrome()

 

_WD_Startup()

 

 

$sSession = _WD_CreateSession($sDesiredCapabilities)

 

_WD_LoadWait($sSession)

 

_WD_Navigate($sSession, "input.html")

 

;;;First Shadow root

Local $oExcel = _Excel_Open()

Local $oWorkbook = _Excel_BookOpen($oExcel, "input.xlsx")

Local $aArray4Test = _Excel_RangeRead($oWorkbook,1,$oWorkbook.ActiveSheet.Usedrange.Columns("A:A"))

Local $oSettingsUISR = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByTagName, "mds-select")

 

_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//mds-select[contains(@class,'col-md-3 link-section mds-select--cpo') or contains(text(),'Object')]")

$test3 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//mds-select[contains(@class,'col-md-3 link-section mds-select--cpo') or contains(text(),'Object')]")

_WD_ElementAction($sSession, $test3, 'click')

 

Sleep(9000)

 

;;;Second Shadow root within

 

Local $oSettingsUISR = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByTagName, "mds-select-option")

 

_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//span[contains(@class,'option__label-primary')]")

$test4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[contains(@class,'option__label-primary')]")

_WD_ElementOptionSelect($sSession, $test4,  $aArray4Test[$i])
 

_WD_Shutdown()

 

Func SetupChrome()

    _WD_Option('Driver', 'chromedriver.exe')

    _WD_Option('Port', 9515)

    _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')

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

EndFunc   ;==>SetupChrome  

I am thinking that there's something wrong with these:

$test4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[contains(@class,'option__label-primary')]")
_WD_ElementOptionSelect($sSession, $test4, 'Test6')

I have also attempted to do this, but it didnt work:

$test3 = 'return document.querySelector("mds-select").shadowRoot.querySelector(".mds-select__container").querySelector(".mds-select__select-wrap").shadowRoot.querySelector(".mds-select__menu").shadowRoot.querySelector(".mds-select__menu-list").shadowRoot.querySelector(".mds-select-option[0]");'
$test4 = _WD_ElementAction($sSession, $test3, 'click')

 

 

Capture.PNG

Edited by Hermes
modified image
Link to post
Share on other sites

ShadowRoot access was recently added to the W3C specs, but it may be a while before it becomes "official".

Both _WD_GetShadowRoot and _WD_FindElement were updated in the latest release to support these latest revision. However, I'm not sure that Chromedriver has been updated to support these features.

Have you tried passing the retrieved shadowroot to _WD_FindElement as the starting element? Without that, you are searching in the main DOM, not the shadow DOM.

 

Link to post
Share on other sites
#Include "Chrome.au3"

#Include "wd_core.au3"

#Include "wd_helper.au3"

#Include "Excel.au3"

 

 

Local $sDesiredCapabilities, $sSession

SetupChrome()

 

_WD_Startup()

 

 

$sSession = _WD_CreateSession($sDesiredCapabilities)

 

_WD_LoadWait($sSession)

 

_WD_Navigate($sSession, "input.html")

 

;;;First Shadow root

Local $oExcel = _Excel_Open()

Local $oWorkbook = _Excel_BookOpen($oExcel, "input.xlsx")

Local $aArray4Test = _Excel_RangeRead($oWorkbook,1,$oWorkbook.ActiveSheet.Usedrange.Columns("A:A"))

Local $oSettingsUISR = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByTagName, "mds-select")

 

_WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByTagName, "mds-select")
Local $oTemp = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".mds-select__select mds-select__select--box mds-select__select--placeholder", $oSettingsUISR)
_WD_ElementAction($sSession, $oTemp, 'click')
Local $oSettingsMainSR = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByTagName, "mds-select-option", $oTemp)
Local $oSettingsAboutPageSR = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".option__label-primary", $oSettingsMainSR)
Local $selectTest = _WD_ElementOptionSelect($sSession, $oSettingsAboutPageSR, $aArray4Test[$i]) 
 

_WD_Shutdown()

 

Func SetupChrome()

    _WD_Option('Driver', 'chromedriver.exe')

    _WD_Option('Port', 9515)

    _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')

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

EndFunc   ;==>SetupChrome

@Danp2 I tried running the above script but still didn't work. Any ideas?

Link to post
Share on other sites

@Hermes Unfortunately, "didn't work" isn't detailed enough to know what went wrong.  Show us the results from the Scite output panel (assumes you are using the default of $_WD_DEBUG = $_WD_DEBUG_Info).

Also, your code looks a little off. Why did you call _WD_GetShadowRoot two times in a row? Also, _WD_FindElement has an optional parameter that you need to set so that it knows that the Starting Node is actually a shadow root.

We may need to come up with an alternate solution if Chromedriver hasn't implemented this new methodology.

Link to post
Share on other sites

@Danp2 I went ahead and corrected the script. I removed the extra shadow root from the script

#Include "Chrome.au3"

#Include "wd_core.au3"

#Include "wd_helper.au3"

#Include "Excel.au3"

 

 

Local $sDesiredCapabilities, $sSession

SetupChrome()

 

_WD_Startup()

 

 

$sSession = _WD_CreateSession($sDesiredCapabilities)

 

_WD_LoadWait($sSession)

 

_WD_Navigate($sSession, "input.html")

 

;;;First Shadow root

Local $oExcel = _Excel_Open()

Local $oWorkbook = _Excel_BookOpen($oExcel, "input.xlsx")

Local $aArray4Test = _Excel_RangeRead($oWorkbook,1,$oWorkbook.ActiveSheet.Usedrange.Columns("A:A"))

Local $oSettingsUISR = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByTagName, "mds-select", True)

Local $oTemp = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".mds-select__select mds-select__select--box mds-select__select--placeholder", $oSettingsUISR)
_WD_ElementAction($sSession, $oTemp, 'click')
Local $oSettingsMainSR = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByTagName, "mds-select-option", $oTemp)
Local $oSettingsAboutPageSR = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".option__label-primary", $oSettingsMainSR)
Local $selectTest = _WD_ElementOptionSelect($sSession, $oSettingsAboutPageSR, $aArray4Test[$i]) 
 

_WD_Shutdown()

 

Func SetupChrome()

    _WD_Option('Driver', 'chromedriver.exe')

    _WD_Option('Port', 9515)

    _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')

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

EndFunc   ;==>SetupChrome

Here is the output from Scite output console

__WD_Post: URL=HTTP://127.0.0.1:9515/session/fdda6c6cd3f0ab5ceb74a3b1933101f4/element; $sData={"using":"tag name","value":"mds-select"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"40b14e2e-b580-4fac-94eb-4bf9940b7fbb"}}...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"40b14e2e-b580-4fac-94eb-4bf9940b7fbb"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/fdda6c6cd3f0ab5ceb74a3b1933101f4/execute/sync; $sData={"script":"return arguments[0].shadowRoot", "args":[{"element-6066-11e4-a52e-4f735466cecf":"40b14e2e-b580-4fac-94eb-4bf9940b7fbb"}]}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"1c6a9fd3-7ce2-44ea-918d-e2e1a901f43f"}}...
_WD_ExecuteScript: {"value":{"element-6066-11e4-a52e-4f735466cecf":"1c6a9fd3-7ce2-44ea-918d-e2e1a901f43f"}}...
_WD_GetShadowRoot: 1c6a9fd3-7ce2-44ea-918d-e2e1a901f43f
_WD_GetShadowRoot ==> Success
__WD_Post: URL=HTTP://127.0.0.1:9515/session/fdda6c6cd3f0ab5ceb74a3b1933101f4/element/1c6a9fd3-7ce2-44ea-918d-e2e1a901f43f/element; $sData={"using":"css selector","value":".mds-select__select mds-select__select--box mds-select__select--placeholder"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\...
__WD_Post ==> No match: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"css selector\",\"selector\":\".mds-select__select mds-select__select--box mds-select__select--placeholder\"}\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x011AD343+3134275]\n\tOrdinal0 [0x0109A131+2007345]\n\tOrdinal0 [0x00F3AEC8+569032]\n\tOrdinal0 [0x00ECA72F+108335]\n\tOrdinal0 [0x00EC4A01+84481]\n\tOrdinal0 [0x00EDEC90+191632]\n\tOrdinal0 [0x00EC4986+84358]\n\tOrdinal0 [0x00EDED31+191793]\n\tOrdinal0 [0x00EE8773+231283]\n\tOrdinal0 [0x00EDEB0B+191243]\n\tOrdinal0 [0x00EC2E77+77431]\n\tOrdinal0 [0x00EC3E3E+81470]\n\tOrdinal0 [0x00EC3DC9+81353]\n\tOrdinal0 [0x010B0C99+2100377]\n\tGetHandleVerifier [0x0131B71A+1396954]\n\tGetHandleVerifier [0x0131B399+1396057]\n\tGetHandleVerifier [0x013270E6+1444518]\n\tGetHandleVerifier [0x0131BCA8+1398376]\n\tOrdinal0 [0x010A7F11+2064145]\n\tOrdinal0 [0x010B22AB+2106027]\n\tOrdinal0 [0x010B23D1+2106321]\n\tOrdinal0 [0x010C4984+2181508]\n\tBaseThreadInitThunk [0x764062C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77940779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77940744+1028]\n"}}
_WD_FindElement: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"css selector\",\"selector\":\".mds-select__select mds-select__select--box mds-select__select--placeholder\"}\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x011AD343+3134275]\n\tOrdinal0 [0x0109A131+2007345]\n\tOrdinal0 [0x00F3AEC8+569032]\n\tOrdinal0 [0x00ECA72F+108335]\n\tOrdinal0 [0x00EC4A01+84481]\n\tOrdinal0 [0x00EDEC90+191632]\n\tOrdinal0 [0x00EC4986+84358]\n\tOrdinal0 [0x00EDED31+191793]\n\tOrdinal0 [0x00EE8773+231283]\n\tOrdinal0 [0x00EDEB0B+191243]\n\tOrdinal0 [0x00EC2E77+77431]\n\tOrdinal0 [0x00EC3E3E+81470]\n\tOrdinal0 [0x00EC3DC9+81353]\n\tOrdinal0 [0x010B0C99+2100377]\n\tGetHandleVerifier [0x0131B71A+1396954]\n\tGetHandleVerifier [0x0131B399+1396057]\n\tGetHandleVerifier [0x013270E6+1444518]\n\tGetHandleVerifier [0x0131BCA8+1398376]\n\tOrdinal0 [0x010A7F11+2064145]\n\tOrdinal0 [0x010B22AB+2106027]\n\tOrdinal0 [0x010B23D1+2106321]\n\tOrdinal0 [0x010C4984+2181508]\n\tBaseThreadInitThunk [0x764062C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77940779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77940744+1028]\n"}}
_WD_FindElement ==> No match: HTTP status = 404
__WD_Post: URL=HTTP://127.0.0.1:9515/session/fdda6c6cd3f0ab5ceb74a3b1933101f4/element//click; $sData={"id":""}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Ses...
__WD_Post ==> No match: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x011AD343+3134275]\n\tOrdinal0 [0x0109A131+2007345]\n\tOrdinal0 [0x00F3AEC8+569032]\n\tOrdinal0 [0x00ECA0C4+106692]\n\tOrdinal0 [0x00ECB553+111955]\n\tOrdinal0 [0x00EC4A7C+84604]\n\tOrdinal0 [0x00EDEC5D+191581]\n\tOrdinal0 [0x00EC4986+84358]\n\tOrdinal0 [0x00EDED31+191793]\n\tOrdinal0 [0x00EE8773+231283]\n\tOrdinal0 [0x00EDEB0B+191243]\n\tOrdinal0 [0x00EC2E77+77431]\n\tOrdinal0 [0x00EC3E3E+81470]\n\tOrdinal0 [0x00EC3DC9+81353]\n\tOrdinal0 [0x010B0C99+2100377]\n\tGetHandleVerifier [0x0131B71A+1396954]\n\tGetHandleVerifier [0x0131B399+1396057]\n\tGetHandleVerifier [0x013270E6+1444518]\n\tGetHandleVerifier [0x0131BCA8+1398376]\n\tOrdinal0 [0x010A7F11+2064145]\n\tOrdinal0 [0x010B22AB+2106027]\n\tOrdinal0 [0x010B23D1+2106321]\n\tOrdinal0 [0x010C4984+2181508]\n\tBaseThreadInitThunk [0x764062C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77940779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77940744+1028]\n"}}
_WD_ElementAction: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Ses...
_WD_ElementAction ==> No match: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x011AD343+3134275]\n\tOrdinal0 [0x0109A131+2007345]\n\tOrdinal0 [0x00F3AEC8+569032]\n\tOrdinal0 [0x00ECA0C4+106692]\n\tOrdinal0 [0x00ECB553+111955]\n\tOrdinal0 [0x00EC4A7C+84604]\n\tOrdinal0 [0x00EDEC5D+191581]\n\tOrdinal0 [0x00EC4986+84358]\n\tOrdinal0 [0x00EDED31+191793]\n\tOrdinal0 [0x00EE8773+231283]\n\tOrdinal0 [0x00EDEB0B+191243]\n\tOrdinal0 [0x00EC2E77+77431]\n\tOrdinal0 [0x00EC3E3E+81470]\n\tOrdinal0 [0x00EC3DC9+81353]\n\tOrdinal0 [0x010B0C99+2100377]\n\tGetHandleVerifier [0x0131B71A+1396954]\n\tGetHandleVerifier [0x0131B399+1396057]\n\tGetHandleVerifier [0x013270E6+1444518]\n\tGetHandleVerifier [0x0131BCA8+1398376]\n\tOrdinal0 [0x010A7F11+2064145]\n\tOrdinal0 [0x010B22AB+2106027]\n\tOrdinal0 [0x010B23D1+2106321]\n\tOrdinal0 [0x010C4984+2181508]\n\tBaseThreadInitThunk [0x764062C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77940779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77940744+1028]\n"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/fdda6c6cd3f0ab5ceb74a3b1933101f4/element; $sData={"using":"tag name","value":"mds-select-option"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\...
__WD_Post ==> No match: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"tag name\",\"selector\":\"mds-select-option\"}\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x011AD343+3134275]\n\tOrdinal0 [0x0109A131+2007345]\n\tOrdinal0 [0x00F3AEC8+569032]\n\tOrdinal0 [0x00ECA72F+108335]\n\tOrdinal0 [0x00EE9DB0+236976]\n\tOrdinal0 [0x00EDEC90+191632]\n\tOrdinal0 [0x00EE8773+231283]\n\tOrdinal0 [0x00EDEB0B+191243]\n\tOrdinal0 [0x00EC2E77+77431]\n\tOrdinal0 [0x00EC3E3E+81470]\n\tOrdinal0 [0x00EC3DC9+81353]\n\tOrdinal0 [0x010B0C99+2100377]\n\tGetHandleVerifier [0x0131B71A+1396954]\n\tGetHandleVerifier [0x0131B399+1396057]\n\tGetHandleVerifier [0x013270E6+1444518]\n\tGetHandleVerifier [0x0131BCA8+1398376]\n\tOrdinal0 [0x010A7F11+2064145]\n\tOrdinal0 [0x010B22AB+2106027]\n\tOrdinal0 [0x010B23D1+2106321]\n\tOrdinal0 [0x010C4984+2181508]\n\tBaseThreadInitThunk [0x764062C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77940779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77940744+1028]\n"}}
_WD_FindElement: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"tag name\",\"selector\":\"mds-select-option\"}\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x011AD343+3134275]\n\tOrdinal0 [0x0109A131+2007345]\n\tOrdinal0 [0x00F3AEC8+569032]\n\tOrdinal0 [0x00ECA72F+108335]\n\tOrdinal0 [0x00EE9DB0+236976]\n\tOrdinal0 [0x00EDEC90+191632]\n\tOrdinal0 [0x00EE8773+231283]\n\tOrdinal0 [0x00EDEB0B+191243]\n\tOrdinal0 [0x00EC2E77+77431]\n\tOrdinal0 [0x00EC3E3E+81470]\n\tOrdinal0 [0x00EC3DC9+81353]\n\tOrdinal0 [0x010B0C99+2100377]\n\tGetHandleVerifier [0x0131B71A+1396954]\n\tGetHandleVerifier [0x0131B399+1396057]\n\tGetHandleVerifier [0x013270E6+1444518]\n\tGetHandleVerifier [0x0131BCA8+1398376]\n\tOrdinal0 [0x010A7F11+2064145]\n\tOrdinal0 [0x010B22AB+2106027]\n\tOrdinal0 [0x010B23D1+2106321]\n\tOrdinal0 [0x010C4984+2181508]\n\tBaseThreadInitThunk [0x764062C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77940779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77940744+1028]\n"}}
_WD_FindElement ==> No match: HTTP status = 404
_WD_GetShadowRoot: 
_WD_GetShadowRoot ==> No match
__WD_Post: URL=HTTP://127.0.0.1:9515/session/fdda6c6cd3f0ab5ceb74a3b1933101f4/element; $sData={"using":"css selector","value":".option__label-primary"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\...
__WD_Post ==> No match: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"css selector\",\"selector\":\".option__label-primary\"}\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x011AD343+3134275]\n\tOrdinal0 [0x0109A131+2007345]\n\tOrdinal0 [0x00F3AEC8+569032]\n\tOrdinal0 [0x00ECA72F+108335]\n\tOrdinal0 [0x00EE9DB0+236976]\n\tOrdinal0 [0x00EDEC90+191632]\n\tOrdinal0 [0x00EE8773+231283]\n\tOrdinal0 [0x00EDEB0B+191243]\n\tOrdinal0 [0x00EC2E77+77431]\n\tOrdinal0 [0x00EC3E3E+81470]\n\tOrdinal0 [0x00EC3DC9+81353]\n\tOrdinal0 [0x010B0C99+2100377]\n\tGetHandleVerifier [0x0131B71A+1396954]\n\tGetHandleVerifier [0x0131B399+1396057]\n\tGetHandleVerifier [0x013270E6+1444518]\n\tGetHandleVerifier [0x0131BCA8+1398376]\n\tOrdinal0 [0x010A7F11+2064145]\n\tOrdinal0 [0x010B22AB+2106027]\n\tOrdinal0 [0x010B23D1+2106321]\n\tOrdinal0 [0x010C4984+2181508]\n\tBaseThreadInitThunk [0x764062C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77940779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77940744+1028]\n"}}
_WD_FindElement: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"css selector\",\"selector\":\".option__label-primary\"}\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x011AD343+3134275]\n\tOrdinal0 [0x0109A131+2007345]\n\tOrdinal0 [0x00F3AEC8+569032]\n\tOrdinal0 [0x00ECA72F+108335]\n\tOrdinal0 [0x00EE9DB0+236976]\n\tOrdinal0 [0x00EDEC90+191632]\n\tOrdinal0 [0x00EE8773+231283]\n\tOrdinal0 [0x00EDEB0B+191243]\n\tOrdinal0 [0x00EC2E77+77431]\n\tOrdinal0 [0x00EC3E3E+81470]\n\tOrdinal0 [0x00EC3DC9+81353]\n\tOrdinal0 [0x010B0C99+2100377]\n\tGetHandleVerifier [0x0131B71A+1396954]\n\tGetHandleVerifier [0x0131B399+1396057]\n\tGetHandleVerifier [0x013270E6+1444518]\n\tGetHandleVerifier [0x0131BCA8+1398376]\n\tOrdinal0 [0x010A7F11+2064145]\n\tOrdinal0 [0x010B22AB+2106027]\n\tOrdinal0 [0x010B23D1+2106321]\n\tOrdinal0 [0x010C4984+2181508]\n\tBaseThreadInitThunk [0x764062C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77940779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77940744+1028]\n"}}
_WD_FindElement ==> No match: HTTP status = 404

 

Link to post
Share on other sites

I get this error log when i try adding , $oSettingsMainSR, Default, True

__WD_Post: URL=HTTP://127.0.0.1:9515/session/0ca6d739924f86eae722f370cec2733e/element/True/element; $sData={"using":"tag name","value":"mds-select"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"stale element reference","message":"stale element reference: element is not attac...
__WD_Post ==> No match: {"value":{"error":"stale element reference","message":"stale element reference: element is not attached to the page document\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00E8D343+3134275]\n\tOrdinal0 [0x00D7A131+2007345]\n\tOrdinal0 [0x00C1AEC8+569032]\n\tOrdinal0 [0x00C1D06E+577646]\n\tOrdinal0 [0x00C1CF73+577395]\n\tOrdinal0 [0x00C1D150+577872]\n\tOrdinal0 [0x00BAA525+107813]\n\tOrdinal0 [0x00BA4A01+84481]\n\tOrdinal0 [0x00BBEC90+191632]\n\tOrdinal0 [0x00BA4986+84358]\n\tOrdinal0 [0x00BBED31+191793]\n\tOrdinal0 [0x00BC8773+231283]\n\tOrdinal0 [0x00BBEB0B+191243]\n\tOrdinal0 [0x00BA2E77+77431]\n\tOrdinal0 [0x00BA3E3E+81470]\n\tOrdinal0 [0x00BA3DC9+81353]\n\tOrdinal0 [0x00D90C99+2100377]\n\tGetHandleVerifier [0x00FFB71A+1396954]\n\tGetHandleVerifier [0x00FFB399+1396057]\n\tGetHandleVerifier [0x010070E6+1444518]\n\tGetHandleVerifier [0x00FFBCA8+1398376]\n\tOrdinal0 [0x00D87F11+2064145]\n\tOrdinal0 [0x00D922AB+2106027]\n\tOrdinal0 [0x00D923D1+2106321]\n\tOrdinal0 [0x00DA4984+2181508]\n\tBaseThreadInitThunk [0x759262C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77760779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77760744+1028]\n"}}
_WD_FindElement: {"value":{"error":"stale element reference","message":"stale element reference: element is not attached to the page document\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00E8D343+3134275]\n\tOrdinal0 [0x00D7A131+2007345]\n\tOrdinal0 [0x00C1AEC8+569032]\n\tOrdinal0 [0x00C1D06E+577646]\n\tOrdinal0 [0x00C1CF73+577395]\n\tOrdinal0 [0x00C1D150+577872]\n\tOrdinal0 [0x00BAA525+107813]\n\tOrdinal0 [0x00BA4A01+84481]\n\tOrdinal0 [0x00BBEC90+191632]\n\tOrdinal0 [0x00BA4986+84358]\n\tOrdinal0 [0x00BBED31+191793]\n\tOrdinal0 [0x00BC8773+231283]\n\tOrdinal0 [0x00BBEB0B+191243]\n\tOrdinal0 [0x00BA2E77+77431]\n\tOrdinal0 [0x00BA3E3E+81470]\n\tOrdinal0 [0x00BA3DC9+81353]\n\tOrdinal0 [0x00D90C99+2100377]\n\tGetHandleVerifier [0x00FFB71A+1396954]\n\tGetHandleVerifier [0x00FFB399+1396057]\n\tGetHandleVerifier [0x010070E6+1444518]\n\tGetHandleVerifier [0x00FFBCA8+1398376]\n\tOrdinal0 [0x00D87F11+2064145]\n\tOrdinal0 [0x00D922AB+2106027]\n\tOrdinal0 [0x00D923D1+2106321]\n\tOrdinal0 [0x00DA4984+2181508]\n\tBaseThreadInitThunk [0x759262C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77760779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77760744+1028]\n"}}
_WD_FindElement ==> No match: HTTP status = 404
_WD_GetShadowRoot: 
_WD_GetShadowRoot ==> No match
__WD_Post: URL=HTTP://127.0.0.1:9515/session/0ca6d739924f86eae722f370cec2733e/element; $sData={"using":"css selector","value":".mds-select__select mds-select__select--box mds-select__select--placeholder"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\...
__WD_Post ==> No match: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"css selector\",\"selector\":\".mds-select__select mds-select__select--box mds-select__select--placeholder\"}\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00E8D343+3134275]\n\tOrdinal0 [0x00D7A131+2007345]\n\tOrdinal0 [0x00C1AEC8+569032]\n\tOrdinal0 [0x00BAA72F+108335]\n\tOrdinal0 [0x00BC9DB0+236976]\n\tOrdinal0 [0x00BBEC90+191632]\n\tOrdinal0 [0x00BC8773+231283]\n\tOrdinal0 [0x00BBEB0B+191243]\n\tOrdinal0 [0x00BA2E77+77431]\n\tOrdinal0 [0x00BA3E3E+81470]\n\tOrdinal0 [0x00BA3DC9+81353]\n\tOrdinal0 [0x00D90C99+2100377]\n\tGetHandleVerifier [0x00FFB71A+1396954]\n\tGetHandleVerifier [0x00FFB399+1396057]\n\tGetHandleVerifier [0x010070E6+1444518]\n\tGetHandleVerifier [0x00FFBCA8+1398376]\n\tOrdinal0 [0x00D87F11+2064145]\n\tOrdinal0 [0x00D922AB+2106027]\n\tOrdinal0 [0x00D923D1+2106321]\n\tOrdinal0 [0x00DA4984+2181508]\n\tBaseThreadInitThunk [0x759262C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77760779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77760744+1028]\n"}}
_WD_FindElement: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"css selector\",\"selector\":\".mds-select__select mds-select__select--box mds-select__select--placeholder\"}\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00E8D343+3134275]\n\tOrdinal0 [0x00D7A131+2007345]\n\tOrdinal0 [0x00C1AEC8+569032]\n\tOrdinal0 [0x00BAA72F+108335]\n\tOrdinal0 [0x00BC9DB0+236976]\n\tOrdinal0 [0x00BBEC90+191632]\n\tOrdinal0 [0x00BC8773+231283]\n\tOrdinal0 [0x00BBEB0B+191243]\n\tOrdinal0 [0x00BA2E77+77431]\n\tOrdinal0 [0x00BA3E3E+81470]\n\tOrdinal0 [0x00BA3DC9+81353]\n\tOrdinal0 [0x00D90C99+2100377]\n\tGetHandleVerifier [0x00FFB71A+1396954]\n\tGetHandleVerifier [0x00FFB399+1396057]\n\tGetHandleVerifier [0x010070E6+1444518]\n\tGetHandleVerifier [0x00FFBCA8+1398376]\n\tOrdinal0 [0x00D87F11+2064145]\n\tOrdinal0 [0x00D922AB+2106027]\n\tOrdinal0 [0x00D923D1+2106321]\n\tOrdinal0 [0x00DA4984+2181508]\n\tBaseThreadInitThunk [0x759262C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77760779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77760744+1028]\n"}}
_WD_FindElement ==> No match: HTTP status = 404
__WD_Post: URL=HTTP://127.0.0.1:9515/session/0ca6d739924f86eae722f370cec2733e/element//click; $sData={"id":""}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Ses...
__WD_Post ==> No match: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00E8D343+3134275]\n\tOrdinal0 [0x00D7A131+2007345]\n\tOrdinal0 [0x00C1AEC8+569032]\n\tOrdinal0 [0x00BAA0C4+106692]\n\tOrdinal0 [0x00BAB553+111955]\n\tOrdinal0 [0x00BA4A7C+84604]\n\tOrdinal0 [0x00BBEC5D+191581]\n\tOrdinal0 [0x00BA4986+84358]\n\tOrdinal0 [0x00BBED31+191793]\n\tOrdinal0 [0x00BC8773+231283]\n\tOrdinal0 [0x00BBEB0B+191243]\n\tOrdinal0 [0x00BA2E77+77431]\n\tOrdinal0 [0x00BA3E3E+81470]\n\tOrdinal0 [0x00BA3DC9+81353]\n\tOrdinal0 [0x00D90C99+2100377]\n\tGetHandleVerifier [0x00FFB71A+1396954]\n\tGetHandleVerifier [0x00FFB399+1396057]\n\tGetHandleVerifier [0x010070E6+1444518]\n\tGetHandleVerifier [0x00FFBCA8+1398376]\n\tOrdinal0 [0x00D87F11+2064145]\n\tOrdinal0 [0x00D922AB+2106027]\n\tOrdinal0 [0x00D923D1+2106321]\n\tOrdinal0 [0x00DA4984+2181508]\n\tBaseThreadInitThunk [0x759262C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77760779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77760744+1028]\n"}}
_WD_ElementAction: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Ses...
_WD_ElementAction ==> No match: {"value":{"error":"no such element","message":"no such element: Element_id length is invalid\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00E8D343+3134275]\n\tOrdinal0 [0x00D7A131+2007345]\n\tOrdinal0 [0x00C1AEC8+569032]\n\tOrdinal0 [0x00BAA0C4+106692]\n\tOrdinal0 [0x00BAB553+111955]\n\tOrdinal0 [0x00BA4A7C+84604]\n\tOrdinal0 [0x00BBEC5D+191581]\n\tOrdinal0 [0x00BA4986+84358]\n\tOrdinal0 [0x00BBED31+191793]\n\tOrdinal0 [0x00BC8773+231283]\n\tOrdinal0 [0x00BBEB0B+191243]\n\tOrdinal0 [0x00BA2E77+77431]\n\tOrdinal0 [0x00BA3E3E+81470]\n\tOrdinal0 [0x00BA3DC9+81353]\n\tOrdinal0 [0x00D90C99+2100377]\n\tGetHandleVerifier [0x00FFB71A+1396954]\n\tGetHandleVerifier [0x00FFB399+1396057]\n\tGetHandleVerifier [0x010070E6+1444518]\n\tGetHandleVerifier [0x00FFBCA8+1398376]\n\tOrdinal0 [0x00D87F11+2064145]\n\tOrdinal0 [0x00D922AB+2106027]\n\tOrdinal0 [0x00D923D1+2106321]\n\tOrdinal0 [0x00DA4984+2181508]\n\tBaseThreadInitThunk [0x759262C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77760779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77760744+1028]\n"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/0ca6d739924f86eae722f370cec2733e/element; $sData={"using":"tag name","value":"mds-select-option"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\...
__WD_Post ==> No match: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"tag name\",\"selector\":\"mds-select-option\"}\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00E8D343+3134275]\n\tOrdinal0 [0x00D7A131+2007345]\n\tOrdinal0 [0x00C1AEC8+569032]\n\tOrdinal0 [0x00BAA72F+108335]\n\tOrdinal0 [0x00BC9DB0+236976]\n\tOrdinal0 [0x00BBEC90+191632]\n\tOrdinal0 [0x00BC8773+231283]\n\tOrdinal0 [0x00BBEB0B+191243]\n\tOrdinal0 [0x00BA2E77+77431]\n\tOrdinal0 [0x00BA3E3E+81470]\n\tOrdinal0 [0x00BA3DC9+81353]\n\tOrdinal0 [0x00D90C99+2100377]\n\tGetHandleVerifier [0x00FFB71A+1396954]\n\tGetHandleVerifier [0x00FFB399+1396057]\n\tGetHandleVerifier [0x010070E6+1444518]\n\tGetHandleVerifier [0x00FFBCA8+1398376]\n\tOrdinal0 [0x00D87F11+2064145]\n\tOrdinal0 [0x00D922AB+2106027]\n\tOrdinal0 [0x00D923D1+2106321]\n\tOrdinal0 [0x00DA4984+2181508]\n\tBaseThreadInitThunk [0x759262C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77760779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77760744+1028]\n"}}
_WD_FindElement: {"value":{"error":"no such element","message":"no such element: Unable to locate element: {\"method\":\"tag name\",\"selector\":\"mds-select-option\"}\n  (Session info: chrome=85.0.4183.83)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00E8D343+3134275]\n\tOrdinal0 [0x00D7A131+2007345]\n\tOrdinal0 [0x00C1AEC8+569032]\n\tOrdinal0 [0x00BAA72F+108335]\n\tOrdinal0 [0x00BC9DB0+236976]\n\tOrdinal0 [0x00BBEC90+191632]\n\tOrdinal0 [0x00BC8773+231283]\n\tOrdinal0 [0x00BBEB0B+191243]\n\tOrdinal0 [0x00BA2E77+77431]\n\tOrdinal0 [0x00BA3E3E+81470]\n\tOrdinal0 [0x00BA3DC9+81353]\n\tOrdinal0 [0x00D90C99+2100377]\n\tGetHandleVerifier [0x00FFB71A+1396954]\n\tGetHandleVerifier [0x00FFB399+1396057]\n\tGetHandleVerifier [0x010070E6+1444518]\n\tGetHandleVerifier [0x00FFBCA8+1398376]\n\tOrdinal0 [0x00D87F11+2064145]\n\tOrdinal0 [0x00D922AB+2106027]\n\tOrdinal0 [0x00D923D1+2106321]\n\tOrdinal0 [0x00DA4984+2181508]\n\tBaseThreadInitThunk [0x759262C4+36]\n\tRtlSubscribeWnfStateChangeNotification [0x77760779+1081]\n\tRtlSubscribeWnfStateChangeNotification [0x77760744+1028]\n"}}
_WD_FindElement ==> No match: HTTP status = 404
_WD_GetShadowRoot: 
_WD_GetShadowRoot ==> No match
(116) : ==> Incorrect number of parameters in function call.:
Local $oSettingsAboutPageSR = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".option__label-primary", $oSettingsMainSR, Default, True)
Local $oSettingsAboutPageSR = ^ ERROR
>Exit code: 1    Time: 46.21

 

Link to post
Share on other sites
5 hours ago, Hermes said:

__WD_Post: URL=HTTP://127.0.0.1:9515/session/0ca6d739924f86eae722f370cec2733e/element/True/element; $sData={"using":"tag name","value":"mds-select"}

That request is clearly wrong. Can you show the line of code that generated that error? It looks like it's from your _WD_GetShadowRoot call, not the _WD_FindElement we were dealing with above. Did you change the wrong line?

Link to post
Share on other sites

Here is the updated script when adding:

Local $oSettingsAboutPageSR = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".option__label-primary", $oSettingsMainSR, Default, True)
#Include "Chrome.au3"

#Include "wd_core.au3"

#Include "wd_helper.au3"

#Include "Excel.au3"

 

 

Local $sDesiredCapabilities, $sSession

SetupChrome()

 

_WD_Startup()

 

 

$sSession = _WD_CreateSession($sDesiredCapabilities)

 

_WD_LoadWait($sSession)

 

_WD_Navigate($sSession, "input.html")

 

;;;First Shadow root

Local $oExcel = _Excel_Open()

Local $oWorkbook = _Excel_BookOpen($oExcel, "input.xlsx")

Local $aArray4Test = _Excel_RangeRead($oWorkbook,1,$oWorkbook.ActiveSheet.Usedrange.Columns("A:A"))

Local $oSettingsUISR = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByTagName, "mds-select", True)

Local $oTemp = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".mds-select__select mds-select__select--box mds-select__select--placeholder", $oSettingsUISR)
_WD_ElementAction($sSession, $oTemp, 'click')
Local $oSettingsMainSR = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByTagName, "mds-select-option", $oTemp)
Local $oSettingsAboutPageSR = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".option__label-primary", $oSettingsMainSR, Default, True)
Local $selectTest = _WD_ElementOptionSelect($sSession, $oSettingsAboutPageSR, $aArray4Test[$i]) 
 

_WD_Shutdown()

 

Func SetupChrome()

    _WD_Option('Driver', 'chromedriver.exe')

    _WD_Option('Port', 9515)

    _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')

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

EndFunc   ;==>SetupChrome

and here is the error that I was talking about. It occurs on the variable:
 

Local $oSettingsAboutPageSR = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".option__label-primary", $oSettingsMainSR, Default, True)

"test.au3" (116) : ==> Incorrect number of parameters in function call.:
Local $oSettingsAboutPageSR = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".option__label-primary", $oSettingsMainSR, Default, True)
Local $oSettingsAboutPageSR = ^ ERROR

 

Link to post
Share on other sites

Since ShadowRoot support was just added to the W3C specs, it will take some time for the browsers to implement this functionality. I have an issue opened on Github where you can monitor the situation.

On 3/2/2021 at 9:22 AM, Hermes said:

I have also attempted to do this, but it didnt work:

$test3 = 'return document.querySelector("mds-select").shadowRoot.querySelector(".mds-select__container").querySelector(".mds-select__select-wrap").shadowRoot.querySelector(".mds-select__menu").shadowRoot.querySelector(".mds-select__menu-list").shadowRoot.querySelector(".mds-select-option[0]");'
$test4 = _WD_ElementAction($sSession, $test3, 'click')

You may need to revert to this methodology in the mean time. However, your logic seems to be flawed in that you are assigning a string to $test3 but you would need to pass this string to _WD_ExecuteScript in order to retrieve the desired element.

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...