如何在PHPUnit Selenium2TestCase中单击可见元素?
我有两个同名的按钮。出于设计原因,同时只能看到其中一个 我想点击任何可见的按钮 如果隐藏第一个按钮,则此表达式如何在PHPUnit Selenium2TestCase中单击可见元素?,php,selenium,phpunit,acceptance-testing,Php,Selenium,Phpunit,Acceptance Testing,我有两个同名的按钮。出于设计原因,同时只能看到其中一个 我想点击任何可见的按钮 如果隐藏第一个按钮,则此表达式 $this->byCssSelector('[name="saveAndClose"]')->click() 返回 Element is not currently visible and so may not be interacted with 如何单击可视按钮?我已经为此编写了简单的代码 public function clickOnDisplayedElemen
$this->byCssSelector('[name="saveAndClose"]')->click()
返回
Element is not currently visible and so may not be interacted with
如何单击可视按钮?我已经为此编写了简单的代码
public function clickOnDisplayedElementByName($name)
{
$elements = $this->elements($this->using('css selector')->value('[name="' . $name . '"]'));
foreach ($elements as $element)
{
if ($element->displayed())
{
$element->click();
return;
}
}
$this->fail('There is no visible elements with name ' . $name);
}