Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to import selenium WebElement in python

I want to import selenium WebElement since I need to check if a function returns a WebElement or not

I have googled but only find how to import selenium, such as from selenium import webdriver, I already have that working. The error part is the type checking line such as:

if isinstance(var, WebElement):
    #do something
else:
    #do nothing

so the question is what is the class path for selenium's WebElement? for example from selenium.common import WebElement (already tried this and not working)

like image 522
am05mhz Avatar asked Jul 24 '18 02:07

am05mhz


People also ask

How do I import Selenium into Python?

To install the Selenium bindings in our system, run the command: pip install selenium. As this is done, a folder called Selenium should get created within the Python folder. To update the existing version of Selenium, run the command: pip install –U selenium.

What is Selenium package in Python?

The selenium package is used to automate web browser interaction from Python.


1 Answers

in case someone did not see the answer, its in the comment:

from selenium.webdriver.remote.webelement import WebElement

i'm adding this answer to close this question, thanks for the help

like image 82
am05mhz Avatar answered Oct 04 '22 00:10

am05mhz