Skip to content

Commit 891dbe5

Browse files
authored
Merge pull request #1 from Hi-Fi/develop
Update fork branch
2 parents cbe8ecb + 265e2b1 commit 891dbe5

File tree

17 files changed

+1194
-1112
lines changed

17 files changed

+1194
-1112
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.settings
33
.classpath
44
target
5-
webdriver
5+
webdriver
6+
/libspecs/

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
language: java
2+
dist: trusty
3+
24
jdk:
35
- oraclejdk8
46

57
env:
68
- PROFILE=build
7-
- PROFILE=build,googlechrome
8-
- PROFILE=build,firefox
99
- PROFILE=build,googlechromeheadless
1010
- PROFILE=build,firefoxheadless
1111

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,26 @@ 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
Differences
6363
-----------
6464

6565
* Some keyword differences between this and [Python version](https://github.com/robotframework/SeleniumLibrary) exists. (Same) keywords should be aligned in upcoming versions.
66-
* Older version of the library was imported as `Library Selenium2Library` (both Java and Python versions). Since 2.53.1.1 (and all 3.x versions) import is done as `Library SeleniumLibrary`
66+
* Older version of the library was imported as `Library Selenium2Library` (both Java and Python versions).
67+
Since 2.53.1.1 (and later major versions) import is done as `Library SeleniumLibrary`
6768

6869

6970
Browser drivers
@@ -86,6 +87,8 @@ to know when to update drivers you use.
8687

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

90+
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.
91+
8992
__ https://seleniumhq.github.io/selenium/docs/api/py/index.html#drivers
9093
__ https://en.wikipedia.org/wiki/PATH_(variable)
9194

@@ -96,7 +99,8 @@ This is a maven project. You can execute the integration tests (using [jBrowser]
9699

97100
mvn integration-test
98101

99-
Other browsers are behind profiles (require browser installation with Firefox and Google Chrome, but not driver):
102+
Other browsers are behind profiles
103+
(require browser installation with Firefox and Google Chrome, but not driver. Driver downloaded directly from Internet, so runner needs to have access to it.):
100104

101105
* Firefox: mvn integration-test -Pfirefox
102106
* Google Chrome: mvn integration-test -Pgooglechrome

pom.xml

Lines changed: 12 additions & 98 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>3.141.59.265-SNAPSHOT</version>
8+
<version>3.141.59.2653-SNAPSHOT</version>
99
<packaging>jar</packaging>
1010

1111
<name>Robot Framework :: SeleniumLibrary</name>
@@ -74,6 +74,7 @@
7474
<selenium.version>3.141.59</selenium.version>
7575
<keywords.class>SeleniumLibrary</keywords.class>
7676
<browser>jbrowser</browser>
77+
<downloadWebDriver>False</downloadWebDriver>
7778
</properties>
7879

7980
<dependencies>
@@ -134,6 +135,11 @@
134135
<version>2.18.3</version>
135136
<scope>test</scope>
136137
</dependency>
138+
<dependency>
139+
<groupId>io.github.bonigarcia</groupId>
140+
<artifactId>webdrivermanager</artifactId>
141+
<version>3.4.0</version>
142+
</dependency>
137143
</dependencies>
138144

139145
<build>
@@ -198,27 +204,6 @@
198204
</lifecycleMappingMetadata>
199205
</configuration>
200206
</plugin>
201-
<plugin>
202-
<groupId>com.lazerycode.selenium</groupId>
203-
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
204-
<version>1.0.16</version>
205-
<configuration>
206-
<!-- root directory that downloaded driver binaries will be stored
207-
in -->
208-
<rootStandaloneServerDirectory>webdriver/binaries</rootStandaloneServerDirectory>
209-
<!-- Where you want to store downloaded zip files -->
210-
<downloadedZipFileDirectory>webdriver/zips</downloadedZipFileDirectory>
211-
<!-- Location of a custom repository map -->
212-
<customRepositoryMap>src/test/resources/RepositoryMap.xml</customRepositoryMap>
213-
</configuration>
214-
<executions>
215-
<execution>
216-
<goals>
217-
<goal>selenium</goal>
218-
</goals>
219-
</execution>
220-
</executions>
221-
</plugin>
222207
<plugin>
223208
<!-- Integration-Test, build documentation -->
224209
<groupId>org.robotframework</groupId>
@@ -236,6 +221,7 @@
236221
<testCasesDirectory>${project.basedir}/src/test/robotframework/testsuites</testCasesDirectory>
237222
<variables>
238223
<variable>browser:${browser}</variable>
224+
<variable>downloadWebDriver:${downloadWebDriver}</variable>
239225
</variables>
240226
<report>target/robotframework-reports/${browser}_report.html</report>
241227
<log>target/robotframework-reports/${browser}_log.html</log>
@@ -379,101 +365,29 @@
379365
<id>firefox</id>
380366
<properties>
381367
<browser>firefox</browser>
368+
<downloadWebDriver>True</downloadWebDriver>
382369
</properties>
383-
<build>
384-
<plugins>
385-
<plugin>
386-
<groupId>com.lazerycode.selenium</groupId>
387-
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
388-
</plugin>
389-
<plugin>
390-
<groupId>org.robotframework</groupId>
391-
<artifactId>robotframework-maven-plugin</artifactId>
392-
<configuration>
393-
<externalRunner>
394-
<jvmArgs>
395-
<jvmArg>-Dwebdriver.gecko.driver=${webdriver.gecko.driver}</jvmArg>
396-
</jvmArgs>
397-
</externalRunner>
398-
</configuration>
399-
</plugin>
400-
</plugins>
401-
</build>
402370
</profile>
403371
<profile>
404372
<id>firefoxheadless</id>
405373
<properties>
406374
<browser>firefoxheadless</browser>
375+
<downloadWebDriver>True</downloadWebDriver>
407376
</properties>
408-
<build>
409-
<plugins>
410-
<plugin>
411-
<groupId>com.lazerycode.selenium</groupId>
412-
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
413-
</plugin>
414-
<plugin>
415-
<groupId>org.robotframework</groupId>
416-
<artifactId>robotframework-maven-plugin</artifactId>
417-
<configuration>
418-
<externalRunner>
419-
<jvmArgs>
420-
<jvmArg>-Dwebdriver.gecko.driver=${webdriver.gecko.driver}</jvmArg>
421-
</jvmArgs>
422-
</externalRunner>
423-
</configuration>
424-
</plugin>
425-
</plugins>
426-
</build>
427377
</profile>
428378
<profile>
429379
<id>googlechrome</id>
430380
<properties>
431381
<browser>googlechrome</browser>
382+
<downloadWebDriver>True</downloadWebDriver>
432383
</properties>
433-
<build>
434-
<plugins>
435-
<plugin>
436-
<groupId>com.lazerycode.selenium</groupId>
437-
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
438-
</plugin>
439-
<plugin>
440-
<groupId>org.robotframework</groupId>
441-
<artifactId>robotframework-maven-plugin</artifactId>
442-
<configuration>
443-
<externalRunner>
444-
<jvmArgs>
445-
<jvmArg>-Dwebdriver.chrome.driver=${webdriver.chrome.driver}</jvmArg>
446-
</jvmArgs>
447-
</externalRunner>
448-
</configuration>
449-
</plugin>
450-
</plugins>
451-
</build>
452384
</profile>
453385
<profile>
454386
<id>googlechromeheadless</id>
455387
<properties>
456388
<browser>googlechromeheadless</browser>
389+
<downloadWebDriver>True</downloadWebDriver>
457390
</properties>
458-
<build>
459-
<plugins>
460-
<plugin>
461-
<groupId>com.lazerycode.selenium</groupId>
462-
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
463-
</plugin>
464-
<plugin>
465-
<groupId>org.robotframework</groupId>
466-
<artifactId>robotframework-maven-plugin</artifactId>
467-
<configuration>
468-
<externalRunner>
469-
<jvmArgs>
470-
<jvmArg>-Dwebdriver.chrome.driver=${webdriver.chrome.driver}</jvmArg>
471-
</jvmArgs>
472-
</externalRunner>
473-
</configuration>
474-
</plugin>
475-
</plugins>
476-
</build>
477391
</profile>
478392
<profile>
479393
<id>release</id>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.github.markusbernhardt.seleniumlibrary;
2+
3+
import com.github.markusbernhardt.seleniumlibrary.keywords.BrowserManagement;
4+
import com.github.markusbernhardt.seleniumlibrary.keywords.Robot;
5+
import org.openqa.selenium.WebDriver;
6+
7+
import javax.script.ScriptEngine;
8+
import javax.script.ScriptEngineManager;
9+
import javax.script.ScriptException;
10+
import java.lang.reflect.Field;
11+
12+
/**
13+
* For extends of custom keywords of WebDriver actions
14+
*/
15+
public class CustomRobotDriverElement {
16+
17+
private static SeleniumLibrary s;
18+
private static BrowserManagement b;
19+
private Robot robot = new Robot();
20+
21+
public CustomRobotDriverElement() throws NoSuchFieldException, IllegalAccessException {
22+
try {
23+
CustomRobotDriverElement.s = getLibraryInstance();
24+
} catch (ScriptException e) {
25+
throw new SeleniumLibraryNonFatalException("Cannot create SeleniumLibrary instance.", e);
26+
}
27+
Field bmField = SeleniumLibrary.class.getDeclaredField("bm");
28+
bmField.setAccessible(true);
29+
b = (BrowserManagement) bmField.get(s);
30+
bmField.setAccessible(false);
31+
}
32+
33+
private static SeleniumLibrary getLibraryInstance() throws ScriptException {
34+
ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");
35+
engine.put("library", "SeleniumLibrary");
36+
engine.eval("from robot.libraries.BuiltIn import BuiltIn");
37+
engine.eval("instance = BuiltIn().get_library_instance(library)");
38+
return (SeleniumLibrary) engine.get("instance");
39+
}
40+
41+
protected WebDriver getCurrentBrowser() {
42+
return b.getCurrentWebDriver();
43+
}
44+
45+
protected Robot getRobot() {
46+
return robot;
47+
}
48+
49+
}

0 commit comments

Comments
 (0)