How to resize/maximize Firefox window during launching Selenium Remote Control?

后端 未结 9 1253
眼角桃花
眼角桃花 2020-12-14 07:47

I am using Selenium Remote Control . During executing the tests the actual Firefox window is so small. I want it full screen so I can see what is happening. How can I maximi

相关标签:
9条回答
  • 2020-12-14 08:07

    Try the windowMaximize command:

    selenium.windowMaximize();
    

    You can also set a specific width and height using the following command:

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

    Where X is the width and Y is the height.

    0 讨论(0)
  • 2020-12-14 08:10

    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)
  • 2020-12-14 08:21

    for Firefox: sel.key_press_native(122) (122 in the key code for F11)

    0 讨论(0)
  • 2020-12-14 08:22

    This works for me. All the other solutions didn't work in FF7.

    WebDriver driver = ((WebDriverBackedSelenium) selenium).getWrappedDriver();
    driver.manage().window().setPosition(new Point(0, 0));
    driver.manage().window().setSize(new Dimension(1920, 1080));
    
    0 讨论(0)
  • 2020-12-14 08:22

    To expand on David Hunt's suggestion for more specific window resizing and moving note the following.

    To work in most environments move before resizing. That is:

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

    To cover 2/3's of the screen, which is handy for seeing part of the selenium driving window underneath, and to do this regardless of your target screen resolution:

    selenium.getEval("window.moveTo(screen.availWidth / 3,0); window.resizeTo(screen.availWidth * (2/3), screen.availHeight); ");

    0 讨论(0)
  • 2020-12-14 08:23

    Well I think the best way is to use selenium.windowMaximize() selenium function instead of manipulating the windows size.

    0 讨论(0)
提交回复
热议问题