我从 2 天开始就开始玩 panther,这是一个很棒的工具,但我对一个场景有一点问题。
我想从我的应用程序中删除一篇文章。过程如下:我按下一个按钮,出现一个警报以确认。
问题是 WebDriver 抛出一个UnexpectedAlertOpenException
ok 所以我把它添加到客户端$client->getWebDriver()->switchTo()->alert()->accept();
但现在我得到了一个NoAlertOpenException
: no alert open,紧接着这条线。
我很尴尬
这是我的测试:
public function testDeleteAnArticle()
{
$client = static::createPantherClient();
$crawler = $client->request('GET', '/');
$crawler = $this->loginAs($client, $crawler, 'admin', 'azerty');
$crawler = $client->click($crawler->selectLink('Dashboard')->link());
$crawler = $client->click($crawler->selectLink('ARTICLES')->link());
$client->getWebDriver()->switchTo()->alert()->accept(); //<-- it will throw a NoAlertOpenException
$crawler = $client->click($crawler->filter('a.is-danger')->eq(5)->link());
$client->waitFor('.notification');
$this->assertContains('The article has been successfully deleted', $crawler->filter('.notification')->text());
}
有人知道如何处理这个吗?谢谢