0

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.

1 Answer 1

1

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 :)

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

1 Comment

Thank You. Could not see the woods for the trees. Works Perfectly.

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.