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

后端 未结 9 1254
眼角桃花
眼角桃花 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:23

    In ruby, the call would be

    web_driver.manage.window.maximize

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

    You can do the following:

    page.driver.browser.manage.window.maximize
    
    0 讨论(0)
  • 2020-12-14 08:30

    None of the answers provided work when passing the -singlewindow parameter to the Selenium RC server. However, if you pass a firefox profile to the Selenium RC server (as detailed somewhat here), you can make an empty profile folder and put this file in the folder:

    localstore.rdf(case sensitive filename!):

    <?xml version="1.0"?>
    <RDF:RDF xmlns:NC="http://home.netscape.com/NC-rdf#"
             xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
      <RDF:Description RDF:about="chrome://browser/content/browser.xul#main-window"
                       sizemode="normal"
                       height="9999"
                       width="9999"
                       screenX="0"
                       screenY="0" />
                       lastSelected="paneTabs" />
      <RDF:Description RDF:about="chrome://browser/content/browser.xul">
        <NC:persist RDF:resource="chrome://browser/content/browser.xul#main-window"/>
        <NC:persist RDF:resource="chrome://browser/content/browser.xul#PersonalToolbar"/>
        <NC:persist RDF:resource="chrome://browser/content/browser.xul#nav-bar"/>
        <NC:persist RDF:resource="chrome://browser/content/browser.xul#status-bar"/>
        <NC:persist RDF:resource="chrome://browser/content/browser.xul#toggle_taskbar"/>
        <NC:persist RDF:resource="chrome://browser/content/browser.xul#navigator-toolbox"/>
        <NC:persist RDF:resource="chrome://browser/content/browser.xul#toolbar-menubar"/>
        <NC:persist RDF:resource="chrome://browser/content/browser.xul#sidebar-box"/>
        <NC:persist RDF:resource="chrome://browser/content/browser.xul#sidebar-title"/>
      </RDF:Description>
    </RDF:RDF>
    

    Replace width and height with your preferred width and height. 9999x9999 will pretty much maximize any monitor.

    The simplest example possible of running your Selenium RC server this way assuming we have the previously mentioned localstore.rdf in our home directory, and we are currently in the directory of the Selenium RC server:

    rm -rf ~/ffProfile
    mkdir ~/ffProfile
    cp localstore.rdf ~/ffProfile
    java -jar selenium-server-*.jar -singlewindow -firefoxProfileTemplate "~/ffProfile"
    

    This also has the added benefit of not "polluting" your tests.

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