简体   繁体   English

Selenium IDE 卡在“准备运行测试”

[英]Selenium IDE stuck on “Preparing to run your test”

I have a test in Selenium IDE which looks like this.我在 Selenium IDE 进行了测试,看起来像这样。 Say that our base URL is https://stackoverflow.com .假设我们的基础 URL 是https://stackoverflow.com

  • open /questions打开/问题
  • pause 500暂停 500
  • type id=search hello输入 id=搜索你好

When I run the test, the first two steps are marked in green, but in actuality the browser is still at `moz-extension://blahblah/bootstrap.html, which says "Preparing to run your test".当我运行测试时,前两个步骤标记为绿色,但实际上浏览器仍然位于 `moz-extension://blahblah/bootstrap.html,上面写着“准备运行测试”。 So then any subsequent tests that rely on the page actually being there will timeout and fail.因此,任何依赖实际存在的页面的后续测试都将超时并失败。 I've disabled all other extensions besides Selenium and the issue persists.我已经禁用了除 Selenium 之外的所有其他扩展,问题仍然存在。

What might be the cause of this issue?这个问题的原因可能是什么?

That same thing happened to me a few times and I'm not sure what caused it.同样的事情发生在我身上几次,我不确定是什么原因造成的。 So what I figured out was that if you click on the first line of your test, and then hit the the run button, it won't get stuck on that message.所以我发现如果你点击测试的第一行,然后点击运行按钮,它不会卡在那个消息上。

TLDR: Insert any command before the first open command (even an empty/disabled one), magically fixes it. TLDR:在第一个打开命令之前插入任何命令(即使是空的/禁用的命令),神奇地修复它。

What I've noticed about this issue is that it only happens when the browser window your tests run in isn't opened yet.我注意到这个问题是,它仅在您的测试运行的浏览器 window 尚未打开时发生。 When you stop test execution but leave the window open and then run the test again, everything works as expected.当您停止测试执行但让 window 保持打开状态然后再次运行测试时,一切都按预期工作。

So what appears to happen is that the open command is run when the browser window is still opening and the page specified doesn't actually get opened, leaving you at the default page.所以似乎发生的是,当浏览器 window 仍在打开并且指定的页面实际上并没有打开时,打开命令运行,将您留在默认页面。 Now the next command that tries to do anything specific to the page gets stuck because you're not on the correct page.现在,下一个尝试对页面执行任何操作的命令会因为您不在正确的页面上而被卡住。

Now for some reason, doing absolutely ANYTHING before calling the open command fixes this.现在由于某种原因,在调用 open 命令之前做任何事情都可以解决这个问题。 Simply insert a new command before "open" and that does the trick.只需在“打开”之前插入一个新命令,就可以了。

在第 1 行的“打开”之前插入一个空命令

If that doesn't work for you then you can use "pause" for a few milliseconds so that the window has time to open before opening the page, but that shouldn't even be necessary.如果这对您不起作用,那么您可以使用“暂停”几毫秒,以便 window 在打开页面之前有时间打开,但这甚至没有必要。

For me it worked by either slowing the execution speed or more efferent way would be use setSpeed command and set time as 1000 milliseconds just before open command is being called & then once it has been called, again use setSpped command and set time as 0.对我来说,它通过减慢执行速度或更有效的方式来工作,即使用 setSpeed 命令并将时间设置为 1000 毫秒,就在调用 open 命令之前,然后一旦调用它,再次使用 setSpped 命令并将时间设置为 0。

Refer to this screenshot参考这个截图

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

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