Selenium XPath error:- Element not found

0 votes

My Selenium Chromedriver script with Python should login to a website and click on a download button which will download a CSV file. On inspecting, details of download button is:

<button id="csv-button" class="block tiny-margin-top" data-args="csv">
      CSV
</button>

and XPath is:

//*[@id="csv-button"]

but it says XPath element not found when I run the script. Please find the code below:

click_button = driver.find_element_by_xpath('//*[@id="csv-button"]')
click_button.click()
Mar 27, 2018 in Selenium by code_ninja
• 5,920 points
1,709 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

The reason for Element not found exception could be because there is a timeout issue. The WbeDriver is getting timedout before your page loads completely.  Try using implicit/ explicit wait statements to overcome this problem.
Add this line of code after the last line in the above code:

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='csv-button']"))).click()

Also remember to import this package:

from selenium.webdriver.support import expected_conditions as EC
answered Mar 27, 2018 by nsv999
• 5,050 points

Related Questions In Selenium

0 votes
1 answer

Getting error saying element not found in selenium

Hey @Jino, The things I figured out ...READ MORE

answered Dec 20, 2018 in Selenium by Shuvodip
102 views
0 votes
1 answer

Xpath element not found

You need to induce WebDriverWait with expected_conditions ...READ MORE

answered Mar 27, 2018 in Selenium by ned_crew
• 1,620 points
121 views
0 votes
1 answer

Selenium-Debugging Error: Element is not clickable at point (X,Y)

Another element is covering the element you ...READ MORE

answered Jul 2, 2018 in Selenium by Samarpit
• 5,130 points
1,515 views
+2 votes
2 answers

How can I press ENTER key with the execute_script in selenium python?

The below code containing Keys.ENTER might just ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,050 points
4,520 views
0 votes
1 answer

Need to download a file using Selenium

Pretty simple...Find the element or link using ...READ MORE

answered Mar 29, 2018 in Selenium by nsv999
• 5,050 points
266 views
0 votes
1 answer

How to use Selenium with Python?

There are many resources for selenium - ...READ MORE

answered Mar 30, 2018 in Selenium by nsv999
• 5,050 points
130 views
0 votes
1 answer

Selenium ChromeDriver issue - Want to run it in background, but not as headless browser

This is a flaw with ChromeDriver. Tried ...READ MORE

answered Mar 26, 2018 in Selenium by nsv999
• 5,050 points
681 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.