1

website:https://www.etoro.com/login

<button automation-id="login-sts-btn-sign-in" ng-click="loginCtrl.login(loginForm)" class="e-btn-big wide dark pointer">Sign in</button>

I am trying to click on Sign in button by xpath :

driver.find_element_by_xpath("/html/body/ui-layout/div/div/div[1]/login/login-sts/div/div/div[1]/form/div/div[4]/button").click()

But failed to do so. Tried by css and by class also but unable to login.

When I am trying to login manually then it login successfully but while through selenium python it failed to do so.

Page only showing an error: "An error occurred ,please try again" Is there any suggestions, what to do or what I am not getting here?

0

You can use the CSS attribute specially placed for automation:

button[@automation-id='login-sts-btn-sign-in'] // XPath
button[automation-id='login-sts-btn-sign-in'] // CSS Selector

If it does not work, please, update your question with the Python code that selects and clicks on the element.

  • I have tried both :'button = driver.find_elements_by_xpath("//button[@automation-id='login-sts-btn-sign-in']").click()' and 'button = driver.find_element_by_css_selector("button[automation-id='login-sts-btn-sign-in']").click()' But it does not works. – Shiv Dec 21 '18 at 11:10
  • What was the error? Add a breakpoint between the find call and the click and inspect of the is visible. Also, add another break point after the click, to check if the click is happening. You may need to add some waits before find or after click. – João Farias Dec 22 '18 at 13:38
0

Try this out

You can find all buttons by text and then execute click() method for each button in a for loop.

Using this SO answer it would be something like this:

buttons = driver.find_elements_by_xpath("//*[contains(text(), 'Sign in')]")

for btn in buttons:
    btn.click()
  • @vermin len(buttons)=2 :Tried both of them but still getting the same error that "An error has occurred please try again" , Do not getting that what can be the reason for that. . . Please suggest any other method would be thankful to you.. – Shiv Dec 21 '18 at 11:17
  • okay so exactly when the error is occuring like when you trying to click the button or before that – Rao Dec 21 '18 at 11:19
  • After clicking the button error occurs on the page. Using driver=webdriver.Firefox(), and used chromedriver() too but error still the same for both – Shiv Dec 21 '18 at 11:22
  • i dont find this error related to either python nor does with selenium – Rao Dec 21 '18 at 12:05
  • 1
    You can check url by manually sign in by provided user details.. if it works? – Shiv Dec 21 '18 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.