from selenium import webdriver
import webbrowser
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
import smtplib
import sys
option = webdriver.ChromeOptions()
option.add_argument("--start-maximized")
chrome_path = "C:\Program Files\Google\Chrome\Application\chrome.exe"
driver = webdriver.Chrome(chrome_path, options=option)
driver.get('https://play.typeracer.com/')
while True:
try:
driver.find_element_by_xpath("""//*[@id="dUI"]/table/tbody/tr[2]/td[2]/div/div[1]/div/table/tbody/tr[3]/td/table/tbody/tr/td[2]/table/tbody/tr[1]/td/a""").click()
break
except:
continue
sleep(5)
try:
words = driver.find_element_by_xpath("""//*[@id="gwt-uid-15"]/table/tbody/tr[2]/td/table/tbody/tr[1]/td/table/tbody/tr[1]/td/div/div/span[1]""").text
except:
print("")
try:
words += driver.find_element_by_xpath("""//*[@id="gwt-uid-15"]/table/tbody/tr[2]/td/table/tbody/tr[1]/td/table/tbody/tr[1]/td/div/div/span[2]""").text + " "
except:
print("")
try:
words += driver.find_element_by_xpath("""//*[@id="gwt-uid-15"]/table/tbody/tr[2]/td/table/tbody/tr[1]/td/table/tbody/tr[1]/td/div/div/span[3]""").text
except:
print("")
print(words)
inputField = driver.find_element_by_xpath("""//*[@id="gwt-uid-15"]/table/tbody/tr[2]/td/table/tbody/tr[2]/td/input""")
#Sleeps because the game can detect cheaters if the sleep is not used...Slows down the WPM slightly
for character in words:
inputField.send_keys(character)
sleep(0.1)
I cannot get the driver.get() to work. I know the chrome path is correct since it does open a new chrome window and it does not open a webpage. Can you fix my code without changing the option's variable. I just put the error up right now by doing a traceback call.
Error is:
File "C:\Users\vidit\Documents\CODE\typeracer.py", line 14, in <module>
driver = webdriver.Chrome(chrome_path, options=option)
File "C:\Users\vidit\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\vidit\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\common\service.py", line 98, in start
self.assert_process_still_running()
File "C:\Users\vidit\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\common\service.py", line 109, in assert_process_still_running
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service C:\Program Files\Google\Chrome\Application\chrome.exe unexpectedly exited. Status code was: 0
My chrome instance did not close or anything just to clarify that. Chrome was still running it did not crash or close.