Skip to content
Snippets Groups Projects
Commit 24dbf69b authored by Rajab Natshah's avatar Rajab Natshah
Browse files

Issue #3179132: Change Automated Functional Acceptance Testing to be Drupal 9...

Issue #3179132: Change Automated Functional Acceptance Testing to be Drupal 9 compatible on the Varbase 9.0.x branch
parent 80229ac1
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ default:
output_path: "%paths.base%/tests/reports/"
extensions:
Drupal\MinkExtension:
ajax_timeout: 20
ajax_timeout: 60
files_path: "%paths.base%/tests/assets/"
goutte: ~
selenium2:
......
......@@ -86,7 +86,7 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
$element = $this->getSession()->getPage();
$this->getSession()->visit($this->locatePath('/user'));
sleep(2);
sleep(2);
$element->fillField('edit-name', $username);
$element->fillField('edit-pass', $password);
$submit = $element->findButton('op');
......@@ -115,7 +115,7 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
// Login with the.
$element = $this->getSession()->getPage();
$this->getSession()->visit($this->locatePath('/user'));
sleep(2);
sleep(2);
$element->fillField('edit-name', $username);
$element->fillField('edit-pass', $password);
$submit = $element->findButton('op');
......@@ -211,7 +211,7 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
* @Given /^(?:|I )wait max of (?P<time>\d+)s(?:| for the page to be ready and loaded)$/
* @Given /^(?:|I )wait(?:| for the page)$/
*
* @throws Exception
* @throws \WebDriver\Exception
* If timeout is reached.
*/
public function iWaitMaxOfSecondsForThePageToBeReadyAndLoaded($time = 10000) {
......@@ -933,7 +933,7 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
if (preg_match($regex, $actual)) {
$found = TRUE;
break;
break;
}
}
if (!$found) {
......@@ -951,6 +951,49 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
}
}
/**
* Check if we do not have the text in the selected element.
*
* Varbase Context #varbase.
*
* Example #1: Then I should not see "your text" in the "ol" element with the "class" attribute set to "breadcrumb"
* Example #2: And I should not see "your text" in the "div" element with the "id" attribute set to "right-panel"
*
* @Then /^I should not see "(?P<text>[^"]*)" in the "(?P<htmlTagName>[^"]*)" element with the "(?P<attribute>[^"]*)" attribute set to "(?P<value>[^"]*)"$/
*/
public function iShouldNotSeeTextInTheHtmlTagElement($text, $htmlTagName, $attribute, $value) {
$elements = $this->getSession()->getPage()->findAll('css', $htmlTagName);
if (empty($elements)) {
throw new \Exception(sprintf('The element "%s" was not found in the page', $htmlTagName));
}
$found = FALSE;
foreach ($elements as $element) {
$actual = $element->getText();
$actual = preg_replace('/\s+/u', ' ', $actual);
$regex = '/' . preg_quote($text, '/') . '/ui';
if (preg_match($regex, $actual)) {
$found = TRUE;
break;
}
}
if ($found) {
throw new \Exception(sprintf('"%s" was found in the "%s" element', $text, $htmlTagName));
}
if (empty($attribute)) {
$attr = $element->getAttribute($attribute);
if (empty($attr)) {
throw new \Exception(sprintf('The "%s" attribute is present on the element "%s"', $attribute, $htmlTagName));
}
if (strpos($attr, "$value") === FALSE) {
throw new \Exception(sprintf('The "%s" attribute does not equal "%s" on the element "%s"', $attribute, $value, $htmlTagName));
}
}
}
/**
* Click on the text in the selected element.
*
......@@ -977,7 +1020,7 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
if (preg_match($regex, $actual)) {
$found = TRUE;
$element->click();
break;
break;
}
}
if (!$found) {
......@@ -1602,7 +1645,7 @@ JS;
* @When /^I select (?:|the )"([^"]*)" paragraph component$/
*/
public function iSelectTheParagraphComponent($value) {
$this->getSession()->getPage()->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "'. $value . '")]')->click();
$this->getSession()->getPage()->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "' . $value . '")]')->click();
}
/**
......@@ -1660,4 +1703,5 @@ JS;
// no-op, alert might not be present.
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment