How to run ghostdriver with Selenium using java(如何使用 Java 使用 Selenium 运行 ghostdriver)
问题描述
我想使用 phantomJS 进行一些 web 测试,我遇到了 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 Java 使用 Selenium 运行 ghostdriver
基础教程推荐
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- JPA惰性列表上的流 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
