0

So these blue buttons with the crosses next to the profiles, how do I write a line of code to return a list of all of these buttons.

Something like:

buttons = browser.find_element_by_css_selector("something here")

or

buttons = browser.find_elements_by_xpath("something here")

or whatelse find_elements_by_... that works

1
  • Please don't post pics of html. Use the snippet tool available via edit Commented May 4, 2019 at 21:57

1 Answer 1

1

I see there are multiple buttons mostly with the same class, so ypu have to use

Then iterate through all of them.

Here is the xpath

buttons = driver.find_elements_by_xpath("//span[@class='ui_button_icon']")
for button in buttons:
    button.click()    

If you want to click specific button you can use either index or relative button to other element like person name.

# clicking on 2nd button
driver.find_element_by_xpath("(//span[@class='ui_button_icon'])[2]").click()

Here is the css

span.ui_button_icon

You can apply same logic to click on nth element using nth-of-type.

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

1 Comment

If you feel this issue is resolved, please accept the answer so that we can reduce the number of unanswered questions :-)

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.