[英]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?在 Robot Framework 中,是否可以从 Selenium2library 获取 WebDriver 实例并在 Python 代码中使用它? What I wanna do is extend the Selenium2Library with some custom functions.
我想做的是用一些自定义函数扩展 Selenium2Library。 But I need the WebDriver instance to do that.
但我需要 WebDriver 实例来做到这一点。
Selenium2Library is no longer supported.不再支持 Selenium2Library。 The newest version of robot's selenium library is SeleniumLibrary .
机器人的 selenium 库的最新版本是SeleniumLibrary 。 If you are using
SeleniumLibrary
rather than the outdated Selenium2Library
, you can access the actual webdriver instance like so:如果您使用的是
SeleniumLibrary
而不是过时的Selenium2Library
,您可以像这样访问实际的 webdriver 实例:
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这记录在文件docs/extending/extending.rst中的 SeleniumLibrary 源代码存储库中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.