Forum Discussion

pbaus's avatar
Occasional Visitor
3 months ago

Dynamic Values in XPATH


I am getting dynamic values in my XPATH (every time when I execute the highlighted number changes). 


If anybody know how to make these numbers as generic at the name mapping level.



2 Replies

  • eykxas's avatar
    Regular Contributor

    Hi ! Usually, these id are generated by the web browser at the loading of the webpage. You can't make these id generic without modifying the app/website itself.

    Instead, you could use the contains method of xpath. > //div[@role='main']/form[contains(@id, 'form_')]/div/div/div/div/button[@name='SystemDefinedSaveButton']

    If you have multiple forms in your webpage, try to find a unique value inside the form you are looking then build your xpath from this point.

    Example : //div[contains(@title, 'My Form Title')]//ancestor::form/div/div/div/div/button[@name='SystemDefinedSaveButton']

  • rraghvani's avatar
    Champion Level 3

    Also see,