I tried to find this code
<div class="ads-form-bottom__submit">
<button type="submit" class="ads-form-bottom__publish button button-orange" title="Enviar anúncio"> Enviar anúncio</button>
</div>
using the XPath
//div[class='ads-form-bottom__submit'][2]/button/following-sibling::div[1]
and
//div[@class='ads-form-bottom__submit']/following-sibling::button
but it doesn't work.
There doesn't appear to be a reason to use following-sibling::
.
Try:
//div[contains(@class,'ads-form-bottom__submit')]/button[contains(@class,'ads-form-bottom__publish')]
迁移到$(By.id(“”)可以缓解很多Xpath问题
To locate the button with text as Enviar anúncio you can use either of the following Locator Strategies :
Using CSS_SELECTOR
:
div.ads-form-bottom__submit>button.ads-form-bottom__publish.button.button-orange[title='Enviar anúncio']
Using XPATH
:
//div[@class='ads-form-bottom__submit']/button[@class='ads-form-bottom__publish button button-orange' and @title='Enviar anúncio']
your both xpaths are incorrect. first one is missing '@' and in second 'button' is not sibling, rather its a child.
use this
//button[contains(text(), 'Enviar anúncio')]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.