Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 2

Selenium Unable to Import Keys

I've tried searching here a few times for a relevant thread but have not been able to find anything. Not sure if it's an issue with how I installed selenium/ version etc. Below is the code I'm trying to run along with the error I received.

 

Any help is greatly appreciated. Thank you!


Code:

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

class TwitterBot:
def _init_(self,username,password):
self.username = username
self.password = password
self.bot = webdriver.Firefox()

def login(self):
bot = self.bot
bot.get('https://twitter.com/')
time.sleep(3)
email = bot.find_element_by_class_name('js-username-field email-input js-initial-focus')
password = bot.find_element_by_class_name('js-password-field')
email.clear()
password.clear()
email.send_keys(self_username)
password.send_keys(self.password)

ducks = TwitterBot('iheartduckss@outlook.com', '*********')
ducks.login()

 

Error:

from selenium.webdriver.common.keys import keys
ImportError: cannot import name 'keys' from 'selenium.webdriver.common.keys' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/common/keys.py)

1 Reply
Ground Controller Lvl 1
Message 2 of 2

Re: Selenium Unable to Import Keys

Please anyone help here, i am alsogetting same error.

E:\Seleniumpython\venv\Scripts\python.exe E:/Seleniumpython/multibrowser.py
Traceback (most recent call last):
File "E:/Seleniumpython/multibrowser.py", line 6, in <module>
driver=webdriver.chrome(executable_path="E:\Driver\chromedriver_win32\chromedriver")
TypeError: 'module' object is not callable