【发布时间】:2020-04-09 11:14:05
【问题描述】:
我可以通过 Selenium 打开 Chrome,但无法模拟按键(特别是 F12,因为我想打开 Inspect 并最终使用移动浏览器 Like so)虽然我可以手动操作,即,打开 Chrome 并按 F12,我希望能够使用 Selenium 自动化这部分。我当前的代码如下所示 -
from selenium import webdriver
import time
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument("--test-type")
options.binary_location = "/usr/bin/chromium"
driver = webdriver.Chrome('/Users/amigo/Documents/pet_projects/selenium/chromedriver')
driver.get('https://www.google.com')
ActionChains(driver).send_keys(Keys.F12).perform()
虽然代码运行没有任何错误,但我没有看到在浏览器上打开了检查。任何建议和帮助表示赞赏!先感谢您。
【问题讨论】:
标签: python-3.x selenium mobile selenium-chromedriver google-chrome-devtools