selenium - 在 Appium 和 Selenium 库的情况下,使用方法“捕获页面屏幕截图”的 Robot Framework 自动日志生成问题
问题描述
对于我的应用程序,我必须在 Web 应用程序上创建数据并在移动应用程序中对其进行验证,因此我的代码同时支持 Appium 和 Selenium 方法。在单个测试套件文件中,我同时调用了 selenium 和 Appium 方法,并且一切都运行成功。
但是,每当任何测试用例由于任何原因失败时,机器人框架自动日志文件都无法理解应该使用哪种方法来捕获页面截图 [Selenium OR Appium]?它会引发以下警告,并且不会捕获任何屏幕截图。
Keyword 'Capture Page Screenshot' could not be run on failure: Multiple keywords with name 'Capture Page Screenshot' found. Give the full name of the keyword you want to use:
AppiumLibrary.Capture Page Screenshot
SeleniumLibrary.Capture Page Screenshot
在测试套件文件中,我们可以定义Appium.Capture Page Screenshot或Selenium.Capture Page Screenshot但对于自动日志创建,我们如何解决这个问题?
解决方案
SeleniumLibrary 可以使用几个可选参数导入
timeout=5.0,
implicit_wait=0.0,
run_on_failure=Capture Page Screenshot,
screenshot_root_directory=None,
plugins=None,
event_firing_webdriver=None
timeout: Default value for timeouts used with Wait ... keywords.
implicit_wait: Default value for implicit wait used when locating elements.
run_on_failure: Default action for the run-on-failure functionality.
screenshot_root_directory: Path to folder where possible screenshots are created or
EMBED. See Set Screenshot Directory keyword for further details about EMBED. If not
given, the directory where the log file is written is used.
plugins: Allows extending the SeleniumLibrary with external Python classes.
event_firing_webdriver: Class for wrapping Selenium with EventFiringWebDriver
run_on_failure
Argument 应该可以解决 Selenium Screenshots 的问题
Appium 库有一个类似的参数
像这样导入库:
Library SeleniumLibrary run_on_failure=SeleniumLibrary.Capture Page Screenshot
Library AppiumLibrary run_on_failure=AppiumLibrary.Capture Page Screenshot
如果这不能解决问题,请尝试使用指定的 Test Teardowns
推荐阅读
- python - SQLITE 查询列表中的单词 - For 循环在第一个单词后停止
- python - 为什么重新加载按钮发送 POST 请求?,Flask Python
- python - 来自字符串列的 sqlite3 日期比较
- django - 运行 te 代码后在我的浏览器中弹出一个窗口说:发生错误
- slack - Slack 应用程序:向此应用程序发送消息已关闭
- ubuntu - 如何更改用户的默认主目录?- 许本图
- python - 时间序列的区间预测 | 时间序列异常
- r - 如何在 R 中使用 DiagrammR 从 gv 文件中选择节点
- python - 如何在 Python 中为 aws 时间流使用分页?
- reactjs - 为什么路由会重置 redux 状态?