https://github.com/lkwg82/de.lgohlke.selenium-webdriver
adds some essential webdriver util classes
https://github.com/lkwg82/de.lgohlke.selenium-webdriver
automation chrome headless-chrome microlib phantomjs selenium webdriver
Last synced: 5 months ago
JSON representation
adds some essential webdriver util classes
- Host: GitHub
- URL: https://github.com/lkwg82/de.lgohlke.selenium-webdriver
- Owner: lkwg82
- License: gpl-2.0
- Archived: true
- Created: 2015-09-14T06:55:33.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2021-12-14T21:12:47.000Z (over 4 years ago)
- Last Synced: 2024-11-16T02:17:59.514Z (over 1 year ago)
- Topics: automation, chrome, headless-chrome, microlib, phantomjs, selenium, webdriver
- Language: Java
- Size: 536 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://search.maven.org/#search%7Cga%7C1%7Cg%3Ade.lgohlke.selenium)
[](https://travis-ci.org/lkwg82/de.lgohlke.selenium-webdriver)
# de.lgohlke.selenium-webdriver
adds some essential webdriver util classes
Note: it is similiar to https://github.com/webdriverextensions/webdriverextensions, but has more emphasis on web automation instead of testing
# Features
- supports chrome headless see https://developers.google.com/web/updates/2017/04/headless-chrome
- supports http(s) proxy
- supports pre-installed chromium-driver
- factory to restart a fresh configured instance
- implementation of logging error handler
- implementation of logging debug handler (screenshots/logs for each step)
- support of concurrent webdriver usage
- a wrapped webdriver, which allows only single access at a time
- a wrapped webdriver, which allows blocking while an transaction is in progress
# usage
in your `pom.xml`
for using the pre-installed chromedriver in `$PATH`
```xml
de.lgohlke.selenium
webdriver
LATEST
for using explicitly a chromedriver version
...
/tmp/webdrivers
...
...
com.github.webdriverextensions
webdriverextensions-maven-plugin
3.1.2
chromedriver
linux
${drivers.installation.directory}
true
webdriver download
generate-resources
install-drivers
...
org.apache.maven.plugins
maven-failsafe-plugin
test
integration-test
verify
${drivers.installation.directory}
...
...
de.lgohlke.selenium
webdriver
LATEST
```
```java
import de.lgohlke.junit.DriverService;
import de.lgohlke.selenium.webdriver.DriverType;
import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import static org.assertj.core.api.Assertions.assertThat;
public class DemoTest {
@Rule
public DriverService driverService = new DriverService(DriverType.CHROME_HEADLESS);
@Test
public void test() throws InterruptedException {
WebDriver driver = driverService.getDriver();
driver.get("https://google.de");
assertThat(driver.getPageSource()).isNotEmpty();
}
}
```
# development instructions
- on linux in intellij you need to pass `DISPLAY=:0.0` variable in run configuration of each test (or run chrome headless)
# build instructions
- install docker
- run `run_docker.sh`
# release instructions
- `mvn -P release release:prepare`
- `mvn -P release release:perform`
# FAQ
## How do I use a synchronized webdriver instance across multiple threads?
```java
Webdriver wrappedDriver = ...
// each additional concurrent webdriver request will be blocked until completion of the first
Webdriver singleCommandSynchronized = ConcurrentWebDriverFactory.createSyncronized(wrappedDriver)
```
## How do I start a transaction to protect a logical sequence of commands?
```java
Webdriver wrappedDriver = ...
LockingWebDriver lockingDriver = ConcurrentWebDriverFactory.createLocking(wrappedDriver);
// blocking any other locking request and any other request from a different thread
lockingDriver.lock();
lockingDriver.get("http://www.lgohlke.de");
lockingDriver.unlock();
```