Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to click on the text button using selenium python

Hi I'm trying to click on select button using xpath and css selector but it doesn't works

browser.find_elements_by_xpath('//div[@class="section-select-all"]').click()
browser.find_elements_by_css_selector('#results-container > form > ul > li:nth-child(1) > div > div > button').click()
browser.find_elements_by_xpath('//*[@id="results-container"]/form/ul/li[1]/div/div/button').click()

please let me know how it would be here is the code

<div class="section-actions"><button type="button" class="section-select-all">Select 50<span class="screen-reader-text"> for section Dec 11, 2015</span></button></div>
like image 865
Bostan Avatar asked Dec 30 '15 10:12

Bostan


People also ask

How do I enter text and click enter in Selenium?

We can type Enter/Return key in Selenium. We shall use the sendKeys method and pass Keys. ENTER as an argument to the method. Also, we can use pass Keys.

How do you click on an item in Selenium?

For automating the right-click operation, Selenium provides a dedicated method – contextClick(). This method accepts the target WebElement as the argument. In order to use this method, use the Actions class object. The method of locating the desired element remains the same.


1 Answers

You're using elements that will not work. Use element instead. I am sure it will work.

like image 75
Sarfraz Avatar answered Nov 15 '22 00:11

Sarfraz