我正在尝试使用Python中的Selenium自动化Chrome恐龙游戏,并创建了以下示例类:
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访问这个游戏?
谢谢!
发布于 2021-10-05 14:10:04
已由第三方https://chromedino.com/切换到唯一版本,并且可以访问此版本。
https://stackoverflow.com/questions/69335951
复制相似问题