I am trying to write a locator where the next text descendant is returned. I wont know the text. The following xpath works:
//*[@id='myChart']//label[contains(text(),"Show:")]/following::div[4]
but I dont like the div[4] as this could easily change. The element is the first div type descendant under show that contains text. Any suggestions?
A
Considering the following clauses:
To locate the element a couple of effective approaches are as follows:
Using xpath:
//*[@id='myChart']//label[contains(., "Show")]//div[text()]
Using xpath with descendant
:
//*[@id='myChart']//label[contains(., "Show")]//descendant::div[text()]
Using xpath with following
:
//*[@id='myChart']//label[contains(., "Show")]//following::div[text()]