MDL-46061 behat: Fixed blur event problem for atto_image
atto_image look for blur event after changing width/height Added a new step to get focus off the element, so this can work.
This commit is contained in:
committed by
Marina Glancy
parent
3ac5a3544c
commit
c1ee80fef5
@@ -18,23 +18,23 @@ Feature: Add images to Atto
|
||||
And I click on "Select this file" "button"
|
||||
And I set the field "Describe this image" to "It's the Moodle"
|
||||
# Wait for the page to "settle".
|
||||
And I wait "2" seconds
|
||||
And I wait until the page is ready
|
||||
And the field "Width" matches value "204"
|
||||
And the field "Height" matches value "61"
|
||||
And I set the field "Auto size" to "1"
|
||||
And I set the field "Width" to "2040"
|
||||
# Trigger blur on the width field.
|
||||
And I set the field "Alignment" to "Bottom"
|
||||
And I take focus off "Width" "field"
|
||||
And the field "Height" matches value "610"
|
||||
And I set the field "Height" to "61"
|
||||
# Trigger blur on the height field.
|
||||
And I set the field "Alignment" to "Bottom"
|
||||
And I take focus off "Height" "field"
|
||||
And the field "Width" matches value "204"
|
||||
And I set the field "Auto size" to "0"
|
||||
And I set the field "Width" to "123"
|
||||
And I set the field "Height" to "456"
|
||||
# Trigger blur on the height field.
|
||||
And I set the field "Alignment" to "Bottom"
|
||||
And I take focus off "Height" "field"
|
||||
And the field "Width" matches value "123"
|
||||
And the field "Height" matches value "456"
|
||||
And I click on "Save image" "button"
|
||||
|
||||
@@ -282,6 +282,26 @@ class behat_general extends behat_base {
|
||||
$node->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the focus and takes away the focus from an element, generating blur JS event.
|
||||
*
|
||||
* @When /^I take focus off "(?P<element_string>(?:[^"]|\\")*)" "(?P<selector_string>[^"]*)"$/
|
||||
* @param string $element Element we look for
|
||||
* @param string $selectortype The type of what we look for
|
||||
*/
|
||||
public function i_take_focus_off_field($element, $selectortype) {
|
||||
if (!$this->running_javascript()) {
|
||||
throw new ExpectationException('Can\'t take focus off from "' . $element . '" in non-js mode', $this->getSession());
|
||||
}
|
||||
// Gets the node based on the requested selector type and locator.
|
||||
$node = $this->get_selected_node($selectortype, $element);
|
||||
$this->ensure_node_is_visible($node);
|
||||
|
||||
// Ensure element is focused before taking it off.
|
||||
$node->focus();
|
||||
$node->blur();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks the specified element and confirms the expected dialogue.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user