首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用Python Selenium访问Chrome Dino游戏

无法使用Python Selenium访问Chrome Dino游戏
EN

Stack Overflow用户
提问于 2021-09-26 14:37:12
回答 1查看 123关注 0票数 1

我正在尝试使用Python中的Selenium自动化Chrome恐龙游戏,并创建了以下示例类:

代码语言:javascript
复制
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访问这个游戏?

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-05 14:10:04

已由第三方https://chromedino.com/切换到唯一版本,并且可以访问此版本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69335951

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档