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

Commit 68245eb

Browse files
committed
Libdoc working
Doesn't set "Run on failure" keyword if robot context isn't loaded.
1 parent 75f317d commit 68245eb

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

pom.xml

Lines changed: 2 additions & 2 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.1</robotframework.version>
2727
<keywords.class>Selenium2Library</keywords.class>
2828
</properties>
2929

@@ -157,7 +157,7 @@
157157
<!-- Integration-Test, build documentation -->
158158
<groupId>org.robotframework</groupId>
159159
<artifactId>robotframework-maven-plugin</artifactId>
160-
<version>1.2</version>
160+
<version>1.4.4</version>
161161
<executions>
162162
<execution>
163163
<id>test</id>

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

Lines changed: 3 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
// ##############################
@@ -510,6 +510,7 @@ public String getKeywordDocumentation(String keywordName) {
510510
}
511511

512512
public static Selenium2Library getLibraryInstance() throws ScriptException {
513+
System.out.println("Testi");
513514
ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");
514515
engine.put("library", "Selenium2Library");
515516
engine.eval("from robot.libraries.BuiltIn import BuiltIn");

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,

0 commit comments

Comments
 (0)