Skip to content

Commit 54c5757

Browse files
committed
refresh driver setup for 4.11 real browser tests
1 parent 3783fd3 commit 54c5757

File tree

1 file changed

+41
-22
lines changed

1 file changed

+41
-22
lines changed

src/test/java/org/openqa/selenium/htmlunit/WebDriverTestCase.java

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@
102102
import org.openqa.selenium.chrome.ChromeOptions;
103103
import org.openqa.selenium.edge.EdgeDriver;
104104
import org.openqa.selenium.edge.EdgeDriverService;
105+
import org.openqa.selenium.edge.EdgeOptions;
105106
import org.openqa.selenium.firefox.FirefoxDriver;
107+
import org.openqa.selenium.firefox.FirefoxDriverService;
106108
import org.openqa.selenium.firefox.FirefoxOptions;
107109
import org.openqa.selenium.firefox.FirefoxProfile;
110+
import org.openqa.selenium.firefox.GeckoDriverService;
108111
import org.openqa.selenium.ie.InternetExplorerDriver;
109112
import org.openqa.selenium.ie.InternetExplorerDriverService;
110113
import org.openqa.selenium.ie.InternetExplorerOptions;
@@ -523,19 +526,39 @@ protected WebDriver buildWebDriver() throws IOException {
523526

524527
if (BrowserVersion.EDGE == getBrowserVersion()) {
525528
if (EDGE_BIN_ != null) {
526-
System.setProperty(EdgeDriverService.EDGE_DRIVER_EXE_PROPERTY, EDGE_BIN_);
529+
final EdgeDriverService service = new EdgeDriverService.Builder()
530+
.withLogOutput(System.out)
531+
.usingDriverExecutable(new File(EDGE_BIN_))
532+
533+
.withAppendLog(true)
534+
.withReadableTimestamp(true)
535+
536+
.build();
537+
538+
final EdgeOptions options = new EdgeOptions();
539+
// options.addArguments("--lang=en-US");
540+
// options.addArguments("--remote-allow-origins=*");
541+
542+
return new EdgeDriver(service, options);
527543
}
528544
return new EdgeDriver();
529545
}
530546

531547
if (BrowserVersion.CHROME == getBrowserVersion()) {
532-
if (CHROME_BIN_ != null) {
533-
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, CHROME_BIN_);
534-
}
548+
final ChromeDriverService service = new ChromeDriverService.Builder()
549+
.withLogOutput(System.out)
550+
.usingDriverExecutable(new File(CHROME_BIN_))
551+
552+
.withAppendLog(true)
553+
.withReadableTimestamp(true)
554+
555+
.build();
556+
535557
final ChromeOptions options = new ChromeOptions();
536558
options.addArguments("--lang=en-US");
559+
options.addArguments("--remote-allow-origins=*");
537560

538-
return new ChromeDriver(options);
561+
return new ChromeDriver(service, options);
539562
}
540563

541564
if (BrowserVersion.FIREFOX == getBrowserVersion()) {
@@ -573,23 +596,19 @@ protected WebClient newWebClient(final BrowserVersion version) {
573596
}
574597

575598
private static FirefoxDriver createFirefoxDriver(final String geckodriverBinary, final String binary) {
576-
if (geckodriverBinary != null
577-
&& !geckodriverBinary.equals(System.getProperty("webdriver.gecko.driver"))) {
578-
System.setProperty("webdriver.gecko.driver", geckodriverBinary);
579-
}
580-
581-
if (binary != null) {
582-
final FirefoxOptions options = new FirefoxOptions();
583-
options.setBinary(binary);
584-
585-
// at least FF79 is not stable when using a profile
586-
final FirefoxProfile profile = new FirefoxProfile();
587-
profile.setPreference("intl.accept_languages", "en-US");
588-
options.setProfile(profile);
589-
return new FirefoxDriver(options);
590-
}
591-
592-
return new FirefoxDriver();
599+
final FirefoxDriverService service = new GeckoDriverService.Builder()
600+
.withLogOutput(System.out)
601+
.usingDriverExecutable(new File(geckodriverBinary))
602+
.build();
603+
604+
final FirefoxOptions options = new FirefoxOptions();
605+
options.setCapability("webSocketUrl", true);
606+
options.setBinary(binary);
607+
608+
final FirefoxProfile profile = new FirefoxProfile();
609+
profile.setPreference("intl.accept_languages", "en-US,en");
610+
options.setProfile(profile);
611+
return new FirefoxDriver(service, options);
593612
}
594613

595614
private static String getBrowserName(final BrowserVersion browserVersion) {

0 commit comments

Comments
 (0)