如何在中间停止Behat测试以运行元素检查器? [英] How to stop Behat tests in the middle to run element inspector?

查看:66
本文介绍了如何在中间停止Behat测试以运行元素检查器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Chrome驱动程序,目前正在执行测试的中间暂停浏览器:

I'm using Chrome driver and currently to pause the browser in the middle of the tests I do:

And I ...
And I wait for 3600 seconds
And I ...

使用以下方法:

/**
 * @Given I wait for :number seconds
 */
public function iWaitForSeconds($number) {
  $this->getSession()->wait($number * 1000);
}

所以我可以自由地使用 DevTools 在测试中的特定位置检查给定页面的对象.

so I can freely use DevTools to inspect the objects of the given page at specific place in my tests.

问题在于,打开 DevTools 时,脚本会因错误而停止:

The problem is that when opening DevTools, the script stops with error:

And I wait for 3600 seconds # CWTest\Context\HelperContext::iWaitForSeconds()
  disconnected: not connected to DevTools
    (Session info: chrome=59.0.3071.115)
    (Driver info: chromedriver=2.31.488774,platform=Mac OS X 10.12.0 x86_64) (WARNING: The server did not provide any stacktrace information)
  Command duration or timeout: 605 milliseconds
  Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
  Driver info: org.openqa.selenium.chrome.ChromeDriver
  Session ID: d429c9a3fdac50fcaed852d9f094d535 (WebDriver\Exception\UnknownError)

还有更好的方法吗?

推荐答案

您可以使用这样的断点:

You can use a breakpoint like this:

    /**
     * adds a breakpoints
     * stops the execution until you hit enter in the console
     * @Then /^breakpoint/
     */
    public function breakpoint()
    {
        fwrite(STDOUT, "\033[s    \033[93m[Breakpoint] Press \033[1;93m[RETURN]\033[0;93m to continue...\033[0m");
        while (fgets(STDIN, 1024) == '') {}
        fwrite(STDOUT, "\033[u");
        return;
    }

您也可以将它声明为静态调用,例如ClassName::breakpoint();

You can also declare it static an call it like ClassName::breakpoint();

作为替代方案,您可以在IDE中启用调试.

As an alternative you could enable debugging in your IDE.

这篇关于如何在中间停止Behat测试以运行元素检查器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