Xpath element not found

0 votes

I was using Selenium,Python and Chromedriver script which will login to a website and use click on a download button which will download a CSV file.

Check the inspect details of download button below:

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

XPath is:

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

but it shows an error that XPath element not found when I execute the script. Below is the code:

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

1 answer to this question.

0 votes

You need to induce WebDriverWait with expected_conditions clause set to element_to_be_clickable as follows:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# other code    
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='csv-button']"))).click()

You can also use:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# other code    
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='block tiny-margin-top' and @id='csv-button']"))).click()

answered Mar 27, 2018 by ned_crew
• 1,620 points

Related Questions In Selenium

0 votes
1 answer

Selenium XPath error:- Element not found

The reason for Element not found exception ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,090 points
3,100 views
0 votes
1 answer

Not able to find element with Xpath

You are using wrong xpath expression. This ...READ MORE

answered Jul 4, 2018 in Selenium by Samarpit
• 5,130 points
763 views
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
350 views
0 votes
1 answer

findElement(By.xpath()) not working using Selenium WebDriver

element = findElement(By.xpath("//*[@test-id='test-username']"); element = findElement(By.xpath("//input[@test-id='test-username']"); (*) - any ...READ MORE

answered Apr 18, 2018 in Selenium by code_ninja
• 6,220 points
1,717 views
+1 vote
2 answers

Getting this error: “Element is not clickable at point”

There are 3 possible solutions for this: 1. ...READ MORE

answered Apr 20, 2018 in Selenium by king_kenny
• 3,650 points
19,717 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
550 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
885 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
546 views