RE: xpath regular expression
Hi ..when i use fire path I get the xpath first time as -“//*[@id=’preMatrix’]/div/div/span” and if i refresh page the xpath changes to -“//*[@id=’preMatrix’]/div/div/span”..how do I genaralise this using regular expression .Pls help
The best way to answer this would be to see the html of the element. Ideally there are many ways to find the element.
– The problem here seems that you have new element which is introduced dynamically in the DOM and above your target element. I would prefer to find the amount of time it takes for the new element to come, wait for that much amount of time and then find this element with second Xpath you have mentioned.
– Second way is that this element will have a fixed position from the bottom of the array of similar elements. //*[@id=’preMatrix’] will have lots of Divs find the last div and see if you element changes position based on the last element. If it does not you are looking at an xpath like this
“//*[@id=’preMatrix’]/div[last()- x]/div/span”. where x is the position of the target element from the last element of same type.