I need Selenium to open it's web browser in a larger resolution ( preferably maximized)

前端 未结 4 2009
广开言路
广开言路 2021-01-01 14:46

I am using Selenium WebDriver and coding in Python

I have looked all over the place and the best I could find were things written in different languages. I also trie

相关标签:
4条回答
  • 2021-01-01 15:08

    Are you asking to increase the screen magnification?

    This will magnify a Firefox browser, Python 2.7

    from selenium.webdriver.common.keys import Keys    
    
    br = webdriver.Firefox()
    zoomAction = ActionChains(br)
    body = br.find_element_by_tag_name('body')
    for i in range(2):
        zoomAction.send_keys_to_element(body,Keys.CONTROL,"+").perform()
    
    0 讨论(0)
  • 2021-01-01 15:10

    You can either use selenium.windowMaxmize(); or if you want to run your test in some specific resolution,You can go with

    selenium.getEval("window.resizeTo(X, Y); window.moveTo(0,0);")

    0 讨论(0)
  • 2021-01-01 15:14
    browser = webdriver.Firefox()
    url = 'http://www.google.com/'
    browser.get(url)
    browser.maximize_window()
    
    0 讨论(0)
  • 2021-01-01 15:25

    Selenium 2.31.0

    driver = webdriver.Firefox()
    
    # Resize the window to the screen width/height
    driver.set_window_size(300, 500)
    
    # Move the window to position x/y
    driver.set_window_position(200, 200)
    
    0 讨论(0)
提交回复
热议问题