How to make dynamic xpath calls
See original GitHub issueHi,
I’m using the following xpath expression to retrieve some node values from an XML.
* def sbsKey = get response /Envelope//resortID[text()='0450']/following-sibling::accomodationProducts[1]//*[local-name()='unit'][1]//sbsKey
* print "The season code is "+sbsKey
My question is - How do I make the the following section of the xpath dynamic
[//resortID[text()='0450']]
I was hoping something like this would solve the purpose, but it doesn’t -
* def fetchedResortID = get response /Envelope//resortID[1]
* print fetchedResortID
* def sbsKey = get response "/Envelope//resortID[text()='"+fetchedResortID+"']/following-sibling::accomodationProducts[1]//*[local-name()='unit'][1]//sbsKey"
* print "The season code is "+sbsKey
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
XPath Functions For Dynamic XPath In Selenium
This Tutorial Explains the Usage of XPath Functions in Identifying the Elements With Examples: Before automating any website is necessary to ...
Read more >How to write Dynamic XPath in Selenium - Learn Automation
Yes, you can use array for that. Take all locators wrt browse button inside an array and call its click action based on...
Read more >Dynamic XPath In Selenium WebDriver A Complete Guide
Dynamic XPath is used to locate exact attribute or decrease the number of matching nodes/result from a webpage and following XPath expressions ...
Read more >Dynamic XPath in Selenium using Different Approaches
Do you know how to write Dynamic xpath in Selenium Webdriver? In this video, we will mainly discuss XPath different methods which will...
Read more >How To Write Dynamic XPath In Selenium WebDriver
In this XPath in Selenium Tutorial, we will learn the different ways of writing Dynamic XPath in Selenium WebDriver.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks Peter. I did figure out this issue. I converted the response object to xml through type conversion and then applied the xpath expression.
Works fine now
Regards, Prashanth Email: Prashanth.Mijar@gmail.com
actually this is a gap. where we have a way to do this for jsonPath so I’m treating this as a feature request. I think you can use this work-around for now (works only for string values, not XML chunks).