Search code examples
seleniumfindpartial

Find Partial NAME tag Selenium Java


HTML

<button id="SearchCriteria_20">

The problem is the "_20" part of the ID is auto generated each time the page is loaded; how would you be able to fine the partial (static bit) of SearchCriteria%?

Thanks all....


Solution

  • since you have 2 buttons that fit "SearchCriteria"

    using the following xpath-expressions:

    //button[contains(@id, 'SearchCriteria')][1]
    

    for the first button or

    //button[contains(@id, 'SearchCriteria')][2]
    

    for the second button