是否有可能找到隐藏的元素?我想要一个查找我的工具提示的函数,该函数说明我的表单中没有正确填充某些内容。
该函数如下所示:
public function checkTooltip()
{
$element = $this->byClassName('tooltip');
if ($element->displayed())
{
echo "something was not filled correctly";
}
}
$var1->value('hello');
$this->checkTooltip();
$var2->value('world');
$this->checkTooltip();
$var3->value('!');
$this->checkTooltip();
当工具提示出现时,这非常有效,但如果没有任何错误,我会收到消息:
"PHPUnit_Extensions_Selenium2TestCase_WebDriverException: no such element"
这样做是因为当没有出现任何问题时它会被隐藏但是我想要选择那个元素,因为我希望我的测试能够确保在我的测试中它不会变质以确保一切都是okey。所以有一个使用phpunit_Selenium2TestCase选择隐藏元素的方法?
答案 0 :(得分:0)
这是一种魅力!
public function checkError()
{
$tooltip = $this->elements($this->using('css selector')->value('div.active div.invalid'));
if(count($tooltip) != 0)
{
foreach ($tooltip as $tool)
{
$warning = $tool->text();
echo "You got a invalid tooltip with this message '".$warning."'";
}
}
}