0

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.

Image shows the array of labels

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

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.