1

I am trying to find an element with multiple classes per xpathusing Selenium Python. I tried something like this:

self.browser.find_element_by_xpath("//button[@class='sqdOP.L3NKy.y3zKF']")

Here the HTML:

<button class="sqdOP  L3NKy   y3zKF     " disabled="" type="submit"><div class="                     Igw0E     IwRSH      eGOV_         _4EzTm                                                                                                              ">Anmelden</div></button>

but it does not work. So how do I find these elements?

1
  • can you publish screen show with that element?seems like it generated dynamically. did it have dots or spaces?have you tried containes? Commented Mar 24, 2021 at 16:13

3 Answers 3

1

There're couples of ways how you can get the element:

driver_find_element_by_xpath("//button[@class='sqdOP  L3NKy   y3zKF     ']")

driver_find_element_by_xpath("//button[contains(@class,'sqdOP  L3NKy   y3zKF']")
    
driver_find_element_by_css_selector("button.sqdOP.L3NKy.y3zKF']")

driver_find_element_by_css_selector("sqdOP  L3NKy   y3zKF     ")
Sign up to request clarification or add additional context in comments.

Comments

0

You should try to separate class by space not point:

self.browser.find_elements_by_xpath("//button[@class='sqdOP L3NKy y3zKF']")

Comments

-1

If you are trying to find several elements with the same class, you can try this: self.driver.find_elements_by_class_name(class)

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.