2013-08-28 9 views
5

मैं बेहट के लिए नया हूं। मैं वर्तमान में मिंक एक्सटेंशन और सेलेनियम 2 ड्राइवर का उपयोग कर रहा हूं और मैं यह जानना चाहता हूं कि परिदृश्य के हिस्से के रूप में परीक्षण को तत्व पर होवर करना चाहिए।मैं वेबपेज पर किसी तत्व पर होवर करने के लिए बेहट/मिंक को कैसे बताऊं?

उदाहरण के लिए, यहाँ मेरी परिदृश्य है:

Scenario: Testing that the Contact Us submenu appears 
    Given I am on "/" 
    When I hover over "About" 
    Then I should see "Contact Us" 

उत्तर

9

मैं इसे समझ से बाहर है, इस सवाल का जवाब https://stackoverflow.com/a/17217598 पर आधारित है और बस क्लिक (प्रतिस्थापित) माउस ले जाएँ के साथ()।

यहाँ मेरी 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(); 
} 

, वैसे-वैसे उपयोग लगता है:

... 
When I hover over the element ".about" 
... 
0

वैकल्पिक मंडराना

से अधिक
/** 
* @Then /^I hover over "([^"]*)"$/ 
*/ 
public function iHoverOver($arg1) 
{ 
    $page = $this->getSession()->getPage(); 
    $findName = $page->find("css", $arg1); 
    if (!$findName) { 
     throw new Exception($arg1 . " could not be found"); 
    } else { 
     $findName->mouseOver(); 
    } 
} 
0
/** 
* works better with css, uses different method for css than xpath 
* @Then /^I mouse over "(?P<selector>[^"]*)"$/ 
*/ 



public function iMouseOver($selector){ 
     $element = $this->find($selector); 
     if($element == null){ 
      throw new Exception('Element '.$selector.' NOT found'); 
     } 
     $this->iFocusOn($selector); 
     if (strstr($selector, '//')) { 
      $element->mouseOver(); 
     } else { 
      $this->mouseOver($selector, '1'); 
     } 
    } 
+0

मुझे iFocu पर कोई दस्तावेज़ नहीं दिख रहा है एसओएन() विधि जिसका आप उपयोग कर रहे हैं। – Alpha01

संबंधित मुद्दे