2

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.

2 Answers 2

1

WebElement has the tag_name property

element.tag_name
Sign up to request clarification or add additional context in comments.

2 Comments

this is insane! I literally have been searching and none of the answers addressed it straight forward. Thanks!
@LakshmiNarayanan you might find this useful, it's Python Selenium API. Focus on Webdriver.remote section.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.