How to run selenium webdriver in the background?

后端 未结 6 1699
误落风尘
误落风尘 2021-01-15 05:36

I\'ve been using Selenium for 2 weeks.

It\'s been really useful so far.

When developing, I like having the browsers pop up so I can see what\'s going on, b

相关标签:
6条回答
  • 2021-01-15 05:39

    Try PhantomJS which is a headless browser webkit. HTMLUnit is also similar to PhantomJs; however, usage of PhamtomJs is highly recommended.

    PhantomJs uses Google chrome's JavaScript Engine but without a GUI.

    Refer :http://phantomjs.org/

    0 讨论(0)
  • 2021-01-15 05:40

    Found simple solutin for JAVA Seleniun Google Chrome

        System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        options.addArguments("headless");
        return new ChromeDriver(options);
    
    0 讨论(0)
  • 2021-01-15 05:40

    Give it a try : https://github.com/detro/ghostdriver.

    It uses Headless approach to automate websites.

    0 讨论(0)
  • 2021-01-15 05:53

    Have you thought about running against a Selenium Grid instead? See https://code.google.com/p/selenium/wiki/Grid2

    0 讨论(0)
  • 2021-01-15 05:54

    Phantom is good headless option, but sssuming you want to stick with same tools you are using ... (the following assumes Linux as platform)

    1. install xvfb (apt-get install xvfb)
    2. You can then run selenium/firefox "headless" (assuming Linux) with the following command:-

    DISPLAY=:1 xvfb-run java -jar [selenium JAR filename]

    Now, when your test suite kicks off selenium, it will run using Firefox without browser windows popping up.

    0 讨论(0)
  • 2021-01-15 05:58

    if the server is on linux, you can allocate a display just to run selenium using Xvfb to create a virtual display

    if the server is on windows you can register the daemon to run as another user than the user logged in, giving the service a desktop. this only work for the local system admin account or by registry tweaking as detailed here note that you will have to set up internet explorer properties for the user the service is running as

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