How to check before actions the xpath available or not?

Viewed 45

I want to check xpath available or not. But I don't want to ignore any error.

I want to do like this...

if driver.find_element_by_xpath("your xpath"):

driver.find_element_by_xpath("your xpath").click()

But it's not working!

1 Answers

If you use elements it will work. Like...

if driver.find_elements_by_xpath("your xpath"):
driver.find_element_by_xpath("your xpath").click()

It will work.

Related