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

Commit 006f979

Browse files
committed
Merge branch 'develop' of github.com:Hi-Fi/robotframework-seleniumlibrary-java into removeExtraDependencies
2 parents 43198b7 + 6b85626 commit 006f979

21 files changed

+1333
-1320
lines changed

.travis.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
language: java
22
dist: trusty
33

4-
matrix:
5-
include:
6-
- os: linux
7-
- os: osx
8-
osx_image: xcode9.3
9-
104
jdk:
115
- oraclejdk8
126

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ 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.265</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.265/robotframework-seleniumlibrary-3.141.59.265-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.265-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.265/robotframework-seleniumlibrary-3.141.59.265.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.265/robotframework-seleniumlibrary-3.141.59.265.xml)
6060
and place it in your PYTHONPATH.
6161

6262
Usage, Selenium 4 (WIP)
@@ -116,7 +116,11 @@ to know when to update drivers you use.
116116

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

119+
<<<<<<< HEAD
119120
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.
121+
=======
122+
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.
123+
>>>>>>> 6b856261db4247ab771ecfafe4912c36a508aef1
120124
121125
__ https://seleniumhq.github.io/selenium/docs/api/py/index.html#drivers
122126
__ https://en.wikipedia.org/wiki/PATH_(variable)

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/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)