Yesterday, I developed a Python Selenium Stackoverflow bot. The code was fine, It did not work though. This bot works with Selenium send_keys
and driver.find_element_by_id
. The code I developed is simple. It asks for the user's input.
It asks:
What's the bot email:
What's the bot password:
What's the Chatroom ID:
The code is below:
import unittest
from selenium import webdriver
import selenium, time
email = input("Enter bot Email: ")
password = input("Enter bot Password: ")
chatroom = input("Enter Chatroom ID: ")
driver = webdriver.Chrome()
emailin = driver.get('https://stackoverflow.com/users/login')
send_button = "sayit-button"
emai = driver.find_element_by_id('email')
emai.send_keys(email)
passw = driver.find_element_by_id('password')
passw.send_keys(password)
login_button = driver.find_element_by_name('submit-button')
login_button.click()
time.sleep()
driver.get('https://chat.stackoverflow.com/rooms/' + chatroom)
## commands
prefix = "/"
if driver.find_element_by_id('bubble') == f"{prefix}help":
print(f"Command Uses in Chatroom")
text = driver.find_element_by_id('input')
text.send_keys('Hello! Im a Bot developed from Pytostack!')
text.send_keys('My commands are `/help`.')
send_button.click()
else:
print(" ")
Yet it sends me this error from the terminal:
How could I fix this?