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 = "myemail@mymail.com"
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.

Community
  • 1
  • 1
user3412816
  • 53
  • 1
  • 8
  • 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. – Louis Mar 13 '14 at 16:22

1 Answers1

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']
ddavison
  • 28,221
  • 15
  • 85
  • 110