开发者

Selenium RC test (PHPUnit)

开发者 https://www.devze.com 2023-03-30 02:16 出处:网络
Using, Centos, Apache, PHPUnit, Selenium RC, I was trying to test selenium RC which is running in one of my server.

Using, Centos, Apache, PHPUnit, Selenium RC,

I was trying to test selenium RC which is running in one of my server.

java -jar selenium-server-standalone-2.4.0.jar

Initially i got error of firefox creating profile and it doesnot load anything up and gives error.

Secondly i tried to do with given profile location.

java -jar selenium-server-standalone-2.4.0.jar -firefoxProfileTemplate "/root/.mozilla/firefox/" &

still it shows error

ERROR - Failed to start new browser session, shutdown browser and clear all session data

INFO - Got result: Failed to start new browser session: Error while launching browser on session null

Pleas开发者_如何学Goe share your view what may be the problem, Running Mock , it is working, for test purpose, but firefox, is unable to lunch browser session.

Note: its not GUI mode (NO X), it has firefox version 3.6.18,

09:48:20.312 INFO - Got result: Failed to start new browser session: Error while launching browser on session null
09:48:39.659 INFO - Command request: getNewBrowserSession[*firefox3, http://google.co.uk] on session null
09:48:39.659 INFO - creating new remote session
09:48:39.660 INFO - Allocated session 17b9149077f648d3bc89b3f106466c6c for http://google.co.uk, launching...
09:48:39.860 INFO - Preparing Firefox profile...
09:49:00.017 ERROR - Failed to start new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: Timed out waiting for profile to be created!
        at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFullProfileToBeCreated(FirefoxChromeLauncher.java:360)
        at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.populateCustomProfileDirectory(FirefoxChromeLauncher.java:114)
        at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launch(FirefoxChromeLauncher.java:83)
        at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launchRemoteSession(FirefoxChromeLauncher.java:412)
        at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSession(BrowserSessionFactory.java:375)
        at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:125)
        at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:87)
        at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowserSession(SeleniumDriverResourceHandler.java:785)
        at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResourceHandler.java:422)
        at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDriverResourceHandler.java:393)
        at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHandler.java:146)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
        at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
        at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
        at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
        at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
        at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
        at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
        at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
        at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
09:49:00.048 INFO - Got result: Failed to start new browser session: Error while launching browser on session null


After, a whole day research, i got the solution, which may be useful for all of you if this is the case..

If Any issue: Due to the Display issue you may face several problem, such as firefox profile, and firefox lunching, and not being able to load.

Firefox Profile Issue: Copy and paste from another machine if you dont have in given machine. Firefox Lunching Issue: With No session on null: yum install xorg-x11-Xvfb && Xvfb :99 -ac && export DISPLAY=:99 && firefox Here if you see any issue regarding xvfb :99 you may have to delete the lock file.

Server is already active for display 99 If this server is no longer running, remove /tmp/.X99-lock and start again.

Firefox should launch without error, and stay running (until you kill it with Control-C)


It kept giving me the same error(ERROR - Failed to start new browser session, shutdown browser and clear all session data) regardless of what i did. I am running Selenium on a linux box with firefox installed and i am trying to run it headless.

Here is how i resolved the issue:
1.Install xvfb(a virtual display manager) and its dependencies

sudo apt-get install xvfb sudo apt-get apt-get install libgl1-mesa-dri xfonts-cyrillic xfonts-100dpi xfonts-75dpi

2.Run xvfb like this

sudo Xvfb :99 -ac

This should get it running on display :99. You will see some output

3.Open a new terminal and type this.

export DISPLAY=:99
java -jar selenium-server-standalone-2.37.0.jar

This will set the display to :99. So anything opened from that terminal window that needs to use display will open on the virtual display(which is invisible) managed by xvfb. The second line starts the selenium server, and since selenium will attempt to start firefox, it will start it on this invisible display.

Then run your test. This should get the test setup and the browser will be invisible.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号