-1

I am trying to click the button using Python + Selenium:

<button value="1" class="_42ft _4jy0 _4w98 _4jy3 _517h _51sy _4w97" aria-
label="Search" tabindex="-1" data-testid="facebar_search_button" 
type="submit"><i class="_585_"></i></button>

Please let me know how can I use it with WebDriver? I tried XPath, by value but none worked.

Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
Syed
  • 33
  • 6

4 Answers4

0

You can try this xpath :- //button[@value='1' and @label='Search']

searchbutton = driver.find_element_by_xpath(//button[@value='1' and @label='Search'])

Ankur Singh
  • 1,239
  • 1
  • 8
  • 18
0

Have you tried starts-with or contains:

Edit:

driver.find_element_by_xpath("//button[@class='_42ft' or @class='_4jy0']");

Edit1: In case of multiple classes 'contains' works mostly.

driver.find_element_by_xpath("//button[contains(@class,'_42f‌​t') and contains(@class, '_4jy0')]");

Let me know what you get!

Mayur Dhumal
  • 58
  • 1
  • 1
  • 11
0

Have you tried:

driver.find_element_by_xpath("//button[contains(@type, 'submit')]");

The top answer on the following Question explains xpaths in more depth: Xpath changing after the page gest loaded every time

Danny
  • 287
  • 2
  • 15
0

This should work

driver.find_element_by_xpath('//button[@type="submit"]').click()
Shekhar Samanta
  • 875
  • 2
  • 12
  • 25