Consider this xpath which should always return one element.
//div[@id='MyDiv123']/div[contains(@class, 'super')]
Assume that we won't add anymore divs whose class is super. Given that info, I don't think that it is a good idea to use /div[contains(@class, 'super')]
because the xpath will break if div[contains(@class, 'super')]
is placed inside another element.
Shouldn't we be using //div[contains(@class, 'super')]
instead ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…