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

Commit d0696f3

Browse files
committed
Merge branch 'master' of github.com:Hi-Fi/robotframework-seleniumlibrary-java into release/3.8.1.1
2 parents 95dd0dc + 7f76950 commit d0696f3

File tree

4 files changed

+203
-180
lines changed

4 files changed

+203
-180
lines changed

README.md

Lines changed: 4 additions & 4 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.7.1.1</version>
48+
<version>3.8.1.1</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://search.maven.org/remotecontent?filepath=com/github/hi-fi/robotframework-seleniumlibrary/3.7.1.1/robotframework-seleniumlibrary-3.7.1.1-jar-with-dependencies.jar),
53+
[jar-with-dependencies](http://search.maven.org/remotecontent?filepath=com/github/hi-fi/robotframework-seleniumlibrary/3.8.1.1/robotframework-seleniumlibrary-3.8.1.1-jar-with-dependencies.jar),
5454
which contains all required libraries.
5555

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

6262
Differences

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.github.hi-fi</groupId>
66
<artifactId>robotframework-seleniumlibrary</artifactId>
7-
<version>3.8.1.0</version>
7+
<version>3.8.1.1-SNAPSHOT</version>
88
<packaging>jar</packaging>
99

1010
<name>Robot Framework :: SeleniumLibrary</name>

src/main/java/SeleniumLibrary.java

Lines changed: 8 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -1,188 +1,21 @@
1-
import java.io.File;
2-
import java.util.ResourceBundle;
3-
4-
import org.robotframework.javalib.annotation.Autowired;
5-
import org.robotframework.javalib.library.AnnotationLibrary;
6-
7-
import com.github.markusbernhardt.seleniumlibrary.keywords.BrowserManagement;
8-
import com.github.markusbernhardt.seleniumlibrary.keywords.RunOnFailure;
9-
import com.github.markusbernhardt.seleniumlibrary.keywords.Screenshot;
10-
11-
public class SeleniumLibrary extends AnnotationLibrary {
12-
13-
/**
14-
* The list of keyword patterns for the AnnotationLibrary
15-
*/
16-
public static final String KEYWORD_PATTERN = "com/github/markusbernhardt/seleniumlibrary/keywords/**/*.class";
17-
18-
/**
19-
* The scope of this library is global.
20-
*/
21-
public static final String ROBOT_LIBRARY_SCOPE = "GLOBAL";
22-
23-
/**
24-
* The actual version of this library. Loaded from maven project.
25-
*/
26-
public static final String ROBOT_LIBRARY_VERSION = loadRobotLibraryVersion();
27-
28-
private static String loadRobotLibraryVersion() {
29-
try {
30-
return ResourceBundle.getBundle(SeleniumLibrary.class.getCanonicalName().replace(".", File.separator))
31-
.getString("version");
32-
} catch (RuntimeException e) {
33-
return "unknown";
34-
}
35-
}
36-
37-
public SeleniumLibrary() {
38-
this("5.0");
1+
public class SeleniumLibrary extends com.github.markusbernhardt.seleniumlibrary.SeleniumLibrary {
2+
public SeleniumLibrary() {
3+
super("5.0");
394
}
405

416
public SeleniumLibrary(String timeout) {
42-
this(timeout, "0.0");
7+
super(timeout);
438
}
449

4510
public SeleniumLibrary(String timeout, String implicitWait) {
46-
this(timeout, implicitWait, "Capture Page Screenshot");
11+
super(timeout, implicitWait);
4712
}
4813

4914
public SeleniumLibrary(String timeout, String implicitWait, String keywordToRunOnFailure) {
50-
this(timeout, implicitWait, "Capture Page Screenshot", "");
15+
super(timeout, implicitWait, keywordToRunOnFailure);
5116
}
5217

5318
public SeleniumLibrary(String timeout, String implicitWait, String keywordToRunOnFailure, String screenshotPath) {
54-
super();
55-
addKeywordPattern(KEYWORD_PATTERN);
56-
//Enable annotations
57-
createKeywordFactory();
58-
bm.setSeleniumTimeout(timeout);
59-
bm.setSeleniumImplicitWait(implicitWait);
60-
rof.registerKeywordToRunOnFailure(keywordToRunOnFailure);
61-
if (!screenshotPath.isEmpty()) {
62-
screenshot.setScreenshotDirectory(screenshotPath);
63-
}
64-
65-
}
66-
67-
// ##############################
68-
// Autowired References
69-
// ##############################
70-
71-
@Autowired
72-
BrowserManagement bm;
73-
74-
@Autowired
75-
RunOnFailure rof;
76-
77-
@Autowired
78-
Screenshot screenshot;
79-
80-
81-
@Override
82-
public String getKeywordDocumentation(String keywordName) {
83-
if (keywordName.equals("__intro__")) {
84-
return "SeleniumLibrary is a web testing library for the Robot Framework and was originally written in Python. This is the Java port of the SeleniumLibrary for Robot Framework (https://github.com/robotframework/SeleniumLibrary). It uses the Selenium libraries internally to control a web browser. See [http://seleniumhq.org/docs/03_webdriver.html|WebDriver] for more information on Selenium (2) and WebDriver. It runs tests in a real browser instance and should work with most modern browsers and can be used with the Jython interpreter or any other Java application.\r\n" +
85-
"\r\n" +
86-
"== Before running tests ==\r\n" +
87-
"\r\n" +
88-
"Prior to running test cases using SeleniumLibrary, the library must be imported into your Robot Framework test suite (see importing section), and the `Open Browser` keyword must be used to open a browser to the desired location.\r\n" +
89-
"\r\n" +
90-
"= Locating elements =\r\n" +
91-
"\r\n" +
92-
"All keywords in SeleniumLibrary that need to find an element on the page take an locator argument.\r\n" +
93-
"\r\n" +
94-
"== Key attributes ==\r\n" +
95-
"\r\n" +
96-
"By default, when a locator value is provided, it is matched against the key attributes of the particular element type. The attributes ``id`` and ``name`` are key attributes to all elements.\r\n" +
97-
"\r\n" +
98-
"List of key attributes:\r\n" +
99-
"\r\n" +
100-
" | = Element Type = | = Key Attributes = | \r\n" +
101-
" | A | @id,@name,@href,text | \r\n" +
102-
" | IMG | @id,@name,@src,@alt | \r\n" +
103-
" | INPUT | @id,@name,@value,@src | \r\n" +
104-
" | BUTTON | @id,@name,@value,text | \r\n" +
105-
" | * | @id,@name | \r\n" +
106-
" \r\n" +
107-
"Example:\r\n" +
108-
" | Click Element | my_element |\r\n" +
109-
"\r\n" +
110-
"== Locator strategies ==\r\n" +
111-
"\r\n" +
112-
"It is also possible to specify the approach SeleniumLibrary should take to find an element by specifying a locator strategy with a locator prefix.\r\n" +
113-
"\r\n" +
114-
"Supported strategies are:\r\n" +
115-
"\r\n" +
116-
" | = Strategy = | = Example = | = Description = | \r\n" +
117-
" | identifier | Click Element | identifier=my_element | Matches by @id or @name attribute | \r\n" +
118-
" | id | Click Element | id=my_element | Matches by @id attribute | \r\n" +
119-
" | name | Click Element | name=my_element | Matches by @name attribute | \r\n" +
120-
" | xpath | Click Element | xpath=//div[@id='my_element'] | Matches by arbitrary XPath expression | \r\n" +
121-
" | dom | Click Element | dom=document.images[56] | Matches by arbitrary DOM expression | \r\n" +
122-
" | link | Click Element | link=My Link | Matches by the link text | \r\n" +
123-
" | css | Click Element | css=div.my_class | Matches by CSS selector | \r\n" +
124-
" | jquery | Click Element | jquery=div.my_class | Matches by jQuery/sizzle selector | \r\n" +
125-
" | sizzle | Click Element | sizzle=div.my_class | Matches by jQuery/sizzle selector | \r\n" +
126-
" | tag | Click Element | tag=div | Matches by HTML tag name | \r\n" +
127-
" \r\n" +
128-
"== Locating tables ==\r\n" +
129-
"\r\n" +
130-
"Table related keywords, such as `Table Should Contain`, work differently. By default, when a table locator value is provided, it will search for a table with the specified id attribute.\r\n" +
131-
"\r\n" +
132-
"Example:\r\n" +
133-
"\r\n" +
134-
" | Table Should Contain | my_table | text | \r\n" +
135-
" \r\n" +
136-
"More complex table locator strategies:\r\n" +
137-
"\r\n" +
138-
" | = Strategy = | = Example = | = Description = | \r\n" +
139-
" | xpath | Table Should Contain | xpath=//table/[@name=\"my_table\"] | text | Matches by arbitrary XPath expression | \r\n" +
140-
" | css | Table Should Contain | css=table.my_class | text | Matches by CSS selector | \r\n" +
141-
"\r\n" +
142-
"== Custom location strategies ==\r\n" +
143-
"\r\n" +
144-
"It is also possible to register custom location strategies. See `Add Location Strategy` for details about custom location strategies.<br>\r\n" +
145-
"\r\n" +
146-
"Example:\r\n" +
147-
"\r\n" +
148-
" | Add Location Strategy | custom | return window.document.getElementById(arguments[0]); | \r\n" +
149-
" | Input Text | custom=firstName | Max | \r\n" +
150-
" \r\n" +
151-
"= Timeouts =\r\n" +
152-
"\r\n" +
153-
"There are several Wait ... keywords that take ``timeout`` as an argument. All of these timeout arguments are optional. The timeout used by all of them can be set globally using the `Set Selenium Timeout keyword`.\r\n" +
154-
"\r\n" +
155-
"All timeouts can be given as numbers considered seconds (e.g. ``0.5`` or ``42``) or in Robot Framework's time syntax (e.g. ``1.5 seconds`` or ``1 min 30 s``). See [http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#time-format|Robot Framework User Guide] for details about the time syntax.\r\n" +
156-
"\r\n" +
157-
"== Log Level ==\r\n" +
158-
"There are several keywords that take ``log level`` as an argument. All of these log level arguments are optional. The default is usually INFO.\r\n" +
159-
"\r\n" +
160-
" | = Log Level = | = Description = | \r\n" +
161-
" | DEBUG | | \r\n" +
162-
" | INFO | | \r\n" +
163-
" | HTML | Same as INFO, but message is in HTML format | \r\n" +
164-
" | TRACE | | \r\n" +
165-
" | WARN | | ";
166-
} else if (keywordName.equals("__init__")) {
167-
return "SeleniumLibrary can be imported with several optional arguments.\r\n" +
168-
" - ``timeout``:\r\n" +
169-
" Default value for `timeouts` used with ``Wait ...`` keywords.\r\n" +
170-
" - ``implicit_wait``:\r\n" +
171-
" Default value for `implicit wait` used when locating elements.\r\n" +
172-
" - ``run_on_failure``:\r\n" +
173-
" Default action for the `run-on-failure functionality`.\r\n" +
174-
" - ``screenshot_root_directory``:\r\n" +
175-
" Location where possible screenshots are created. If not given,\r\n" +
176-
" the directory where the log file is written is used.";
177-
} else {
178-
try {
179-
return super.getKeywordDocumentation(keywordName);
180-
}
181-
catch (Exception e) {
182-
System.out.println(keywordName);
183-
}
184-
}
185-
return keywordName;
186-
187-
}
19+
super(timeout, implicitWait, keywordToRunOnFailure, screenshotPath);
20+
}
18821
}

0 commit comments

Comments
 (0)