how to import selenium WebElement in python

Question:

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)

Asked By: am05mhz

||

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

Answered By: am05mhz
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.