0

I'm trying to input login details into GMAIL with the below coode

from selenium import webdriver
import getpass

chromedriver = 'C:\Python34\Scripts\chromedriver'



driver = webdriver.Chrome(chromedriver)

driver.get('http://www.google.com/adwords/')

signin = driver.find_element_by_class_name('ignore-channel')
signin.click()

email = input('Enter your Email ID : ')
password = getpass.getpass('Password :')
email = driver.find_element_by_id('Email')
email.send_keys(email)
passwd = driver.find_element_by_id('Passwd')
passwd.send_keys(password)

submit = driver.find_element_by_id('signIn')
submit.click()
tools = driver.find_elements_by_partial_link_text('Keyword')
tools[0].click()

When i enter the login/pass details. Python returns the below error

Traceback (most recent call last):
  File "C:/Python34/SEO.py", line 18, in <module>
    email.send_keys(email)
AttributeError: 'str' object has no attribute 'send_keys'

any idea where i might be wrong?

KJ

1
  • 3
    Why are you using same variables for user input and WebElements? Commented Jun 18, 2015 at 18:11

1 Answer 1

1

Check these lines from your code:

Line number 15

email = input('Enter your Email ID : ')

Line number 17

email = driver.find_element_by_id('Email')

Line number 18

email.send_keys(email)

So you are assigning your email string to the variable name 'email' and then again assigning the 'webelement' into the same variable name 'email'. So when the code tries to do sendkeys at line 18, it does not work.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. such a crap mistake !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.