-5

Here's my code:

<ul class="Buttons--stackOnMobile">
    <li class="col">
        <button class="Button">Sign In</button>
    </li>
    <li class="col col--secondary">
        <a class="Button Button--alt" href="/account/create">Create an Account</a>
    </li>
    <li class="col hide">
        <button class="Button">Sign In</button>
    </li>
</ul>

I'm trying to make selenium click on Sign in button.

I'm coding in Python 3.6.

Philipp
  • 717
  • 2
  • 7
  • 20
Trap Star
  • 25
  • 6
  • 2
    Possible duplicate of [python selenium click on button](https://stackoverflow.com/questions/21350605/python-selenium-click-on-button) – Lucas Abbade Oct 29 '19 at 13:28
  • 1
    Welcome to Stack Overflow! See: [How do I do X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-do-x) The expectation on SO is that the user asking a question not only does research to answer their own question but also shares that research, code attempts, and results. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: [ask] – JeffC Oct 29 '19 at 21:04
  • You need to post your python code. You have posted HTML so far. Also include the full error message that you get when running your current code. – JeffC Oct 29 '19 at 21:04

1 Answers1

1

There are two buttons are present with the same xpath.

if you want to click first button then use below code

wait = WebDriverWait(browser, 10)
button= wait.until(EC.element_to_be_clickable((By.XPATH,'(//button[@class="Button"])[1]')))
button.click()

if you want to click the second button then use below code

  wait = WebDriverWait(browser, 10)
    button= wait.until(EC.element_to_be_clickable((By.XPATH,'(//button[@class="Button"])[2]')))
    button.click()
SeleniumUser
  • 3,833
  • 2
  • 6
  • 23