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.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

4 Answers4

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')]
MivaScott
  • 1,763
  • 1
  • 12
  • 30
0

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

Pizazz93
  • 23
  • 5
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']
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
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')]
Rakesh Raut
  • 183
  • 3
  • 12