Mario92
Mario92

Reputation: 45

Robot framework Selenium2Library get WebDriver instance

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.

Upvotes: 0

Views: 920

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385930

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

Upvotes: 3

Related Questions