I have a maven-powered Robot-framework project in java that uses selenium 3.4.0 dependency, robotframework 3.0.2 dependency, markusbernhardt's selenium2library version 1.4.0.8, and robotframework-maven-plugin version 1.4.7.
My robot tests live in the src/main/test/robotframework/acceptance folder, while in src/main/java/mypackage I created a Customized.java file to set a system property for the browser driver path (I then import this library in my tests:
*** Settings ***
Library Selenium2Library
Library mypackage.Customized
This works perfectly. But now I'd like to implement my own keywords to extend Selenium2Library. But I'm not sure how to obtain the current WebDriver instance that is running.
I mean, if I weren't using Robot and just plain Selenium, I'd do something like this:
WebDriver driver=new ChromeDriver();
driver.doSomething();
However, in this case I don't want to instantiate a new WebDriver but instead get the one that is currently running (which Robot automatically instantiated). How can I do that?
I've so far created a Selenium2Library
object and set it with the value returned by Selenium2Library.getLibraryInstance();
but that's not giving me access to selenium's methods (e.g.: getCurrentUrl() is not listed).