I am trying to sign in my account through this link on the Market Watch web page through Python and using the Selenium package. I am able to select the "Sign In" button and click on it but nothing happens and therefore can't access the webpage I want.
I think my mistake comes from the fact that I am perhaps not selecting the correct button. The element code is the following:
<div class="sign-in">
<button class="solid-button basic-login-submit">
<span class="text" data-token="signIn" token-title="signIn" title="Sign In">
Sign In
</span>
</button>
</div>
<div class="create-connect" style="display: none;">
<button class="solid-button basic-login-connect">
<span class="text" data-token="yesConnect">
Yes, connect
</span>
</button>
...some other buttons for facebook connection
My code is the following:
driver.get("https://sso.accounts.dowjones.com/login?state=g6Fo2SBQQURPVkxkcTR0RW1zX21NSmxLY3F4Q2RoUm5QTWV4UaN0aWTZMmdhRm8yU0IwUW01dVV6WjJiVXhVUmtaRVRXd3dlamM1UVdjNVIweExiVFJVYlc5WFl3o2NpZNkgNWhzc0VBZE15MG1KVElDbkpOdkM5VFhFdzNWYTdqZk8&client=5hssEAdMy0mJTICnJNvC9TXEw3Va7jfO&protocol=oauth2&prompt=login&scope=openid%20idp_id%20given_name%20family_name%20email%20djid%20prts&response_type=code&redirect_uri=https%3A%2F%2Faccounts.marketwatch.com%2Fauth%2Fsso%2Flogin&nonce=ac689d94-8b8f-4e6d-9255-439f58fc3c0f&connection=DJldap&ui_locales=en-us-x-mw-3-8&ns=prod%2Faccounts-mw#!/signin") #this is the link above
username = driver.find_element_by_id("username")
password = driver.find_element_by_id("password")
username.send_keys("[email protected]")
password.send_keys("***")
driver.find_element_by_xpath(".//*[contains(text(), 'Sign In')]").click()
driver.find_element_by_xpath(".//*[contains(text(), 'Yes, connect')]").click()
Where the first element is supposed to on the sign in button. I am not sure about the second click but I stilled tried it and still nothing happened.
I am interested to find out:
- what am I doing wrong
- why when I click on the "Sign In" button nothing happens
- how to get over it
I have also tried without success:
driver.find_element_by_css_selector("solid-button.basic-login-submit")

<form>has no action attribute, so I bet JavaScript is listening for an onclick or onsubmit event. Clicking this using Selenium might not be triggering DOM events correctly. You might want to try triggering a click event using JavaScript.