Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
How do I access the first element of an array using a CSS selector in python?
For Example:
css=('.od-FieldEditor-fieldTitle.ms-Label.is-required') returns an array of 6 labels. I want to access the innerText attribute of the first label.
css=('.od-FieldEditor-fieldTitle.ms-Label.is-required')
innerText
Image shows the array of labels
Try this:
elements = driver.find_elements_by_css_selector('selector_required') # if you want to navigate through for e in elements: # do some stuffs with 'e' # to access a single object e = elements[0] # will return the first element of a list
Add a comment
Required, but never shown
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.
Explore related questions
See similar questions with these tags.