Skip to content

Commit

Permalink
MNT Use behat-extension function for clicking elements
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Apr 15, 2021
1 parent acbcf46 commit d7570cb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 30 deletions.
4 changes: 2 additions & 2 deletions tests/behat/features/create-a-page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ Feature: Create a page
Scenario: I cannot add root level pages without permission
When I go to "/admin/settings"
And I click the "Access" CMS tab
And I click the "#Form_EditForm_CanCreateTopLevelType_OnlyTheseUsers" element
And I click on the "#Form_EditForm_CanCreateTopLevelType_OnlyTheseUsers" element
And I press the "Save" button
And I click the ".cms-login-status__logout-link" element
And I click on the ".cms-login-status__logout-link" element
When I am logged in with "AUTHOR" permissions
And I press the "Add new" button
Then I see the "Top level" radio button "disabled" attribute equals "1"
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/features/publish-a-page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Feature: Publish a page
# Use a css-selector instead of the the "Archive" button otherwise it will get confused with
# the "Archive" model admin
Then I see the "#Form_EditForm_action_archive" element
When I click the "#Form_EditForm_action_archive" element, confirming the dialog
When I click on the "#Form_EditForm_action_archive" element, confirming the dialog

Then I should see a "Restore" button
And I should not see a "Published" button
Expand Down
27 changes: 0 additions & 27 deletions tests/behat/src/FixtureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,33 +80,6 @@ public function stepCreateRedirectorPage($type, $id, $targetType, $targetId)
$obj->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
}

/**
* @When /^I click the "([^"]+)" element$/
* @param $selector
*/
public function iClickTheElement($selector)
{
/** @var DocumentElement $page */
$page = $this->getMainContext()->getSession()->getPage();
$element = $page->find('css', $selector);

assertNotNull($element, sprintf('Element %s not found', $selector));

$element->click();
}

/**
* Needs to be in single command to avoid "unexpected alert open" errors in Selenium.
*
* @When /^I click the "([^"]+)" element, confirming the dialog$/
* @param $selector
*/
public function iClickTheElementConfirmingTheDialog($selector)
{
$this->iClickTheElement($selector);
$this->basicContext->iConfirmTheDialog();
}

/**
* @When /^I see the "([^"]+)" element$/
* @param $selector
Expand Down

0 comments on commit d7570cb

Please sign in to comment.