How do I create a Xpath of any element in web page when it is changes each page load or refresh using selenium
Asked
Active
Viewed 1,385 times
-2
-
show examples of how it's changes – Ori Marko Jan 10 '18 at 10:15
-
suppose if there is submit button ,it is changing its ID,name, css and Xpath also how do we find that – Yogeshk Jan 10 '18 at 10:31
-
There is only 1 submit? What do it have special? Can you show sample – Ori Marko Jan 10 '18 at 10:34
-
suppose there is a table of students end each time its adding new student lets say first time it displays 5 student information second time it displays 8 students (name ,branch, roll no) when user clicks on student no 6 it displays the information of that student. But my question it is changing everytime the element ID,Name an all thing how do we find that ?? dear @user7294900 user answer is correct only when the table is static but in my case the table is dynamically changing – Yogeshk Jan 11 '18 at 07:09
2 Answers
0
If there is 1 submit button, you can find element by checking input type submit
//input[@type='submit']
If there are more and you know it place in page for example 2. Search by child number as:
( //input[@type='submit']) [2]

Ori Marko
- 56,308
- 23
- 131
- 233
0
You can try this method it works fine. Here is my xpath,
//*[@id="CaseTypes_39aa6635-cd44-4104-a9f7-e33c3f96e2ab__Amount"]
Here is my code:
[FindsBy(How = How.XPath, Using = "//*[starts-with(@id, 'CaseTypes_') and substring(@id, string-length(@id) - string-length('__Amount') +1) = '__Amount']")]
I hope it helps!!

Mutu Arron
- 71
- 1
- 9