I'm trying to automate the Chrome dino game using Selenium in Python and have created this sample class:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
class GameControl():
def __init__(self):
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_experimental_option("detach", True)
self.DINO_URL="chrome://dino"
self.driver = webdriver.Chrome(options=options)
self.driver.set_network_conditions(offline=True, latency=5, throughput=500 * 1024)
self.actionChains = ActionChains(self.driver)
def load_game(self):
self.driver.get(self.DINO_URL)
def close_game(self):
self.driver.close()
def start_game(self):
print("Starting game...")
self.actionChains.send_keys(Keys.SPACE).perform()
From another file, I call load_game()
, but I get an error saying
selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_INTERNET_DISCONNECTED (Session info: chrome=94.0.4606.61)
When I repalce the url with a normal https://google.com
, it seems to work fine. I'm assuming this might be because Selenium expects a response?
Is there a work-around for how I can access this game via Selenium?
Thanks!
CodePudding user response:
Switched to the only version by a third party https://chromedino.com/
and can access this.