0

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.

0

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')]
0

Migrating to $(By.id("") alleviates a lot of Xpath issues

  • How does By.id help if there are no IDs in the html code? – MivaScott Apr 10 at 22:49
  • it doesnt but it makes troubleshooting easier – Pizazz93 Apr 12 at 16:45
0

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']
    
0

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')]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.