How to click the search button using Selenium web driver and Python

0 votes

I am trying to click the button but it is not working

<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>
Jul 19, 2018 in Selenium by Martin
• 4,220 points
2,955 views

3 answers to this question.

0 votes

Below will help
Use xpath :- //button[@value='1' and @label='Search']

searchbutton = driver.find_element_by_xpath(//button[@value='1' and @label='Search'])
answered Jul 19, 2018 by Samarpit
• 5,130 points
This solution is not working.It still gives an error.
Can you please provide the error that you are facing?
0 votes

Try this will work:

JavascriptExecutor js = (JavascriptExecutor) driver;//create instance of javascript executor to do actions
WebElement buttonSubmit= driver.findElement(By.xpath("//button[@class='_42ft _4jy0 _4w98 _4jy3 _517h _51sy _4w97']"));
js.executeScript("arguments[0].click();", buttonSubmit);
answered Feb 20 by nizam
0 votes

You can try with tag.

#this code will get the list of tags and select the second tag from the list
element = driver.find_elements_by_tag_name('button')[1] 
#this will click the element
element.click()

Ref: https://stackoverflow.com/questions/49063338/trying-to-click-on-the-button-tag-in-selenium-web-driver-using-python

answered Apr 10 by Matin

Related Questions In Selenium

0 votes
2 answers

Python & Selenium: How to find and click on YouTube's Like button

Hello Nitin, as the Like button on ...READ MORE

answered Aug 23 in Selenium by Abha
• 22,870 points
585 views
+1 vote
1 answer
0 votes
1 answer

Installing Selenium Webdriver with Python package

Hey Hemant, for installing Selenium Webdriver with ...READ MORE

answered May 8 in Selenium by Anvi
• 12,840 points
140 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
555 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
890 views
+1 vote
1 answer
0 votes
1 answer

How to click a span with given text using Selenium Python

If ALL_USA is subject to change, then ...READ MORE

answered Jul 26, 2018 in Selenium by Samarpit
• 5,130 points
1,777 views