Starting with Phantomjs driver

有些话、适合烂在心里 提交于 2019-12-11 08:48:47

问题


Can anyone suggest me good documentations or steps to start or configure phantomJs driver in java so that i can run my test cases in remote server.


回答1:


I run the selenium server in grid mode then connect the phantomjs to it after it is up as it doesn't try to reconnect if it disconnects or isn't fully up

./phantomjs --webdriver=5558 --webdriver-selenium-grid-hub=http://localhost:4444

which will have it listen on port 5558 (for example) but you connect through selenium an it appears as browser phantomjs on Any platform

Steps

java -jar selenium-server-standalone-2.14.0.jar -role hub 

./phantomjs --webdriver=5558 --webdriver-selenium-grid-hub=http://localhost:4444

You can then run tests as per the selenium web site https://code.google.com/p/selenium/wiki/Grid2

I use perl to run tests http://metacpan.org/pod/Selenium::Remote::Driver but there are many choices




回答2:


First of all, add the relevant dependency of phantomJsDriver (GhostDriver) to the POM file:

<dependency>
    <groupId>com.github.detro.ghostdriver</groupId>
    <artifactId>phantomjsdriver</artifactId>
    <version>LATEST_VERSION_HERE</version>
</dependency>

You can find the full guide here

Then, work with it like with ordinary WebDriver as described in Selenium manuals, but, instead of initialising HtmlUnitDriver:

WebDriver driver = new HtmlUnitDriver();

Initialize PhantomsJsDriver:

WebDriver driver = new PhantomJsDriver();


来源:https://stackoverflow.com/questions/17808174/starting-with-phantomjs-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!