0

I followed the accepted answer's solution at: How to use Selenium with Python?

I am trying to log into coinbase https://coinbase.com/signin

Here is my code

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException


site = "https://coinbase.com/signin"
email = "[email protected]"
password = "mypassword"

xpaths = {
'emailTxtBox' : '/html/body/div[2]/div[2]/div[2]/div/div/form/div[2]/div/input',      
'passwordTxtBox' : '/html/body/div[2]/div[2]/div[2]/div/div/form/div[3]/div/input',
'submitButton' : '/html/body/div[2]/div[2]/div[2]/div/div/form/div[4]/div/input'
    }

browser = webdriver.Firefox()
browser.get(site)

#Write Username in Username TextBox
mydriver.find_element_by_xpath(xpaths['emailTxtBox']).send_keys(email)

#Write Password in password TextBox
mydriver.find_element_by_xpath(xpaths['passwordTxtBox']).send_keys(password)

#Click Login button
mydriver.find_element_by_xpath(xpaths['submitButton']).click()

I run this, and selenium opens coinbase, then refreshes after a couple seconds, then nothing happens.

1
  • Are you sure your xpaths are hitting the right elements? For the two send_keys you should see the text typed in at least. If the xpaths are off but still match something, Selenium will happily go forth sending keys and clicking on the wrong elements. Commented Mar 13, 2014 at 16:22

1 Answer 1

4

You are specifying:

xpaths['usernameTxtBox']

but it doesn't exist according to your array:

xpaths = {
'usernameTxtBox' # needs to be in the array
'emailTxtBox' : '/html/body/div[2]/div[2]/div[2]/div/div/form/div[2]/div/input',      
'passwordTxtBox' : '/html/body/div[2]/div[2]/div[2]/div/div/form/div[3]/div/input',
'submitButton' : '/html/body/div[2]/div[2]/div[2]/div/div/form/div[4]/div/input'
    }

Edit after comment: I'd consider either revising your xpath, or Keeping It Simple, (Stupid).

//input[@id='email']
//input[@id='password']
//input[@id='signin_button']
Sign up to request clarification or add additional context in comments.

2 Comments

That was just a typo in in the post, sorry. it still wont work.
I fixed my answer. I was suppost to be using browser. instead of mydriver. Silly me. Thanks anyways for trying to help

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.