全屏显示硒。该怎么办?

时间:2019-05-10 15:57:10

标签: python selenium-chromedriver

我正在尝试使用pycharm在selenium上执行键盘键功能来编写脚本。我想执行F11键,即:使用selenium进入全屏并返回正常窗口,但是我正在使用的脚本不执行任何功能,并且驱动程序在给定时间延迟后退出。我的脚本使用了chrome驱动程序。请帮忙。

我在Windows 8.1上使用它 带有pycham教育版 python 3.7 硒为python 3.14

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time

driver = webdriver.Chrome(executable_path=r"A:\full screen\browser\chromedriver.exe")
driver.get("https://www.google.com")
time.sleep(2)
print("google")
act = ActionChains(driver)
act.send_keys(Keys.F11).perform()
print("fullscreen")
time.sleep(2)
act.send_keys(Keys.F11).perform()
print("fullscreen exit")
time.sleep(2)
driver.quit()

我的预期结果是全屏显示并返回正常窗口,然后退出chrome驱动程序。

0 个答案:

没有答案
相关问题