0

click to see button

I want to make selenium click the above button so i used:

driver=webdriver.Chrome()
generate=driver.find_element_by_link_text("GENERATE EXCEL FILE TO DOWNLOAD")
generate.click()

But selenium wasnt able to find it, so how do i make selenium find that button and click it?

PS: I'm using Python

2 Answers2

1

Maybe you need a little bit 'wait' before performing clicking to this element, something like:

driver=webdriver.Chrome()
driver.wait_for_element_to_appear
generate=driver.find_element_by_link_text("GENERATE EXCEL FILE TO DOWNLOAD")
generate.click()

Please search for it because it's quite simple

0

You should use xpath. This is the best way to do it but you have to find x_path for your element. For example like this:

python_button = driver.find_elements_by_xpath("//input[@name='lang' and @value='Python']")[0]
python_button.click()

Maybe this link could help you: https://pythonspot.com/selenium-click-button/

Moreover you could try do select it by the id:

driver.find_element_by_id("lst-ib")

And also by the visible text could work:

driver.find_element_by_link_text("Python Tutorial")
SebNik
  • 880
  • 3
  • 10
  • 21
  • Yeah, i tried this but the html code is too complicated and hence i cant find the name and value. Hence is there any way? – Divyam Sureka May 05 '20 at 09:49
  • Can you share the Website ? Because you should be able to select the element and then get the xpath in most browsers. – SebNik May 05 '20 at 09:51
  • https://services.gst.gov.in/services/login, this is the link, i want to login and download monthly files from many different accounts, which is a very monotonus task, and hence i was hoping to ease my task using selenium. So is it possible to click the button? – Divyam Sureka May 05 '20 at 09:57
  • Of course it is possible, just right klick on your download button then inspect this elemtn and you can see the full xpath – SebNik May 05 '20 at 09:59
  • When i inspected the button this came :, so how should i proceed? – Divyam Sureka May 05 '20 at 10:24
  • in most browser you can select the the item and then copy it in xpath – SebNik May 06 '20 at 08:38