Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Added HTMLUnit support back #86

Merged
merged 1 commit into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
- PROFILE=build,firefox
- PROFILE=build,googlechromeheadless
- PROFILE=build,firefoxheadless
- PROFILE=build,htmlunitwithjs

stages:
- test
Expand Down
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@
<artifactId>jbrowserdriver</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.35.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down Expand Up @@ -361,6 +366,13 @@
</plugins>
</build>
</profile>
<profile>
<id>htmlunitwithjs</id>
<properties>
<browser>htmlunitwithjs</browser>
<downloadWebDriver>False</downloadWebDriver>
</properties>
</profile>
<profile>
<id>firefox</id>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerOptions;
import org.openqa.selenium.opera.OperaDriver;
Expand Down Expand Up @@ -168,7 +169,9 @@ public void closeBrowser() {
"| Opera | opera |\r\n" +
"| Android | android |\r\n" +
"| Iphone | iphone |\r\n" +
"| JBrowser | jbrowser |\r\n" +
"| JBrowser | jbrowser |\r\n" +
"| HTMLUnit | htmlunit |\r\n" +
"| HTMLUnit with Javascript | htmlunitwithjs |\r\n" +
"\r\n" +
"To be able to actually use one of these browsers, you need to have a matching Selenium browser driver available. See the [https://github.com/Hi-Fi/robotframework-seleniumlibrary-java#browser-drivers|project documentation] for more details.\r\n" +
"\r\n" +
Expand Down Expand Up @@ -677,6 +680,12 @@ protected WebDriver createLocalWebDriver(String browserName, Capabilities desire
} catch (Exception e) {
throw new SeleniumLibraryFatalException("Creating " + browserName + " instance failed.", e);
}
case "htmlunit":
return new HtmlUnitDriver(desiredCapabilities);
case "htmlunitwithjs":
HtmlUnitDriver driver = new HtmlUnitDriver(desiredCapabilities);
driver.setJavascriptEnabled(true);
return driver;
default:
throw new SeleniumLibraryFatalException(browserName + " is not a supported browser.");
}
Expand Down Expand Up @@ -769,6 +778,11 @@ protected Capabilities createCapabilities(String browserName, String desiredCapa
case "jbrowser":
desiredCapabilities = new DesiredCapabilities("jbrowser", "1", Platform.ANY);
break;
case "htmlunit":
case "htmlunitwithjs":
desiredCapabilities = DesiredCapabilities.htmlUnit();
((DesiredCapabilities) desiredCapabilities).setBrowserName("htmlunit");
break;
default:
throw new SeleniumLibraryFatalException(browserName + " is not a supported browser.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void runOnFailure() {
if(runOnFailurePythonInterpreter.get().eval("EXECUTION_CONTEXTS.current").toString().equals("None")) {
return;
}
runningOnFailureRoutine = true;

try {
runOnFailurePythonInterpreter.get().exec(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public void testCreateDesiredCapabilitiesWithOnlyBrowserOptions() {
assertTrue(profile.getStringPreference("network.proxy.http", "wrong") != "wrong");
}

@Test
public void testCreateDesiredCapabilitiesForHtmlUnit() {
Capabilities dc = bm.createCapabilities("htmlunitwithjs", null, "");
assertTrue(dc.getBrowserName().equals("htmlunit"));
}

@Test
public void parseChromeBrowserOptions() {
ChromeOptions chromeOptions = new ChromeOptions();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
*** Settings ***
Suite Teardown Close All Browsers
Resource ../../settings/Settings.robot
Default Tags htmlunitwith htmlunitwithjs

*** Variables ***
${URL Application} http://www.w3schools.com

*** Test Cases ***
Select
[Tags] jbrowser
Open Browser https://developer.mozilla.org/en/docs/Web/HTML/Element/select#Examples ${browser} mainbrowser
Wait Until Page Contains Element xpath://select
Select From List xpath://select Third Value
Expand Down
1 change: 0 additions & 1 deletion src/test/robotframework/testsuites/UnitTests/ExtJS.robot
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Suite Setup Open Page
Suite Teardown Close Browser
Resource ../../settings/Settings.robot
Default Tags jbrowser

*** Variables ***
${URL Application} http://examples.sencha.com/extjs/6.5.0/examples/classic/ticket-app/index.html
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*** Settings ***
Resource ../../settings/Settings.robot
Default Tags jbrowser

*** Test Cases ***
Get Inner Element Id test
Expand Down