Skip to content

Commit 2f721ca

Browse files
Merge pull request #74 from Hi-Fi/RF29
Compatible with Robot Framework 2.9 -series with updated dependencies
2 parents 2f7ad9e + 8809cec commit 2f721ca

File tree

7 files changed

+34
-30
lines changed

7 files changed

+34
-30
lines changed

pom.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<aspectj.version>1.7.3</aspectj.version>
2424
<java.version>1.6</java.version>
2525
<xml.doclet.version>1.0.4</xml.doclet.version>
26-
<robotframework.version>2.8.3</robotframework.version>
26+
<robotframework.version>2.9.2</robotframework.version>
2727
<keywords.class>Selenium2Library</keywords.class>
2828
</properties>
2929

@@ -52,7 +52,7 @@
5252
<dependency>
5353
<groupId>org.robotframework</groupId>
5454
<artifactId>javalib-core</artifactId>
55-
<version>1.2</version>
55+
<version>1.2.1</version>
5656
</dependency>
5757
<dependency>
5858
<groupId>com.github.markusbernhardt</groupId>
@@ -62,7 +62,7 @@
6262
<dependency>
6363
<groupId>org.seleniumhq.selenium</groupId>
6464
<artifactId>selenium-server</artifactId>
65-
<version>2.43.1</version>
65+
<version>2.47.1</version>
6666
</dependency>
6767
<dependency>
6868
<groupId>com.opera</groupId>
@@ -92,7 +92,7 @@
9292
<dependency>
9393
<groupId>org.seleniumhq.selenium</groupId>
9494
<artifactId>selenium-remote-driver</artifactId>
95-
<version>2.43.1</version>
95+
<version>2.47.1</version>
9696
</dependency>
9797
<dependency>
9898
<groupId>io.selendroid</groupId>
@@ -104,6 +104,11 @@
104104
<artifactId>java-client</artifactId>
105105
<version>2.0.0</version>
106106
</dependency>
107+
<dependency>
108+
<groupId>org.apache.commons</groupId>
109+
<artifactId>commons-exec</artifactId>
110+
<version>1.3</version>
111+
</dependency>
107112
</dependencies>
108113

109114
<build>
@@ -157,7 +162,7 @@
157162
<!-- Integration-Test, build documentation -->
158163
<groupId>org.robotframework</groupId>
159164
<artifactId>robotframework-maven-plugin</artifactId>
160-
<version>1.2</version>
165+
<version>1.4.5</version>
161166
<executions>
162167
<execution>
163168
<id>test</id>

