我是Behat的新手.我目前正在使用Mink Extension和Selenium2驱动程序,我想知道如何指定测试应该作为场景的一部分悬停在元素上.
例如,这是我的场景:
Scenario: Testing that the Contact Us submenu appears
Given I am on "/"
When I hover over "About"
Then I should see "Contact Us"
Run Code Online (Sandbox Code Playgroud)
Pet*_*eth 11
我根据这个答案/sf/answers/1205231891/找到了它,并用mouseOver()替换了click().
这是我的FeatureContext代码:
/**
* @When /^I hover over the element "([^"]*)"$/
*/
public function iHoverOverTheElement($locator)
{
$session = $this->getSession(); // get the mink session
$element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element
// errors must not pass silently
if (null === $element) {
throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator));
}
// ok, let's hover it
$element->mouseOver();
}
Run Code Online (Sandbox Code Playgroud)
我必须在使用时传递css选择器,因此用法如下:
...
When I hover over the element ".about"
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5780 次 |
| 最近记录: |