Newbe
Newbe

Reputation: 127

Python Selenium print elements not element

In python Selenium I am attempting to print a list of class_name(meta). When I use browser.find.element only one value is returned. I then amend the script:-

demo = browser.find_elements_by_class_name("meta")
print demo.text

I get the following error:-

Traceback (most recent call last): File "test.py", line 29, in print demo.text AttributeError: 'list' object has no attribute 'text'

I new to python & selenium but I have searched for a solution with no luck.

Thanks in advance for your help.

Upvotes: 0

Views: 3136

Answers (1)

Shubham Jain
Shubham Jain

Reputation: 17553

That is happening because you are not iterating. You forget

for lang in demo:

Example code :-

langs = fire.find_elements_by_css_selector("#gt-sl-gms-menu div.goog-menuitem-content")
for lang in langs:
    print lang.text

Hope it will help you :)

Upvotes: 1

Related Questions