5
votes

I am using a Selenium module in Python to log into Quora. It works fine for Facebook, but I am getting an error on the send_keys('my_email') line while trying it on Quora:

I am using the following script.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

driver = webdriver.Firefox()
driver.get('http://www.quora.com/')
time.sleep(60)

username = driver.find_element_by_name('email')
time.sleep(60)
username.send_keys('my_email')
time.sleep(60)

password = driver.find_element_by_name('password')
time.sleep(60)
password.send_keys('my_password')
time.sleep(60)

password.send_keys(Keys.RETURN)

driver.close

Sleep time is not a problem here, because I tried executing a script line by line using the Python shell.

Error:

Traceback (most recent call last): File "", line 1, in password.send_keys('my_password') File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 293, in send_keys self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': typing}) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 370, in _execute return self._parent.execute(command, params) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 173, in execute self.error_handler.check_response(response) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 164, in check_response raise exception_class(message, screen, stacktrace) ElementNotVisibleException: Message: u'Element is not currently visible and so may not be interacted with' ; Stacktrace: at fxdriver.preconditions.visible (file:///c:/users/siddhesh/appdata/local/temp/tmpgwft3s/extensions/[email protected]/components/command_processor.js:8791:5) at DelayedCommand.prototype.checkPreconditions_ (file:///c:/users/siddhesh/appdata/local/temp/tmpgwft3s/extensions/[email protected]/components/command_processor.js:11438:1) at DelayedCommand.prototype.executeInternal_/h (file:///c:/users/siddhesh/appdata/local/temp/tmpgwft3s/extensions/[email protected]/components/command_processor.js:11455:11) at DelayedCommand.prototype.executeInternal_ (file:///c:/users/siddhesh/appdata/local/temp/tmpgwft3s/extensions/[email protected]/components/command_processor.js:11460:7) at DelayedCommand.prototype.execute/< (file:///c:/users/siddhesh/appdata/local/temp/tmpgwft3s/extensions/[email protected]/components/command_processor.js:11402:5)

1
Please include the complete traceback into the question.alecxe

1 Answers

6
votes

The problem is that there are multiple inputs with name="email".

You need the one in the "Regular Login" section:

form = driver.find_element_by_class_name('regular_login')
username = form.find_element_by_name('email')
username.send_keys('my_email')

password = form.find_element_by_name('password')
password.send_keys('my_password')