In Robot Framework, is it possible to get the WebDriver instance from the Selenium2library and use it in Python code? What I wanna do is extend the Selenium2Library with some custom functions. But I need the WebDriver instance to do that.
- 1Selenium2Library is very old and unsupported. Is there a reason you're using it rather than the newer SeleniumLibrary?Bryan Oakley– Bryan Oakley2021-03-12 23:50:12 +00:00Commented Mar 12, 2021 at 23:50
- @BryanOakley no reason, i'm pretty new to Robot framework and i thought SeleniumTWO was the new library :D I didn't specifiy any library in my robot file so I assume it's using the SeleniumLibrary thenMario92– Mario922021-03-13 08:03:26 +00:00Commented Mar 13, 2021 at 8:03
Add a comment |
1 Answer
Selenium2Library is no longer supported. The newest version of robot's selenium library is SeleniumLibrary. If you are using SeleniumLibrary rather than the outdated Selenium2Library, you can access the actual webdriver instance like so:
from robot.libraries.BuiltIn import BuiltIn selib = BuiltIn().get_library_instance("SeleniumLibrary") driver = selib.driver This is documented in the SeleniumLibrary source code repository in the file docs/extending/extending.rst