That should be drastically shortened. That is likely to fail if you are testing in different browsers and if anything ever changes on the page it could throw a false positive due to it looking at the wrong . I recommend looking up “Relative XPaths” and also “ Axes”, but I could demonstrate a better for you if you posted a screenshot of the HTML and the web page.

Based on what you posted, you could do something like:
//table[@id ='something' or @class='Something that identifies this specific table']//tr[contains(text(), 'something to identify the row') or ./text() = 'Exact Text Match']//strong[2]

Usually with table rows I end up identifying the row based on the text from a cell within the row.
//table[@id ='something' or @class='Something that identifies this specific table']//tr[.//td[contains(text(), 'something to identify the row') or ./text() = 'Exact Text Match']]//td//strong[2][contains(text(), 'Partial Text Match') or ./text() = 'Exact Text Match']

Source link https://sqa.stackexchange.com/questions/10342/how-to--element-using-contains-in-xpath


Please enter your comment!
Please enter your name here