src/main/java/com/github/markusbernhardt/selenium2library/Selenium2Library.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,13 @@ public Selenium2Library(String timeout, String implicitWait) {
360360
* Default=Capture Page Screenshot. Optional custom keyword to
361361
* run on failure.
362362
*/
363-
public Selenium2Library(String timeout, String implicitWait, String runOnFailure) {
363+
public Selenium2Library(String timeout, String implicitWait, String keywordToRunOnFailure) {
364364
super();
365365
addKeywordPattern(KEYWORD_PATTERN);
366366
createKeywordFactory(); // => init annotations
367367
browserManagement.setSeleniumTimeout(timeout);
368368
browserManagement.setSeleniumImplicitWait(implicitWait);
369-
this.runOnFailure.registerKeywordToRunOnFailure(runOnFailure);
369+
runOnFailure.registerKeywordToRunOnFailure(keywordToRunOnFailure);
370370
}
371371

372372
// ##############################

src/main/java/com/github/markusbernhardt/selenium2library/keywords/Logging.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,13 @@ protected void log0(String msg, String methodName, String methodArguments) {
365365
}
366366

367367
protected File getLogDir() {
368-
if (logDir == null) {
369-
PyString logDirName = (PyString) loggingPythonInterpreter.get().eval("GLOBAL_VARIABLES['${LOG FILE}']");
368+
369+
if (logDir == null && !loggingPythonInterpreter.get().eval("EXECUTION_CONTEXTS.current").toString().equals("None")) {
370+
PyString logDirName = (PyString) loggingPythonInterpreter.get().eval("BuiltIn().get_variables()['${LOG FILE}']");
370371
if (logDirName != null && !(logDirName.asString().toUpperCase().equals("NONE"))) {
371372
return new File(logDirName.asString()).getParentFile();
372373
}
373-
logDirName = (PyString) loggingPythonInterpreter.get().eval("GLOBAL_VARIABLES['${OUTPUTDIR}']");
374+
logDirName = (PyString) loggingPythonInterpreter.get().eval("BuiltIn().get_variables()['${OUTPUTDIR}']");
374375
return new File(logDirName.asString()).getParentFile();
375376
} else {
376377
return new File(logDir);
@@ -386,7 +387,7 @@ public static void setLogDir(String logDirectory) {
386387
@Override
387388
protected PythonInterpreter initialValue() {
388389
PythonInterpreter pythonInterpreter = new PythonInterpreter();
389-
pythonInterpreter.exec("from robot.variables import GLOBAL_VARIABLES; from robot.api import logger;");
390+
pythonInterpreter.exec("from robot.libraries.BuiltIn import BuiltIn; from robot.running.context import EXECUTION_CONTEXTS; from robot.api import logger;");
390391
return pythonInterpreter;
391392
}
392393
};

src/main/java/com/github/markusbernhardt/selenium2library/keywords/RunOnFailure.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public String registerKeywordToRunOnFailure(String keyword) {
9999
@Override
100100
protected PythonInterpreter initialValue() {
101101
PythonInterpreter pythonInterpreter = new PythonInterpreter();
102-
pythonInterpreter.exec("from robot.libraries import BuiltIn; BUILTIN = BuiltIn.BuiltIn();");
102+
pythonInterpreter.exec("from robot.libraries.BuiltIn import BuiltIn; from robot.running.context import EXECUTION_CONTEXTS; BIN = BuiltIn();");
103103
return pythonInterpreter;
104104
}
105105
};
@@ -111,10 +111,13 @@ public void runOnFailure() {
111111
if (runningOnFailureRoutine) {
112112
return;
113113
}
114-
runningOnFailureRoutine = true;
114+
if(runOnFailurePythonInterpreter.get().eval("EXECUTION_CONTEXTS.current").toString().equals("None")) {
115+
return;
116+
}
117+
115118
try {
116119
runOnFailurePythonInterpreter.get().exec(
117-
String.format("BUILTIN.run_keyword('%s')",
120+
String.format("BIN.run_keyword('%s')",
118121
runOnFailureKeyword.replace("'", "\\'").replace("\n", "\\n")));
119122
} catch (RuntimeException r) {
120123
logging.warn(String.format("Keyword '%s' could not be run on failure%s", runOnFailureKeyword,

src/main/java/com/github/markusbernhardt/selenium2library/locators/ElementFinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public static List<WebElement> find(WebDriver webDriver, String locator, String
261261
@Override
262262
protected PythonInterpreter initialValue() {
263263
PythonInterpreter pythonInterpreter = new PythonInterpreter();
264-
pythonInterpreter.exec("from robot.variables import GLOBAL_VARIABLES; from robot.api import logger;");
264+
pythonInterpreter.exec("from robot.libraries.BuiltIn import BuiltIn; from robot.api import logger;");
265265
return pythonInterpreter;
266266
}
267267
};

src/test/robotframework/objects/Google.Search.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Documentation Defines all required resources and keywords
44
Resource ../adapters/Selenium2Library.txt
55

66
*** Variables ***
7-
${Google.Search.Locator.SearchField} id=gbqfq
7+
${Google.Search.Locator.SearchField} id=lst-ib
88
${Google.Search.Locator.SearchResult.Rtomac} xpath=//a[contains(.,'MarkusBernhardt')]
99

1010
*** Keywords ***

src/test/robotframework/testsuites/UnitTests/Google.txt

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,29 @@ Open And Close Google Site
1010
Capture Page Screenshot
1111

1212
Store Web Element In JavaScript
13-
Execute Javascript window.document.my_element = window.document.getElementsByClassName('gbqfba')[0];
13+
Execute Javascript window.document.my_element = window.document.getElementsByClassName('gsfi')[0];
1414
${className}= Execute Javascript return window.document.my_element.className;
15-
Should Be Equal ${className} gbqfba
15+
Should Contain ${className} gsfi
1616

1717
Search Robotframework Selenium2Library
1818
Google.Search.Search String Robotframework Selenium2Library Java
1919

2020
Search With JavaScript Locator
2121
Selenium2Library.Add Location Strategy elementById return window.document.getElementById(arguments[0]);
22-
Input Text elementById=gbqfq Robotframework Selenium2Library Java
23-
Press Key elementById=gbqfq \\13
22+
Input Text elementById=lst-ib Robotframework Selenium2Library Java
23+
Press Key elementById=lst-ib \\13
2424
Wait Until Element Is Visible xpath=//a[contains(.,'MarkusBernhardt')]
2525
Capture Page Screenshot
26-
27-
Search With JavaScript Locator And Delimiter
28-
Selenium2Library.Add Location Strategy elementByClassname return window.document.getElementsByClassName(arguments[0])[arguments[1]]; ,
29-
Element Text Should Be elementByClassname=gbqfba,0 Google-Suche
30-
Element Text Should Be elementByClassname=gbqfba,1 Auf gut Glück!
31-
26+
3227
Search With JavaScript Locator Text
33-
Selenium2Library.Add Location Strategy text return window.document.evaluate("//*[contains(text(),'" + arguments[0] + "')]", window.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
28+
Selenium2Library.Add Location Strategy text return window.document.evaluate("//*[contains(@value,'" + arguments[0] + "')]", window.document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
3429
Wait Until Element Is Visible text=Google-Suche
3530

3631
Search Without Locator Type
37-
Input Text gbqfq Robotframework Selenium2Library Java
38-
Press Key gbqfq \\13
32+
Input Text lst-ib Robotframework Selenium2Library Java
33+
Press Key lst-ib \\13
3934
Wait Until Element Is Visible //a[contains(.,'MarkusBernhardt')]
4035

4136
Get Id Of Active Element With JavaScript
42-
Input Text gbqfq Robotframework Selenium2Library
37+
Input Text lst-ib Robotframework Selenium2Library
4338
${activeElementId}= Execute JavaScript return window.document.activeElement.id;

0 commit comments

Comments
 (0)