如何测试仅在悬停时可见的图标


How Can I Test An Icon Only Visible On Hover?

我有一个页面,用户可以通过单击悬停时才可见的铅笔图标来编辑表单的标题。我正在编写一个phpunit Selenium测试,我尝试了MoveToElement和其他一些Selenium函数来访问这个不可见的元素,但目前还不支持。

当我尝试直接访问元素时,测试错误并输出

    Element is not currently visible and so may not be interacted with

我如何嘲笑悬停在图标上的鼠标?

最终不得不使用javascript来完成这项工作,因为其他Selenium方法都没有php绑定

$script_show = 'jQuery(".class_name").css("display", "block");';
$script_hide = 'jQuery(".class_name").css("display", "none");';
//prior to accessing the non-visible element
$this->execute( array( 'script' => $script_show , 'args'=>array() ) );
//after it no longer needs to be visible
$this->execute( array( 'script' => $script_hide , 'args'=>array() ) );

当铅笔图标不可见时,您需要移动到/mouseover/hover/任何元素,以使图标可见,然后对铅笔图标执行操作。一旦你看到铅笔图标,你的网站的UI是如何实现的将决定确切的硒代码。