如何使用java运行Selenium的ghostdriver [英] How to run ghostdriver with Selenium using java

查看:234
本文介绍了如何使用java运行Selenium的ghostdriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 phantomJS 进行一些网络测试,我遇到了 GhostDriver https://github.com/detro/ghostdriver )。我使用自述文件中的说明构建它,我可以在指定的端口上运行它,但我不知道如何从我的Java代码访问Web驱动程序。为了澄清,我在ruby中看到了这个例子:

I want to use phantomJS for some web testing, and I've come across GhostDriver (https://github.com/detro/ghostdriver). I've built it using the instructions in the readme and I can run it on a specified port, but I am not sure how to access the web driver from my java code. To clarify, I've seen this example in ruby:

  caps = {
  :browserName => "phantomjs",
  :platform => "LINUX"
   }

urlhub = "http://key:secret@hub.testingbot.com:4444/wd/hub"

client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 120

@webdriver = Selenium::WebDriver.for :remote, :url => urlhub, :desired_capabilities => caps, :http_client => client
@webdriver.navigate.to "http://www.google.com/"
puts @webdriver.title
@webdriver.save_screenshot("./screenshot.png")
@webdriver.quit

我只是不确定如何从java做同样的事情。

I'm just not sure how to do the same from java.

推荐答案

我相信这个链接会回答你的问题。你需要Selenium 2.28.0和PhantomJS 1.8。我已经对此进行了测试,虽然我的测试是前瞻性的,但它的工作方式与广告一样。请注意,您需要下载Selenium zip文件以获取包含绑定的jar。 Maven回购还没有包含它。

I believe this link will answer your questions. You will need Selenium 2.28.0, and PhantomJS 1.8. I have tested this, and it works as advertised, although my tests were precursory. Note that you need to download the Selenium zip file to get the jar which contains the bindings. The Maven repo does not yet include it.

http://ivandemarino.me/2012/12/04/Finally-GhostDriver-1-0-0/

这篇关于如何使用java运行Selenium的ghostdriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