【文件属性】:
文件名称:基于WebKit无图形化浏览器jBrowserDriver.zip
文件大小:407KB
文件格式:ZIP
更新时间:2022-08-07 23:28:32
开源项目
jBrowserDriver是一款采用纯Java编写的无图形化浏览器,基于WebKit,和Selenium兼容。通过Maven安装:
com.machinepublishers
jbrowserdriver
0.16.1
使用示例代码: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("http://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();
}
}