2013-08-28 16 views

Odpowiedz

9

I zorientowaliśmy się, na podstawie tej odpowiedzi https://stackoverflow.com/a/17217598 i po prostu zastąpiła click() z mouseOver().

Oto mój kod 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(); 
} 

muszę przekazać selektor CSS, gdy używam go, więc użycie wygląda następująco:

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

Alternatywny unoszą się nad

/** 
* @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

Nie mogę znaleźć żadnej dokumentacji na iFocu Metoda sOn(), której używasz. – Alpha01

Powiązane problemy