Debugging 如何阻止BEAT测试在中间运行元素检查器? 我使用Chrome驱动程序,现在在测试中间暂停浏览器: And I ... And I wait for 3600 seconds And I ...

Debugging 如何阻止BEAT测试在中间运行元素检查器? 我使用Chrome驱动程序,现在在测试中间暂停浏览器: And I ... And I wait for 3600 seconds And I ...,debugging,webdriver,selenium-chromedriver,behat,Debugging,Webdriver,Selenium Chromedriver,Behat,根据以下方法: /** * @Given I wait for :number seconds */ public function iWaitForSeconds($number) { $this->getSession()->wait($number * 1000); } 因此,我可以自由地使用DevTools在测试中的特定位置检查给定页面的对象 问题在于,当打开DevTools时,脚本会停止并出现错误: And I wait for 3600 seconds # CW

根据以下方法:

/**
 * @Given I wait for :number seconds
 */
public function iWaitForSeconds($number) {
  $this->getSession()->wait($number * 1000);
}
因此,我可以自由地使用DevTools在测试中的特定位置检查给定页面的对象

问题在于,当打开DevTools时,脚本会停止并出现错误:

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)

有更好的方法吗?

您可以使用如下断点:

    /**
     * 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()


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

您可以使用如下断点:

    /**
     * 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()

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

使用该模块,您可以轻松地逐步完成某个功能,而无需为其添加特定代码。这是GitHub概述:

调试特定场景时,请使用CLI中的
--单步执行
标志:

在每个步骤之后,您将看到消息

[在“”之后暂停-按enter键继续]

Behat测试套件将保持此挂起状态,直到收到回车,以允许您执行任何必要的检查

使用该模块,您无需为特定功能添加特定代码,即可轻松完成特定功能。这是GitHub概述:

调试特定场景时,请使用CLI中的
--单步执行
标志:

在每个步骤之后,您将看到消息

[在“”之后暂停-按enter键继续]

Behat测试套件将保持此挂起状态,直到收到回车,以允许您执行任何必要的检查


回答很好,但我绝对建议用IDE调试以避免此类黑客。回答很好,但我绝对建议用IDE调试以避免此类黑客。