0

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:

enter image description here

How could I fix this?

vehn
  • 49
  • 9
  • Does this [question](https://stackoverflow.com/questions/50642308/webdriverexception-unknown-error-devtoolsactiveport-file-doesnt-exist-while-t) help? – Bahrom Jun 03 '21 at 22:00
  • 3
    [Please do not upload images of code/errors when asking a question.](//meta.stackoverflow.com/q/285551) Include your code as a [formatted code block](//stackoverflow.com/help/formatting) instead of an image. [Why do we hate screenshots so much?](//meta.stackoverflow.com/q/303812/) – Pranav Hosangadi Jun 03 '21 at 22:01
  • Since this is a common error, please explain what existing solutions you've tried and what happened when you tried each solution. – Random Davis Jun 04 '21 at 19:20

2 Answers2

1

You need to get a chromedriver.exe to start with. Be sure to check your Chrome version and get the correspondent chromedriver. Then pass it to webdriver

chromedriver_path = 'your_path'
driver = webdriver.Chrome(executable_path=chromedriver_path)
-1

The problem seems to start at Line # 9

driver = webdriver.Chrome()

I think you have problem when starting a browser instance, maybe permission change on your browser would help.