DumbDude Posted November 4, 2021 Posted November 4, 2021 Sorry if that has been answered already but I am trying to get the value from this ul <ul id="infolist"> <li> <label> Number: </label> " 12345" </li> <li> <label> County: </label> " CountyA" </li> <li> <label> City: </label> " City1" </li> What I want is the text from the label name and the text from that label I have tried a few different ways but i am trying this code. _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//ul[@id='infoList']/li::text()[0]") any help would be apperciated
Danp2 Posted November 4, 2021 Posted November 4, 2021 You will need to first get the element's ID using _WD_FindElement. Then you can use _WD_ElementAction to retrieve the desired info. Normally, you would need to retrieve each LI element individually. However, you may be able to adapt the sample code in FAQ #7. Latest Webdriver UDF Release Webdriver Wiki FAQs
DumbDude Posted November 5, 2021 Author Posted November 5, 2021 This is great thanks, it put me on the right track $infoList = _WD_FindElement($sSession,$_WD_LOCATOR_ByXPath,"//ul[@id='infoList']") $infoList_text = _WD_ElementAction($sSession, $infoList, 'property', 'innerText') $aOptions = StringSplit ($infoList_text," ", $STR_NOCOUNT) _WD_HighlightElement($sSession,$infoList,2) Sleep(250) _ArrayDisplay($aOptions)
DumbDude Posted November 9, 2021 Author Posted November 9, 2021 Anyway to get the text from <li> without the <label>'s
Danp2 Posted November 10, 2021 Posted November 10, 2021 Yes. To do this using Webdriver, you will need to access each LI element and retrieve the desired property / attribute. Alternatively, you may be able to modify your code above to use Regex instead of StringSplit to obtain just the desired text. 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