Commit 4f4aa415 authored by Aaron Wells's avatar Aaron Wells Committed by Gerrit Code Review

Merge "Fix the Selenium2Driver issue when setValue. Bug 1407847"

parents bc92adaf 8c9b805f
......@@ -10,7 +10,8 @@
*/
use Behat\Mink\Session as Session,
Behat\Mink\Element\NodeElement as NodeElement;
Behat\Mink\Element\NodeElement as NodeElement,
WebDriver\Key;
/**
* Representation of a form field.
......@@ -48,6 +49,21 @@ class BehatFormField {
$this->field = $fieldnode;
}
/**
* Empty the value to a text or textarea field.
*
* @return void
*/
public function empty_value() {
if (strtolower($this->field->getAttribute('type')) == 'text'
|| $this->field->getTagName() == 'textarea') {
// Using Ctrl-a and Delete to remove the existing value
// @TODO: for Mac OS, we should use Command-a to select all text
$this->field->keyPress('a', 'ctrl');
$this->field->keyPress(Key::DELETE);
}
}
/**
* Sets the value to a field.
*
......
......@@ -24,6 +24,11 @@ class BehatFormText extends BehatFormField {
* @return void
*/
public function set_value($value) {
// For autofocus text input and textarea, we need to reset the existing text first
if (strpos(strtolower($this->field->getAttribute('class')), 'autofocus') !== false
|| strpos(strtolower($this->field->getAttribute('class')), 'text') !== false) {
$this->empty_value();
}
$this->field->setValue($value);
}
......
@javascript @core @meta_test
Feature: Testing Behat's functionality
In order to be able to use every functionality in Mahara is working correct
As an admin I need to log in
And test every link/file/button/checkbox etc. possible
Scenario: Meta test testing Behat's functionality (Bug #1387836)
Given I log in as "admin" with password "Password1"
And I am on homepage
And I follow "Content"
And I should be on "artefact/internal/index.php"
And I set the following fields to these values:
| First name | test first name |
| Last name | test last name |
And I press "Save profile"
And I follow "Portfolio"
# Creating a page
And I press "Create page"
And I set the field "Page title" to "test page name 1"
And I press "Save"
# Verifying it saved
And I should see "Page saved successfully"
# Creating a collection
And I choose "Collections" in "Portfolio"
And I follow "New collection"
And I set the field "Collection name" to "test collection name"
And the "Page navigation bar" checkbox should be checked
And I press "Next: Edit collection pages"
# Adding pages to the collection
And I press "Add pages"
# Verifying it added
And I should see "You need to select a page to add to the collection."
And the checkbox "test page name 1" should be unchecked
And I check "test page name 1"
And the "test page name 1" checkbox should be checked
And I press "Add pages"
And I follow "Done"
And I hover "Delete collection" "link"
And I go to the homepage
And I go to "Export"
And I move backward one page
And I wait "3" seconds
And I move forward one page
And I follow "Content"
And the "First name" field should not contain "Jinelle"
And the "First name" field should contain "test first name"
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