(蟒蛇,硒)如何在运行时最小化火狐窗口



如何使用Selenium和Python最小化Firefox窗口

我试过

    try:
        body=None
        body = driver.find_element_by_tag_name("body")
        body.send_keys("{%+" "+N}")
        print "entered keys"
    except NoSuchElementException:
        print "item body is not exists" 
    code:2
    ------
    body.send_keys(Keys.CONTROL+Keys.ESCAPE+'D')
    code:3
    ------
    body.send_keys("{%" "n}")

没有任何效果,我想在运行时或调用后最小化我的 Firefox 窗口

或以没有焦点的不可见模式运行

以下代码应该有帮助:

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.google.com")
actionChain = ActionChains(driver).key_down(Keys.ALT)
actionChain.send_keys(Keys.SPACE)
actionChain.send_keys("n")
actionChain.perform()

最新更新