It turns out that Robot uses a new thread for every keyword executed. It has the same thread name, but the TID changes for each keyword executed.
So, even if you call "WebDriverRunner.setWebDriver(myWebDriverInstance)" you will see Selenide attempt to open a new browser in each Robot Keyword.
The solution is to create a custom KeywordLibrary that sets the webdriver used by Selenide before each Keyword is executed:
public class MyKeywordLibrary extends AnnotationLibrary {
public static final String ROBOT_LIBRARY_SCOPE = "GLOBAL";
private static final String LIBRARY_DOCUMENTATION = "My Keyword Library";
private final Logger logger = LoggerFactory.getLogger(UiKeywordLibrary.class);
public UiKeywordLibrary(String classpath) {
super(classpath);
}
@Override
public Object runKeyword(String keywordName, Object[] args) {
myWebDriver = .... ; // Get your webdriver from somewhere, however your framework works
logger.info("Setting WebDriver for Selenide framework.");
WebDriverRunner.setWebDriver(myWebDriver);
return super.runKeyword(keywordName, args);
}
}
--
You received this message because you are subscribed to the Google Groups "selenide" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenide+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenide/5d71372d-5929-4a08-8fae-e851f98a3fb7n%40googlegroups.com.