Commit 1e233c5e authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1415247: Adding behat step to confirm file deletion



Change-Id: Iaee6116f6220227325d5ead4ec548a8f8df26797
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit cff3fbff)
parent 3daeb4ba
......@@ -381,6 +381,55 @@ class BehatGeneral extends BehatBase {
$elementnode->click();
}
/**
* Click a row containing the specified text.
*
* @When /^I click the row "(?P<row_text_string>(?:[^"]|\\")*)"$/
* @param string $rowtext the row text
* @throws ElementNotFoundException
*/
public function i_click_row($rowtext) {
// The table row container.
$rowtextliteral = $this->escaper->escapeLiteral($rowtext);
$exception = new ElementNotFoundException($this->getSession(), 'text', null, 'the row containing the text "' . $rowtext . '"');
$xpath = "//div[(contains(concat(' ', normalize-space(@class), ' '), ' listrow ')" .
" or contains(concat(' ', normalize-space(@class), ' '), ' list-group-item '))" .
" and contains(normalize-space(.), " . $rowtextliteral . ")]" .
"//a[contains(concat(' ', normalize-space(@class), ' '), ' outer-link ')]";
$rownode = $this->find('xpath', $xpath, $exception);
//$this->ensure_node_is_visible($rownode);
//$rownode->click();
// For some reasons, the Mink function click() and check() do not work
// Using jQuery as a workaround
$jscode = "jQuery(\"div.list-group-item:contains(" . $this->escapeDoubleQuotes($rowtextliteral) . ") a.outer-link\")[0].click();";
$this->getSession()->executeScript($jscode);
}
/**
* Click on the delete button inside a list/table row containing the specified text.
*
* @When /^I delete the "(?P<row_text_string>(?:[^"]|\\")*)" row$/
* @param string $rowtext The list/table row text
* @throws ElementNotFoundException
*/
public function i_delete_the_row($rowtext) {
// The table row container.
$rowtextliteral = $this->escaper->escapeLiteral($rowtext);
$exception = new ElementNotFoundException($this->getSession(), 'text', null, 'the delete button in the row containing the text "' . $rowtext . '"');
$xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), concat(' ', 'list-group-item', ' '))" .
" and contains(normalize-space(.), " . $rowtextliteral . ")]//button[starts-with(@id, 'delete_')]" .
"|" .
"//tr[contains(normalize-space(.), " . $rowtextliteral . ")]//input[starts-with(@id, 'delete_') or starts-with(@name, 'files_filebrowser_delete')]";
$deletenode = $this->find('xpath', $xpath, $exception);
$this->ensure_node_is_visible($deletenode);
$deletenode->press();
$this->getSession()->getDriver()->getWebDriverSession()->accept_alert();
}
/**
* Drags and drops the specified element to the specified container. This step does not work in all the browsers, consider it experimental.
*
......
......@@ -36,6 +36,7 @@ Scenario: Creating a collection AND adding pages
# Adding page 1, 2 & 3 to the collection
And I press "Next: Edit collection pages"
And I follow "All"
And I wait "1" seconds
Then I press "Add pages"
# Verifying that the pages were added
And I should see "Testing page 1"
......
......@@ -35,6 +35,9 @@ Scenario: Creating sub folder and attaching files (Bug 1426983)
And I attach the file "Image3.png" to "Upload file"
# Confirming upload was successful
And I should see "Upload of Image3.png to Subfolder2 complete"
# Confirming deletion of upload
And I delete the "Image3.png" row
And I should see "Image Image3.png deleted"
# Verifying you can move from subfolder2 to Home
And I follow "Home"
# Verifying all 2 folders are still there
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment