简体   繁体   English

最小化浏览器Robot Framework关键字

[英]Minimize browser Robot Framework keyword

I have installed Robot Framework and created some test cases. 我已经安装了Robot Framework并创建了一些测试用例。 I used the keyword Maximize Browser Window to maximize the browser but now I need to minimize the browser. 我使用关键字最大化浏览器窗口来最大化浏览器,但是现在我需要最小化浏览器。 I see the official documentation but I don't find a specific keyword, now I'm use: 我看到了官方文档,但是找不到特定的关键字,现在使用:

  Set Window Size        ${0}       ${0}

but that isn't what I want. 但这不是我想要的。 I want to minimize or run the test in background. 我想最小化或在后台运行测试。 Does anybody know how. 有人知道吗。

thanks in advance. 提前致谢。

Great question, my company actually managed to accomplish this, but not the way you're thinking. 很好的问题是,我的公司实际上设法做到了这一点,但不是您的思维方式。

The short version is that it's probably impossible within normal Robot Framework, but we set up a persistent Linux VM and installed Jenkins and Robot Framework on it. 简短的版本是在普通的Robot Framework中可能是不可能的,但是我们设置了一个持久的Linux VM并在其上安装了Jenkins和Robot Framework。 This was then connected to the GitHub repository where builds are uploaded and set to run a new test on every push. 然后将其连接到GitHub存储库,在其中上载构建,并设置为在每次推送时运行新测试。

However, if you want to get into the internals of your particular browser, I found a way to guarantee that Chrome is started by Robot Framework maximized, so it might be possible to do the same thing, but in reverse. 但是,如果您想进入特定浏览器的内部,我找到了一种方法来确保Chrome由Robot Framework最大化启动,因此可能可以执行相同的操作,但反之亦然。 Assuming none of your keywords rely on xy coordinates, it should be fine. 假设您的关键字都不依赖xy坐标,那就没问题了。 Robot Framework works just fine when the browser it's controlling is minimized. 当将其控制的浏览器最小化时,Robot Framework可以正常工作。

Here's the code for what I did to start with. 这是我开始做的代码。

Open Chrome
    [Arguments]     ${HOMEPAGE}
    ${options}  Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()   sys
    Call Method     ${options}  add_argument    --start-maximized
    Create WebDriver    Chrome  chrome_options=${options}
    Go To   ${HOMEPAGE}

Edit: After further discussion with senior developers, the answer is no. 编辑:在与高级开发人员进一步讨论之后,答案是否定的。 It is not possible as asked because Selenium needs an available element to interact with. 由于Selenium需要可用的元素进行交互,因此无法按要求进行操作。 It might not necessarily be visible to the eye, but it needs to be available to the program, and that is not the case when the browser window is minimized. 它可能不一定是肉眼可见的,但它必须可供程序使用,而当浏览器窗口最小化时,情况并非如此。 When I changed my above code to "--start-minimized", it opened minimized and then promptly ran visibly. 当我将上面的代码更改为“ --start-minimized”时,它最小化打开,然后立即运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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