loading...

Visibility of element in DOM (Python with Selenium)

joselitan profile image Jose Martin ・1 min read

Hello,
I am struggling to find a more efficient way to identify if an element is visible in the DOM or not.
I am creating a simple automation script with selenium and python and the best way i found is to use is self.driver.find_elements_by_xpath("xpath") with len function. it would look like this

verify_element = len(self.driver.find_elements_by_xpath(".//xpath"). If it will return the result in a list. If element exist it will return "1" and if it doesn't it will return "0"

The mentioned above works great but it has a mayor setback which is that it takes too long time for that line of code to execute.

It would be very appreciated if you guys have a better way/solution to share.

thanks in advanced.

Discussion

markdown guide