Lakshmi Narayanan
Lakshmi Narayanan

Reputation: 5362

get tag of element selenium python

Is there a way to get the tag of the element using selenium python? For eg:

    <div class = "...."></div>

Is there a way to get the result as div if the element is known? I do know that there's a solution with bs4 but my routine is well developed in selenium.

Upvotes: 2

Views: 112

Answers (2)

iDrwish
iDrwish

Reputation: 3103

You can use Selenium find_element_by_

Driver = webdriver.Chrome()
element = Driver.find_element_by_class_name(class_name)
element.tag_name

The documentation is over here.

Upvotes: 1

Guy
Guy

Reputation: 50949

WebElement has the tag_name property

element.tag_name

Upvotes: 1

Related Questions