I know that I can use methods such as:
find_elements_by_tag_name() find_elements_by_id() find_elements_by_css_selector() find_elements_by_xpath()
But what I would like to do is simply get a list of all the element IDs that exist in the page, perhaps along with the tag type they occur in.
How can I accomplish this?
Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. Python is a general-purpose language, meaning it can be used to create a variety of different programs and isn't specialized for any specific problems.
Python has a simple syntax similar to the English language. Python has syntax that allows developers to write programs with fewer lines than some other programming languages. Python runs on an interpreter system, meaning that code can be executed as soon as it is written.
Python is widely considered among the easiest programming languages for beginners to learn. If you're interested in learning a programming language, Python is a good place to start. It's also one of the most widely used.
Python is undoubtedly considered a top programming language at the same level as JavaScript or C++, and it's one of the most used languages by businesses and enterprises. Even though it's almost 30 years old, Python is still relevant, given its ease of use, its vibrant community, and many applications.
from selenium import webdriver driver = webdriver.Firefox() driver.get('http://google.com') ids = driver.find_elements_by_xpath('//*[@id]') for ii in ids: #print ii.tag_name print ii.get_attribute('id') # id name as string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With