#I'm sure this will be interchangeable with the Chrome driver too
driver = webdriver.Firefox()
#Set the focus to the browser rather than the web content
driver.set_context("chrome")
#Create a var of the window
win = driver.find_element_by_tag_name("window")
#Send the key combination to the window itself rather than the web content to zoom out
#(change the "-" to "+" if you want to zoom in)
win.send_keys(Keys.CONTROL + "-")
#Set the focus back to content to re-engage with page elements
driver.set_context("content")
我到处寻找使用selenium缩小范围的解决方案,文档中没有提到任何内容。幸运的是,Firefox(geckodriver)的驱动程序在他们的Github上有这个功能
我简略地介绍了如何缩小(和缩小),希望这是最有意义的(或者至少对我来说是这样)
在指定缩放级别时,可以执行类似的操作,如下所示:
例如,如果我的
body
有一个<div id='values'>
,我可以使用或者尝试一下:
这对IE有效
相关问题 更多 >
编程相关推荐