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

Commit 2030980

Browse files
committed
Replaced Maven plugin for webdriver download with WebdriverManager (thanks to @YauheniPo)
Suite setup to handle download in a way that tests doesn't need to be changed
1 parent 9c2c5d5 commit 2030980

File tree

5 files changed

+46
-100
lines changed

5 files changed

+46
-100
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/

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,36 @@ which contains all required libraries. Running of tests with this can be done wi
5959
[Library Specs](http://central.maven.org/maven2/com/github/hi-fi/robotframework-seleniumlibrary/3.141.59.26/robotframework-seleniumlibrary-3.141.59.26.xml)
6060
and place it in your PYTHONPATH.
6161

62+
Usage, Selenium 4 (WIP)
63+
-----------------
64+
65+
If you are using the robotframework-maven-plugin you can
66+
use this library by adding the following dependency to
67+
your pom.xml:
68+
69+
<dependency>
70+
<groupId>com.github.hi-fi</groupId>
71+
<artifactId>robotframework-seleniumlibrary</artifactId>
72+
<version>4.0.0-alpha-1.0</version>
73+
<scope>test</scope>
74+
</dependency>
75+
76+
If you cannot use the robotframework-maven-plugin you can use the
77+
[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>`.
79+
80+
* More information about this library can be found in the
81+
[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).
82+
* For keyword completion in RIDE you can download this
83+
[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)
84+
and place it in your PYTHONPATH.
85+
6286
Differences
6387
-----------
6488

6589
* 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`
90+
* Older version of the library was imported as `Library Selenium2Library` (both Java and Python versions).
91+
Since 2.53.1.1 (and later major versions) import is done as `Library SeleniumLibrary`
6792

6893

6994
Browser drivers
@@ -86,6 +111,8 @@ to know when to update drivers you use.
86111

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

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.
115+
89116
__ https://seleniumhq.github.io/selenium/docs/api/py/index.html#drivers
90117
__ https://en.wikipedia.org/wiki/PATH_(variable)
91118

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

97124
mvn integration-test
98125

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

101129
* Firefox: mvn integration-test -Pfirefox
102130
* Google Chrome: mvn integration-test -Pgooglechrome

pom.xml

Lines changed: 6 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
<selenium.version>4.0.0-alpha-1</selenium.version>
7575
<keywords.class>SeleniumLibrary</keywords.class>
7676
<browser>jbrowser</browser>
77+
<downloadWebDriver>False</downloadWebDriver>
7778
</properties>
7879

7980
<dependencies>
@@ -213,27 +214,6 @@
213214
</lifecycleMappingMetadata>
214215
</configuration>
215216
</plugin>
216-
<plugin>
217-
<groupId>com.lazerycode.selenium</groupId>
218-
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
219-
<version>1.0.16</version>
220-
<configuration>
221-
<!-- root directory that downloaded driver binaries will be stored
222-
in -->
223-
<rootStandaloneServerDirectory>webdriver/binaries</rootStandaloneServerDirectory>
224-
<!-- Where you want to store downloaded zip files -->
225-
<downloadedZipFileDirectory>webdriver/zips</downloadedZipFileDirectory>
226-
<!-- Location of a custom repository map -->
227-
<customRepositoryMap>src/test/resources/RepositoryMap.xml</customRepositoryMap>
228-
</configuration>
229-
<executions>
230-
<execution>
231-
<goals>
232-
<goal>selenium</goal>
233-
</goals>
234-
</execution>
235-
</executions>
236-
</plugin>
237217
<plugin>
238218
<!-- Integration-Test, build documentation -->
239219
<groupId>org.robotframework</groupId>
@@ -251,6 +231,7 @@
251231
<testCasesDirectory>${project.basedir}/src/test/robotframework/testsuites</testCasesDirectory>
252232
<variables>
253233
<variable>browser:${browser}</variable>
234+
<variable>downloadWebDriver:${downloadWebDriver}</variable>
254235
</variables>
255236
<report>target/robotframework-reports/${browser}_report.html</report>
256237
<log>target/robotframework-reports/${browser}_log.html</log>
@@ -394,101 +375,29 @@
394375
<id>firefox</id>
395376
<properties>
396377
<browser>firefox</browser>
378+
<downloadWebDriver>True</downloadWebDriver>
397379
</properties>
398-
<build>
399-
<plugins>
400-
<plugin>
401-
<groupId>com.lazerycode.selenium</groupId>
402-
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
403-
</plugin>
404-
<plugin>
405-
<groupId>org.robotframework</groupId>
406-
<artifactId>robotframework-maven-plugin</artifactId>
407-
<configuration>
408-
<externalRunner>
409-
<jvmArgs>
410-
<jvmArg>-Dwebdriver.gecko.driver=${webdriver.gecko.driver}</jvmArg>
411-
</jvmArgs>
412-
</externalRunner>
413-
</configuration>
414-
</plugin>
415-
</plugins>
416-
</build>
417380
</profile>
418381
<profile>
419382
<id>firefoxheadless</id>
420383
<properties>
421384
<browser>firefoxheadless</browser>
385+
<downloadWebDriver>True</downloadWebDriver>
422386
</properties>
423-
<build>
424-
<plugins>
425-
<plugin>
426-
<groupId>com.lazerycode.selenium</groupId>
427-
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
428-
</plugin>
429-
<plugin>
430-
<groupId>org.robotframework</groupId>
431-
<artifactId>robotframework-maven-plugin</artifactId>
432-
<configuration>
433-
<externalRunner>
434-
<jvmArgs>
435-
<jvmArg>-Dwebdriver.gecko.driver=${webdriver.gecko.driver}</jvmArg>
436-
</jvmArgs>
437-
</externalRunner>
438-
</configuration>
439-
</plugin>
440-
</plugins>
441-
</build>
442387
</profile>
443388
<profile>
444389
<id>googlechrome</id>
445390
<properties>
446391
<browser>googlechrome</browser>
392+
<downloadWebDriver>True</downloadWebDriver>
447393
</properties>
448-
<build>
449-
<plugins>
450-
<plugin>
451-
<groupId>com.lazerycode.selenium</groupId>
452-
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
453-
</plugin>
454-
<plugin>
455-
<groupId>org.robotframework</groupId>
456-
<artifactId>robotframework-maven-plugin</artifactId>
457-
<configuration>
458-
<externalRunner>
459-
<jvmArgs>
460-
<jvmArg>-Dwebdriver.chrome.driver=${webdriver.chrome.driver}</jvmArg>
461-
</jvmArgs>
462-
</externalRunner>
463-
</configuration>
464-
</plugin>
465-
</plugins>
466-
</build>
467394
</profile>
468395
<profile>
469396
<id>googlechromeheadless</id>
470397
<properties>
471398
<browser>googlechromeheadless</browser>
399+
<downloadWebDriver>True</downloadWebDriver>
472400
</properties>
473-
<build>
474-
<plugins>
475-
<plugin>
476-
<groupId>com.lazerycode.selenium</groupId>
477-
<artifactId>driver-binary-downloader-maven-plugin</artifactId>
478-
</plugin>
479-
<plugin>
480-
<groupId>org.robotframework</groupId>
481-
<artifactId>robotframework-maven-plugin</artifactId>
482-
<configuration>
483-
<externalRunner>
484-
<jvmArgs>
485-
<jvmArg>-Dwebdriver.chrome.driver=${webdriver.chrome.driver}</jvmArg>
486-
</jvmArgs>
487-
</externalRunner>
488-
</configuration>
489-
</plugin>
490-
</plugins>
491-
</build>
492401
</profile>
493402
<profile>
494403
<id>release</id>

src/test/robotframework/settings/Settings.robot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Library SeleniumLibrary
66
*** Variables ***
77
${Profile} Local
88
${browser} jbrowser
9+
${downloadWebDriver} ${False}
910
${Selenium.Browser.Name} ${browser}
1011
${Selenium.Browser.Version} 17
1112
${Selenium.Timeout} 30.0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*** Settings ***
2+
Resource ../../settings/Settings.robot
3+
Suite Setup Handle WebDriver
4+
5+
*** Keywords ***
6+
Handle WebDriver
7+
Run Keyword If ${downloadWebDriver} WebDriver Manager Setup ${browser}

0 commit comments

Comments
 (0)