无法使用 Python Selenium 访问 Chrome Dino 游戏
Unable to access Chrome Dino game using Python Selenium
我正在尝试在 Python 中使用 Selenium 自动化 Chrome 恐龙游戏并创建了这个示例 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()
我从另一个文件调用 load_game()
,但我收到一条错误消息
selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_INTERNET_DISCONNECTED (Session info: chrome=94.0.4606.61)
当我用正常的 https://google.com
替换 url 时,它似乎工作正常。我假设这可能是因为 Selenium 需要响应?
对于如何通过 Selenium 访问此游戏,是否有解决方法?
谢谢!
已由第三方切换到唯一版本https://chromedino.com/
并且可以访问此。
我正在尝试在 Python 中使用 Selenium 自动化 Chrome 恐龙游戏并创建了这个示例 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()
我从另一个文件调用 load_game()
,但我收到一条错误消息
selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_INTERNET_DISCONNECTED (Session info: chrome=94.0.4606.61)
当我用正常的 https://google.com
替换 url 时,它似乎工作正常。我假设这可能是因为 Selenium 需要响应?
对于如何通过 Selenium 访问此游戏,是否有解决方法?
谢谢!
已由第三方切换到唯一版本https://chromedino.com/
并且可以访问此。