from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://www.google.com')
content = driver.find_element_by_css_selector('title')
print content
I can't seem to get any content by any means(tag_name, class_name, name...) What is the problem with this code?
There doesn't seem to be any problem with the code. The is element being identified correctly by your code.
content = driver.find_element_by_css_selector('title')
print content.tag_name
This should confirm that you have indeed located a web element with title tag. The content.text does not return anything since the title element is not part of the page itself. (Similar trouble discussed here in Java)
If you're trying to print the title of the page, use the following driver field
print(driver.title)
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