Merge 2284b66d03
into bf36edecad
This commit is contained in:
commit
17646ecc2f
|
@ -750,4 +750,63 @@ JS;
|
|||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the order of two texts.
|
||||
* Assumptions: the two texts appear in their conjunct parent element once
|
||||
* @Then /^I should see the text "(?P<textBefore>(?:[^"]|\\")*)" (before|after) the text "(?P<textAfter>(?:[^"]|\\")*)"$/
|
||||
*/
|
||||
public function theTextBeforeAfter($textBefore, $order, $textAfter) {
|
||||
$textBefore = $this->fixStepArgument($textBefore);
|
||||
$textAfter = $this->fixStepArgument($textAfter);
|
||||
|
||||
$elementBefore = $this->getSession()->getPage()->find('named', array(
|
||||
'content', $this->getSession()->getSelectorsHandler()->xpathLiteral($textBefore)
|
||||
));
|
||||
assertNotNull($elementBefore, sprintf('%s not found', $textBefore));
|
||||
$elementAfter = $this->getSession()->getPage()->find('named', array(
|
||||
'content', $this->getSession()->getSelectorsHandler()->xpathLiteral($textAfter)
|
||||
));
|
||||
assertNotNull($elementAfter, sprintf('%s not found', $textAfter));
|
||||
|
||||
$text = $elementBefore->getText();
|
||||
while (strpos($text, $textAfter) === FALSE) {
|
||||
$elementBefore = $elementBefore->getParent();
|
||||
$text = $elementBefore->getText();
|
||||
}
|
||||
|
||||
if($order === 'before') {
|
||||
assertTrue(preg_match("/$textBefore(.*?)$textAfter/", $text) === 1, $text);
|
||||
} else {
|
||||
assertTrue(preg_match("/$textAfter(.*?)$textBefore/", $text) === 1, $text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills in HTML Editor (rich-text editor, e.g. TinyMCE) with specified id|name|label.
|
||||
* @example I fill in "Terms and Conditions" HTML Editor with "test User Terms and Conditions1"
|
||||
* @When /^(?:|I )fill in "(?P<label>(?:[^"]|\\")*)" HTML Editor with "(?P<value>(?:[^"]|\\")*)"$/
|
||||
* @When /^(?:|I )fill in "(?P<value>(?:[^"]|\\")*)" for "(?P<label>(?:[^"]|\\")*)" HTML Editor$/
|
||||
*/
|
||||
public function fillInHtmlEditor($label, $value) {
|
||||
$locator = $this->fixStepArgument($label);
|
||||
$value = $this->fixStepArgument($value);
|
||||
|
||||
$element = $this->getSession()->getPage()->find('xpath',
|
||||
$this->getSession()->getSelectorsHandler()->selectorToXpath("xpath", ".//div["
|
||||
. "(./@id='$locator' or ./@name='$locator' or contains(./@label, '$locator'))]"
|
||||
));
|
||||
assertNotNull($element, sprintf('HTML Editor "%s" label or id not found', $label));
|
||||
|
||||
$iframe = $element->getParent()->find('css','iframe');
|
||||
assertNotNull($iframe, 'iframe not found for HTML Editor');
|
||||
$iframeId = $iframe->getAttribute('id');
|
||||
if($iframeId == null) {
|
||||
$iframeId = $iframe->getAttribute('name');
|
||||
}
|
||||
assertNotNull($iframeId, 'iframe id and name not found for HTML Editor');
|
||||
$this->getSession()->switchToIframe($iframeId);
|
||||
$field = $this->getSession()->getPage()->find('css', 'body');
|
||||
$field->setValue($value);
|
||||
$this->getSession()->switchToIframe(null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue