简体   繁体   English

机器人框架 Selenium2Library 获取 WebDriver 实例

[英]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.

相关问题 无法在 Robot Framework 中使用 Selenium2Library。 导入错误:没有名为 Selenium2Library 的模块错误 - Unable to use Selenium2Library in Robot Framework. ImportError: No module named Selenium2Library error 用于机器人框架中关键字访问的 Selenium2library 导入 - Selenium2library import for keyword access in robot framework Robot Framework,将自定义关键字与Selenium2Library集成 - Robot Framework, integrating custom keywords with Selenium2Library Robot Framework Selenium2Library 中的无缓存刷新 - No-Cache Refresh In Robot Framework Selenium2Library 无法在 Robot Framework 上导入 Selenium2library:错误(未找到导入文件) - Cannot import Selenium2library on Robot Framework : error (import file not found) 如何使用 Selenium2Library 在 Robot Framework 中向我的 chromedriver 添加扩展并远程启动 - How can I add an extension to my chromedriver at the Robot Framework with Selenium2Library and launch remotely 在内置库关键字“run_keyword_and_continue_on_failure”中使用 selenium2library 关键字的 ROBOT 框架问题 - ROBOT framework issue in using selenium2library keyword inside builtIn library keyword 'run_keyword_and_continue_on_failure' 如何使用selenium2Library将Chrome应用程序打开到Robot中 - How to open a Chrome application into Robot using selenium2Library 导入Selenium2Library - Importing Selenium2Library 在 Robot Framework 中使用 Selenium.Webdriver 和 SeleniumLibrary - Using Selenium.Webdriver and SeleniumLibrary in Robot Framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM