SkysLastChance Posted May 26, 2021 Share Posted May 26, 2021 (edited) I have multiple xpaths that are always changing, except for the last 2 or 3 chars is there a way I can grab an xpath that changes like this? Or is there a alternative way I can try to grab these? $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="in5wO_4"]') ;;enters dob _WD_ElementAction($sSession, $sElement, 'value', FormatDate($sR4)) @mikell was able to help with a similar issue in IE. However, this method wont work. $var = "_26" ; $sHTML = '<input name="in2xk_92" class="navitem s_147" id="in2xk_26" style="..." etc>' $sHTML = _IEDocReadHTML($oIE) $id = StringRegExpReplace($sHTML, '(?s).*?id="(\w+' & $var & ').*', "$1") ; Msgbox(0,"", $id) $oInput = _IEGetObjById($oIE, $id) ; etc Edited May 27, 2021 by SkysLastChance You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott Link to comment Share on other sites More sharing options...
TheXman Posted May 26, 2021 Share Posted May 26, 2021 (edited) Have you tried using the xpath ends-with() function? Here's a nice xpath cheat sheet with examples: https://devhints.io/xpath Edited May 26, 2021 by TheXman seadoggie01, SkysLastChance and Danp2 2 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
SkysLastChance Posted May 27, 2021 Author Share Posted May 27, 2021 Thank you for this link. I appreciate it. However, I am still not understanding something here. $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[ends-with(@id,"_4")]' ;;enters dob _WD_ElementAction($sSession, $sElement, 'value', FormatDate($sR4)) I keep getting a syntax error. You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott Link to comment Share on other sites More sharing options...
SkysLastChance Posted May 27, 2021 Author Share Posted May 27, 2021 (edited) wow... ")" nvm... It still seems not to be finding the element though. Edited May 27, 2021 by SkysLastChance You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott Link to comment Share on other sites More sharing options...
TheXman Posted May 27, 2021 Share Posted May 27, 2021 Thanks for the link? Is that all you want to thank me for? If so, I guess I'll add you to my ever increasing list of people to ignore. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
SkysLastChance Posted May 27, 2021 Author Share Posted May 27, 2021 Okay, so I figured this out. https://stackoverflow.com/questions/22436789/xpath-ends-with-does-not-work In short browsers use xpath 1.0 and end-with() function is a 2.0 feature. There is an example of a nice work around here though. You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott Link to comment Share on other sites More sharing options...
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