python - 如何在 Python 中使用 Selenium 打开 chrome 开发者控制台?

标签 python google-chrome selenium

我正在尝试使用 selenium webdriver 在 chrome 中打开开发人员控制台。 我在做

from selenium import webdriver

from selenium.webdriver.common import action_chains, keys

...

browser = webdriver.Chrome(executable_path="C:\chrm\chromedriver.exe") browser.get("https://www.facebook.com/groups/GNexus5/")

...

action = action_chains.ActionChains(browser)

action.send_keys(keys.Keys.CONTROL+keys.Keys.SHIFT+'j')

action.perform()

但它没有打开开发者控制台。 我已经尝试了其他键(只需键入一些击键,控制选择一些元素)并且它们正在工作。

我正在使用 ChromeDriver

最佳答案

告诉 selenium 在启动 chrome 时包含一个“auto-open-devtools-for-tabs”,这里是一个使用 nightwatch 配置的例子:

...

chrome: {
  desiredCapabilities: {
    browserName: 'chrome',
    javascriptEnabled: true,
    acceptSslCerts: true,
    chromeOptions: {
      'args': ['incognito', 'disable-extensions', 'auto-open-devtools-for-tabs']
    }
  }
},
...

关于python - 如何在 Python 中使用 Selenium 打开 chrome 开发者控制台?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30931234/

相关文章:

Python文字游戏

python - 代码完成例如Numpy、SciPy 或 Matplotlib 在 Eclipse PyDev 中不起作用

jquery - 按下 ESC 键关闭对话框后执行对话框的关闭功能(仅限 chrome)

css - Chrome 上显示的框边框不规则

javascript - 想要断言页面源代码中是否存在文本

java - java selenium 如何获取下一个元素的值

python - 计算自纪元以来以秒为单位表示的 float ,以 UTC 为设定时间/日期

python - PySpark 评估

ajax - Chrome中的跨域问题可能是奇怪的Dart HttpRequest行为的b/c

python - 单元测试python中的软断言