Hermes Posted March 12, 2021 Posted March 12, 2021 I'm trying to select a specific option in a dropdown box based on the value of a cell from an excel sheet. I can make it work when using the script below: Local $oTest = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, ".page") Local $oTest2 = _WD_GetShadowRoot($sSession, $_WD_LOCATOR_ByCSSSelector, "#main", $oTest) Local $oTest4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "mds-select-option[value='Monkey']", $oTest2) _WD_ElementAction($sSession, $oTest4, 'click') Notice that i have put value = 'Monkey', but there are several values from the sheet. So far, here are my attempts that didnt work. ;Local $oTest4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "mds-select-option[value='']", $oTest2) ;_WD_ElementAction($sSession, $oTest4, 'value', $aArray4[$i]) ;Local $oTest4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "mds-select-option", $oTest2) ;_WD_ElementAction($sSession, $oTest4, 'value', $aArray4[$i]) ;Local $oTest4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "mds-select-option", $oTest2) ;_WD_ElementAction($sSession, $oTest4, 'click' = $aArray4[$i]) ;Local $oTest4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "mds-select-option[value='$aArray4[$i]']", $oTest2) ;_WD_ElementAction($sSession, $oTest4, 'click') ;Local $oTest4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "mds-select-option[value=$aArray4[$i]]", $oTest2) <--- I really thought this one would work but did not. ;_WD_ElementAction($sSession, $oTest4, 'click')
Danp2 Posted March 12, 2021 Posted March 12, 2021 2 hours ago, Hermes said: Local $oTest4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "mds-select-option[value='Monkey']", $oTest2) Just change this line so that the locator string is dynamic instead of a constant. Like this -- $oTest4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByCSSSelector, "mds-select-option[value='" & $aArray4[$i] & "']", $oTest2) Latest Webdriver UDF Release Webdriver Wiki FAQs
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