This is my first time playing around with selenium and I am trying to take an email and password from a text file (so I can log in and out of different accounts through the use of this bot) and it throws the following errors:
**File "E:\Python\Python_code\Email Login Bot\Login_Bot.py", line 29, in <module>
bot(info[0], info[1])
File "E:\Python\Python_code\Email Login Bot\Login_Bot.py", line 7, in bot
user = br.find_element_by_css_selector("email")
File "E:\Python\Python installer\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 598, in find_element_by_css_selector
return self.find_element(by=By.CSS_SELECTOR, value=css_selector)
File "E:\Python\Python installer\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "E:\Python\Python installer\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "E:\Python\Python installer\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"email"}
(Session info: chrome=92.0.4515.107)**
Below is my source code:
from selenium import webdriver
def bot(usr, pas):
br = webdriver.Chrome()
br.get("https://login.live.com/")
user = br.find_element_by_css_selector("email")
user.clear()
user.send_keys(usr)
btn = br.find_element_by_css_selector("submit")
btn.click()
passwd = br.find_element_by_css_selector("passwd")
passwd.clear()
passwd.send_keys(pas)
btn = br.find_element_by_css_selector("submit")
btn.click()
if __name__ == "__main__":
file = open("Details.txt", "r")
info = file.readlines()
file.close()
bot(info[0], info[1])
Any help would be greatly appreciated, thank you.