简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM