如何在使用 Selenium 和 PHPUnit 关闭框架后返回 window?

How to back to window after closed frame with Selenium and PHPUnit?

我正在测试一个带有框架的页面,在该页面上单击后框架会自动关闭。框架关闭后,Selenium 无法返回当前 window 并继续测试。

我的测试:

public function testMyFrame(){
    $this->frame('myFrame'); //Select frame
    $this->byId('myButtonInFrame')->click; //Here myFrame is closed and my page don't have some frame
    $this->byId('otherButton')->click;
}

错误:

PHPUnit_Extensions_Selenium2TestCase_WebDriverException: cannot forward the request 127.0.0.1:8080 failed to respond
org.openqa.grid.common.exception.GridException

您遇到的错误与正在关闭的框架无关。整个window在这里关闭。

请确保消除 "windows" 与 "frames" 的歧义。如果切换到框架,并且框架关闭,window 关闭,因为框架附加到 window。如果 window 关门了,你总能回来。

然而,返回当前上下文的命令接近于:

$this->switchToDefaultContent();

(它可能没有命名,但搜索文档。你应该找到关于 "switching to default content" 的内容)

已发现错误,将予以修复。可以看到here