How to maximize the browser window in Selenium WebDriver (Selenium 2) using C#?

前端 未结 28 2306
悲&欢浪女
悲&欢浪女 2020-11-29 18:20

Is there any way to maximize the browser window using WebDriver (Selenium 2) with C#?

28条回答
  •  半阙折子戏
    2020-11-29 18:21

    There is a function that you can use to maximize the window in Python which is window_maximize(). And this is how I'm using it.Hope this helps -

    from selenium import selenium
    sel = selenium('localhost', 4444, '*firefox', 'http://10.77.21.67/')
    sel.start()
    sel.open('/')
    sel.wait_for_page_to_load(60000)
    #sel.window_focus()
    sel.window_maximize()
    png = sel.capture_screenshot_to_string()
    f = open('screenshot.png', 'wb')
    f.write(png.decode('base64'))
    f.close()
    sel.stop()
    

提交回复
热议问题