jBrowserDriver 基于 WebKit 无图形化浏览器开源项目

我要开发同款
匿名用户2016年07月27日
74阅读
所属分类Java、应用工具、浏览器
授权协议Apache

作品详情

jBrowserDriver是一款采用纯Java编写的无图形化浏览器,基于WebKit,和 Selenium 兼容。

通过Maven安装:

<dependency>  <groupId>com.machinepublishers</groupId>  <artifactId>jbrowserdriver</artifactId>  <version>0.16.1</version></dependency>

使用示例代码:

import org.openqa.selenium.WebDriver;import com.machinepublishers.jbrowserdriver.Timezone;import com.machinepublishers.jbrowserdriver.JBrowserDriver;import com.machinepublishers.jbrowserdriver.Settings;public class Example {  public static void main(String[] args) {    // You can optionally pass a Settings object here,    // constructed using Settings.Builder    JBrowserDriver driver = new JBrowserDriver(Settings.builder().      timezone(Timezone.AMERICA_NEWYORK).build());    // This will block for the page load and any    // associated AJAX requests    driver.get("https://example.com");    // You can get status code unlike other Selenium drivers.    // It blocks for AJAX requests and page loads after clicks     // and keyboard events.    System.out.println(driver.getStatusCode());    // Returns the page source in its current state, including    // any DOM updates that occurred after page load    System.out.println(driver.getPageSource());    // Close the browser. Allows this thread to terminate.    driver.quit();  }}
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论