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

Commit e3e462e

Browse files
authored
Merge pull request #87 from Hi-Fi/removeExtraDependencies
Remove extra dependencies
2 parents 2030980 + 245c8fd commit e3e462e

29 files changed

+1405
-1344
lines changed

.travis.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
language: java
2-
3-
matrix:
4-
include:
5-
- os: linux
6-
- os: osx
7-
osx_image: xcode9.3
2+
dist: trusty
83

94
jdk:
105
- oraclejdk8
116

127
env:
138
- PROFILE=build
14-
- PROFILE=build,googlechrome
15-
- PROFILE=build,firefox
169
- PROFILE=build,googlechromeheadless
1710
- PROFILE=build,firefoxheadless
11+
- PROFILE=build,htmlunitwithjs
1812

1913
stages:
2014
- test
@@ -30,7 +24,6 @@ addons:
3024
before_install:
3125
- if [ ! -z "$GPG_SECRET_KEYS" ]; then echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --import; fi
3226
- if [ ! -z "$GPG_OWNERTRUST" ]; then echo $GPG_OWNERTRUST | base64 --decode | $GPG_EXECUTABLE --import-ownertrust; fi
33-
- .travis/setup_xvfb.sh
3427

3528
install: mvn --settings .travis/settings.xml verify -Dgpg.skip -B -V -P$PROFILE
3629
script: skip

.travis/setup_xvfb.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

3+
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 762E3157
34
sudo apt-get -qq update
45
sudo apt-get install -y dbus-x11
56
export DISPLAY=:99.0

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@ your pom.xml:
4545
<dependency>
4646
<groupId>com.github.hi-fi</groupId>
4747
<artifactId>robotframework-seleniumlibrary</artifactId>
48-
<version>3.141.59.26</version>
48+
<version>3.141.59.2653</version>
4949
<scope>test</scope>
5050
</dependency>
5151

