Skip to content

Commit

Permalink
Replace PhantomJS with Headless Chrome for testing (fixes #400)
Browse files Browse the repository at this point in the history
  • Loading branch information
janschaefer committed May 5, 2019
1 parent d7466a5 commit e712484
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Expand Up @@ -21,9 +21,8 @@ If you want to contribute code or documentation please follow the following work
## System Requirements

* JDK 8 (`JAVA_HOME` and `PATH` should be set accordingly)
- Note that JGiven is built and compatible with Java 1.6, however, because of some test libraries, Java 8 is required for executing the tests in the `jgiven-tests` project
- Note that JGiven is built and compatible with Java 7, however, because of some test libraries, Java 8 is required for executing the tests in the `jgiven-tests` project
* Gradle (is automatically downloaded by the `gradlew` script)
* PhantomJS (required for the Selenium tests of the HTML5 report, can be installed, for example, with `npm install -g phantomjs-prebuilt`)

## Building and Testing JGiven

Expand Down
2 changes: 1 addition & 1 deletion jgiven-tests/build.gradle
Expand Up @@ -11,7 +11,7 @@ dependencies {

testCompile "org.assertj:assertj-core:$assertjVersion"
testCompile 'org.seleniumhq.selenium:selenium-java:3.141.59'
testCompile 'com.codeborne:phantomjsdriver:1.4.4'
testCompile 'io.github.bonigarcia:webdrivermanager:3.4.0'
testCompile 'org.apache.commons:commons-io:1.3.2'
}
sourceCompatibility = targetCompatibility = 1.8
Expand Down
Expand Up @@ -7,6 +7,8 @@
import java.util.List;
import java.util.Map;

import io.github.bonigarcia.wdm.ChromeDriverManager;
import io.github.bonigarcia.wdm.DriverManagerType;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -15,7 +17,6 @@
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;

import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
Expand All @@ -35,6 +36,8 @@
import com.tngtech.jgiven.tags.FeatureTags;
import com.tngtech.jgiven.tags.FeatureTagsWithCustomStyle;
import com.tngtech.jgiven.tags.Issue;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

@BrowserTest
@FeatureHtml5Report
Expand All @@ -54,7 +57,15 @@ public class Html5AppTest extends JGivenScenarioTest<GivenReportModels<?>, WhenH

@BeforeClass
public static void setupWebDriver() {
webDriver = new PhantomJSDriver();
ChromeDriverManager.getInstance(DriverManagerType.CHROME).setup();

ChromeOptions options = new ChromeOptions();
options.addArguments("--headless");
options.addArguments("--disable-gpu");
options.addArguments("window-size=1280x768");

webDriver = new ChromeDriver(options);

webDriver.manage().window().setSize( new Dimension( 1280, 768 ) );
}

Expand Down

0 comments on commit e712484

Please sign in to comment.