Robot框架在测试运行期间如何使用chrome中的开发工具?

2024-05-16 02:50:43 发布

您现在位置:Python中文网/ 问答频道 /正文

在robot测试运行期间是否有可能让dev tools(inspector)保持打开状态? 我在我的“半自动”测试中包含了一个手动步骤,在这个步骤中,我打开了开发工具(F12),但是在点击Execute Manual StepPASS之后,其他的自动步骤就跟着出现了,开发工具会立即自动关闭。 我的测试结构概述:

Semi-automated robot test
    do some automated steps
    execute manual step     open developers console
    do some other automated steps
    execute manual step     check something in dev console

我不知道如何在机器人测试期间处理开发工具。即使我在手动步骤中在单独的窗口中打开dev工具,在自动化步骤中它仍然是关闭的。。。在

谢谢你的建议:-)


Tags: devexecuteinspector状态steprobot步骤some
3条回答

这是不可能的。来自ChromeDriver help center

When you open the DevTools window, ChromeDriver is automatically disconnected. When ChromeDriver receives a command, if disconnected, it will attempt to close the DevTools window and reconnect.

If you need to inspect something in DevTools, the best you can do now is pause your test so that ChromeDriver won't close DevTools. When you are done inspecting things in Chrome, you can unpause your test and ChromeDriver will close the window and continue.

如果您只想获取有关HTTP-在Seelenium测试运行期间发送的请求的信息,则可能需要添加以下代码,该代码将不断打印出包含所需信息的日志:

import logging
import http.client as client

client.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("selenium.webdriver.remote.remote_connection")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True

作为@Guy答案的一个例子,您可以在Robot框架中使用Dialogs

*** Settings ***
Library    Dialogs

*** Test Cases ***
test case
   Pause Execution    Please Press OK to Continue. 

然后将显示以下警报类型的框。在

enter image description here

相关问题 更多 >