5252
If you cannot use the robotframework-maven-plugin you can use the
53-
[jar-with-dependencies](http://central.maven.org/maven2/com/github/hi-fi/robotframework-seleniumlibrary/3.141.59.26/robotframework-seleniumlibrary-3.141.59.26-jar-with-dependencies.jar),
54-
which contains all required libraries. Running of tests with this can be done with command `java -jar robotframework-seleniumlibrary-3.141.59.26-jar-with-dependencies.jar <test location>`.
53+
[jar-with-dependencies](http://central.maven.org/maven2/com/github/hi-fi/robotframework-seleniumlibrary/3.141.59.2653/robotframework-seleniumlibrary-3.141.59.2653-jar-with-dependencies.jar),
54+
which contains all required libraries. Running of tests with this can be done with command `java -jar robotframework-seleniumlibrary-3.141.59.2653-jar-with-dependencies.jar <test location>`.
5555

5656
* More information about this library can be found in the
57-
[Keyword Documentation](http://central.maven.org/maven2/com/github/hi-fi/robotframework-seleniumlibrary/3.141.59.26/robotframework-seleniumlibrary-3.141.59.26.html).
57+
[Keyword Documentation](http://central.maven.org/maven2/com/github/hi-fi/robotframework-seleniumlibrary/3.141.59.2653/robotframework-seleniumlibrary-3.141.59.2653.html).
5858
* For keyword completion in RIDE you can download this
59-
[Library Specs](http://central.maven.org/maven2/com/github/hi-fi/robotframework-seleniumlibrary/3.141.59.26/robotframework-seleniumlibrary-3.141.59.26.xml)
59+
[Library Specs](http://central.maven.org/maven2/com/github/hi-fi/robotframework-seleniumlibrary/3.141.59.2653/robotframework-seleniumlibrary-3.141.59.2653.xml)
6060
and place it in your PYTHONPATH.
6161

6262
Usage, Selenium 4 (WIP)
63-
-----------------
63+
-----------------------
6464

6565
If you are using the robotframework-maven-plugin you can
6666
use this library by adding the following dependency to
@@ -75,14 +75,19 @@ your pom.xml:
7575

7676
If you cannot use the robotframework-maven-plugin you can use the
7777
[jar-with-dependencies](http://central.maven.org/maven2/com/github/hi-fi/robotframework-seleniumlibrary/4.0.0-alpha-1.0/robotframework-seleniumlibrary-4.0.0-alpha-1.0-jar-with-dependencies.jar),
78-
which contains all required libraries. Running of tests with this can be done with command `java -jar robotframework-seleniumlibrary-4.0.0-alpha-1.0-jar-with-dependencies.jar <test location>`.
78+
which contains all required libraries except ios/android ones (Appium and Selendroid). Running of tests with this can be done with command `java -jar robotframework-seleniumlibrary-4.0.0-alpha-1.0-jar-with-dependencies.jar <test location>`.
7979

8080
* More information about this library can be found in the
8181
[Keyword Documentation](http://central.maven.org/maven2/com/github/hi-fi/robotframework-seleniumlibrary/4.0.0-alpha-1.0/robotframework-seleniumlibrary-4.0.0-alpha-1.0.html).
8282
* For keyword completion in RIDE you can download this
8383
[Library Specs](http://central.maven.org/maven2/com/github/hi-fi/robotframework-seleniumlibrary/4.0.0-alpha-1.0/robotframework-seleniumlibrary-4.0.0-alpha-1.0.xml)
8484
and place it in your PYTHONPATH.
8585

86+
Testing IOS/Android browsers with library
87+
-----------------------------------------
88+
Pre-Selenium 4 fat-jar contains Appium and Selendroid that allow testing of IOS and Android browsers. Those are dropped in Selenium 4 -versions,
89+
so dependencies needs to be handles self with either Maven/Gradle or manually. If there's need to have fat-jar with those, please create issue about that.
90+
8691
Differences
8792
-----------
8893

@@ -111,7 +116,7 @@ to know when to update drivers you use.
111116

112117
Drivers can also be fetched with [https://github.com/Ardesco/selenium-standalone-server-plugin|Selenium Driver Binary Downloader plugin].
113118

114-
With Selenium 4 [https://github.com/bonigarcia/webdrivermanager|WebdriverManager] is taken to use, so handling of drivers can also be done with standalone JAR from tests itself.
119+
With At 3.141.59.265 [https://github.com/bonigarcia/webdrivermanager|WebdriverManager] is taken to use, so handling of drivers can also be done with standalone JAR from tests itself.
115120

116121
__ https://seleniumhq.github.io/selenium/docs/api/py/index.html#drivers
117122
__ https://en.wikipedia.org/wiki/PATH_(variable)

pom.xml

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.github.hi-fi</groupId>
77
<artifactId>robotframework-seleniumlibrary</artifactId>
8-
<version>4.0.0-alpha-1.0-SNAPSHOT</version>
8+
<version>4.0.0-alpha-2.0-SNAPSHOT</version>
99
<packaging>jar</packaging>
1010

1111
<name>Robot Framework :: SeleniumLibrary</name>
@@ -71,7 +71,7 @@
7171
<java.version>1.8</java.version>
7272
<robotframework.maven.plugin.version>1.5.1</robotframework.maven.plugin.version>
7373
<robotframework.version>3.1.2</robotframework.version>
74-
<selenium.version>4.0.0-alpha-1</selenium.version>
74+
<selenium.version>4.0.0-alpha-2</selenium.version>
7575
<keywords.class>SeleniumLibrary</keywords.class>
7676
<browser>jbrowser</browser>
7777
<downloadWebDriver>False</downloadWebDriver>
@@ -113,11 +113,12 @@
113113
<artifactId>selenium-java</artifactId>
114114
</exclusion>
115115
</exclusions>
116+
<scope>provided</scope>
116117
</dependency>
117118
<dependency>
118119
<groupId>io.appium</groupId>
119120
<artifactId>java-client</artifactId>
120-
<version>7.0.0</version>
121+
<version>7.2.0</version>
121122
<exclusions>
122123
<exclusion>
123124
<groupId>org.seleniumhq.selenium</groupId>
@@ -128,6 +129,7 @@
128129
<artifactId>selenium-api</artifactId>
129130
</exclusion>
130131
</exclusions>
132+
<scope>provided</scope>
131133
</dependency>
132134
<dependency>
133135
<groupId>org.apache.commons</groupId>
@@ -137,7 +139,36 @@
137139
<dependency>
138140
<groupId>com.machinepublishers</groupId>
139141
<artifactId>jbrowserdriver</artifactId>
140-
<version>1.1.0-RC1</version>
142+
<version>1.1.0-RC2</version>
143+
<exclusions>
144+
<exclusion>
145+
<groupId>org.seleniumhq.selenium</groupId>
146+
<artifactId>selenium-remote-driver</artifactId>
147+
</exclusion>
148+
<exclusion>
149+
<groupId>org.seleniumhq.selenium</groupId>
150+
<artifactId>selenium-api</artifactId>
151+
</exclusion>
152+
</exclusions>
153+
</dependency>
154+
<dependency>
155+
<groupId>org.seleniumhq.selenium</groupId>
156+
<artifactId>htmlunit-driver</artifactId>
157+
<version>2.36.0</version>
158+
<exclusions>
159+
<exclusion>
160+
<groupId>org.seleniumhq.selenium</groupId>
161+
<artifactId>selenium-remote-driver</artifactId>
162+
</exclusion>
163+
<exclusion>
164+
<groupId>org.seleniumhq.selenium</groupId>
165+
<artifactId>selenium-api</artifactId>
166+
</exclusion>
167+
<exclusion>
168+
<groupId>org.seleniumhq.selenium</groupId>
169+
<artifactId>selenium-support</artifactId>
170+
</exclusion>
171+
</exclusions>
141172
</dependency>
142173
<dependency>
143174
<groupId>org.mockito</groupId>
@@ -148,7 +179,7 @@
148179
<dependency>
149180
<groupId>io.github.bonigarcia</groupId>
150181
<artifactId>webdrivermanager</artifactId>
151-
<version>3.4.0</version>
182+
<version>3.6.2</version>
152183
</dependency>
153184
</dependencies>
154185

@@ -288,7 +319,7 @@
288319
<!-- Weave the failure handler into the code -->
289320
<groupId>org.codehaus.mojo</groupId>
290321
<artifactId>aspectj-maven-plugin</artifactId>
291-
<version>1.10</version>
322+
<version>1.11</version>
292323
<executions>
293324
<execution>
294325
<goals>
@@ -318,7 +349,7 @@
318349
<!-- Set 1.7 as target, use project source encoding -->
319350
<groupId>org.apache.maven.plugins</groupId>
320351
<artifactId>maven-compiler-plugin</artifactId>
321-
<version>3.7.0</version>
352+
<version>3.8.0</version>
322353
<configuration>
323354
<source>${java.version}</source>
324355
<target>${java.version}</target>
@@ -346,7 +377,7 @@
346377
<!-- Build the fat jar with all dependencies -->
347378
<groupId>org.apache.maven.plugins</groupId>
348379
<artifactId>maven-assembly-plugin</artifactId>
349-
<version>2.6</version>
380+
<version>3.1.0</version>
350381
<configuration>
351382
<archive>
352383
<manifest>
@@ -371,6 +402,13 @@
371402
</plugins>
372403
</build>
373404
</profile>
405+
<profile>
406+
<id>htmlunitwithjs</id>
407+
<properties>
408+
<browser>htmlunitwithjs</browser>
409+
<downloadWebDriver>False</downloadWebDriver>
410+
</properties>
411+
</profile>
374412
<profile>
375413
<id>firefox</id>
376414
<properties>
@@ -432,7 +470,7 @@
432470
<plugin>
433471
<groupId>org.codehaus.mojo</groupId>
434472
<artifactId>build-helper-maven-plugin</artifactId>
435-
<version>1.10</version>
473+
<version>3.0.0</version>
436474
<executions>
437475
<execution>
438476
<id>attach-artifacts</id>

src/main/java/com/github/markusbernhardt/seleniumlibrary/CustomRobotDriverElement.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.markusbernhardt.seleniumlibrary;
22

33
import com.github.markusbernhardt.seleniumlibrary.keywords.BrowserManagement;
4+
import com.github.markusbernhardt.seleniumlibrary.keywords.Logging;
45
import com.github.markusbernhardt.seleniumlibrary.keywords.Robot;
56
import org.openqa.selenium.WebDriver;
67

@@ -16,7 +17,8 @@ public class CustomRobotDriverElement {
1617

1718
private static SeleniumLibrary s;
1819
private static BrowserManagement b;
19-
private Robot robot = new Robot();
20+
protected Robot robot = new Robot();
21+
protected Logging logging = new Logging();
2022

2123
public CustomRobotDriverElement() throws NoSuchFieldException, IllegalAccessException {
2224
try {
@@ -41,9 +43,4 @@ private static SeleniumLibrary getLibraryInstance() throws ScriptException {
4143
protected WebDriver getCurrentBrowser() {
4244
return b.getCurrentWebDriver();
4345
}
44-
45-
protected Robot getRobot() {
46-
return robot;
47-
}
48-
4946
}

src/main/java/com/github/markusbernhardt/seleniumlibrary/SeleniumLibrary.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public SeleniumLibrary(String timeout, String implicitWait, String keywordToRunO
6363
if (!screenshotPath.isEmpty()) {
6464
screenshot.setScreenshotDirectory(screenshotPath);
6565
}
66-
6766
}
6867

6968
// ##############################
@@ -79,7 +78,6 @@ public SeleniumLibrary(String timeout, String implicitWait, String keywordToRunO
7978
@Autowired
8079
Screenshot screenshot;
8180

82-
8381
@Override
8482
public String getKeywordDocumentation(String keywordName) {
8583
if (keywordName.equals("__intro__")) {
@@ -185,6 +183,5 @@ public String getKeywordDocumentation(String keywordName) {
185183
}
186184
}
187185
return keywordName;
188-
189186
}
190187
}

src/main/java/com/github/markusbernhardt/seleniumlibrary/keywords/BrowserManagement.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.openqa.selenium.firefox.FirefoxDriver;
4040
import org.openqa.selenium.firefox.FirefoxOptions;
4141
import org.openqa.selenium.firefox.FirefoxProfile;
42+
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
4243
import org.openqa.selenium.ie.InternetExplorerDriver;
4344
import org.openqa.selenium.ie.InternetExplorerOptions;
4445
import org.openqa.selenium.remote.Augmenter;
@@ -165,7 +166,9 @@ public void closeBrowser() {
165166
"| Safari | safari |\r\n" +
166167
"| Android | android |\r\n" +
167168
"| Iphone | iphone |\r\n" +
168-
"| JBrowser | jbrowser |\r\n" +
169+
"| JBrowser | jbrowser |\r\n" +
170+
"| HTMLUnit | htmlunit |\r\n" +
171+
"| HTMLUnit with Javascript | htmlunitwithjs |\r\n" +
169172
"\r\n" +
170173
"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" +
171174
"\r\n" +
@@ -672,6 +675,12 @@ protected WebDriver createLocalWebDriver(String browserName, Capabilities desire
672675
} catch (Exception e) {
673676
throw new SeleniumLibraryFatalException("Creating " + browserName + " instance failed.", e);
674677
}
678+
case "htmlunit":
679+
return new HtmlUnitDriver(desiredCapabilities);
680+
case "htmlunitwithjs":
681+
HtmlUnitDriver driver = new HtmlUnitDriver(desiredCapabilities);
682+
driver.setJavascriptEnabled(true);
683+
return driver;
675684
default:
676685
throw new SeleniumLibraryFatalException(browserName + " is not a supported browser.");
677686
}
@@ -761,6 +770,11 @@ protected Capabilities createCapabilities(String browserName, String desiredCapa
761770
case "jbrowser":
762771
desiredCapabilities = new DesiredCapabilities("jbrowser", "1", Platform.ANY);
763772
break;
773+
case "htmlunit":
774+
case "htmlunitwithjs":
775+
desiredCapabilities = DesiredCapabilities.htmlUnit();
776+
((DesiredCapabilities) desiredCapabilities).setBrowserName("htmlunit");
777+
break;
764778
default:
765779
throw new SeleniumLibraryFatalException(browserName + " is not a supported browser.");
766780
}

src/main/java/com/github/markusbernhardt/seleniumlibrary/keywords/Cookie.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ public void deleteCookie(String name) {
4242

4343
@RobotKeyword("Returns all cookies of the current page.")
4444
public String getCookies() {
45-
StringBuffer ret = new StringBuffer();
45+
StringBuilder ret = new StringBuilder();
4646

47-
ArrayList<org.openqa.selenium.Cookie> cookies = new ArrayList<org.openqa.selenium.Cookie>(browserManagement
47+
ArrayList<org.openqa.selenium.Cookie> cookies = new ArrayList<>(browserManagement
4848
.getCurrentWebDriver().manage().getCookies());
4949
for (int i = 0; i < cookies.size(); i++) {
50-
ret.append(cookies.get(i).getName() + "=" + cookies.get(i).getValue());
50+
ret.append(cookies.get(i).getName()).append('=').append(cookies.get(i).getValue());
5151
if (i != cookies.size() - 1) {
5252
ret.append("; ");
5353
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.github.markusbernhardt.seleniumlibrary.keywords;
2+
3+
import com.github.markusbernhardt.seleniumlibrary.RunOnFailureKeywordsAdapter;
4+
import org.robotframework.javalib.annotation.ArgumentNames;
5+
import org.robotframework.javalib.annotation.Autowired;
6+
import org.robotframework.javalib.annotation.RobotKeyword;
7+
import org.robotframework.javalib.annotation.RobotKeywords;
8+
9+
import java.util.ArrayList;
10+
import java.util.Collections;
11+
import java.util.List;
12+
import java.util.Locale;
13+
14+
@RobotKeywords
15+
public class DataUtils extends RunOnFailureKeywordsAdapter {
16+
17+
private static final String ASCENDING = "ascending";
18+
private static final String DESCENDING = "descending";
19+
20+
@Autowired
21+
protected Robot robot;
22+
23+
/**
24+
* Instantiated Logging keyword bean
25+
*/
26+
@Autowired
27+
protected Logging logging;
28+
29+
// ##############################
30+
// Keywords
31+
// ##############################
32+
33+
/**
34+
* Sort list of strings.
35+
*
36+
* @param jsonStringOfList json string of list strings
37+
* @param params sorting order
38+
* @return sorting list of strings
39+
*/
40+
@RobotKeyword("Returns sorting list of strings by ``order``.")
41+
@ArgumentNames({"list", "order=ascending"})
42+
public List<String> sortStrings(String jsonStringOfList, String... params) {
43+
List<String> listOfStrings = robot.parseRobotList(jsonStringOfList);
44+
String order = robot.getParamsValue(params, 0, ASCENDING);
45+
List<String> sortedList = new ArrayList<>(listOfStrings);
46+
if (order.equalsIgnoreCase(DESCENDING)) {
47+
listOfStrings.sort(Collections.reverseOrder());
48+
} else {
49+
Collections.sort(listOfStrings);
50+
}
51+
logging.info(String.format("Sorted list '%s' by %s", sortedList, order.toUpperCase(Locale.ENGLISH)));
52+
return sortedList;
53+
}
54+
}

0 commit comments

Comments
 (0)