Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed unwanted trailing tab in chrome 53 #244

Merged
merged 2 commits into from
Oct 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions src/Selenium2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -678,10 +678,11 @@ public function setValue($xpath, $value)
$existingValueLength = strlen($element->attribute('value'));
// Add the TAB key to ensure we unfocus the field as browsers are triggering the change event only
// after leaving the field.
$value = str_repeat(Key::BACKSPACE . Key::DELETE, $existingValueLength) . $value . Key::TAB;
$value = str_repeat(Key::BACKSPACE . Key::DELETE, $existingValueLength) . $value;
}

$element->postValue(array('value' => array($value)));
$this->trigger($xpath, 'change');
}

/**
Expand Down Expand Up @@ -819,17 +820,15 @@ public function mouseOver($xpath)
*/
public function focus($xpath)
{
$script = 'Syn.trigger("focus", {}, {{ELEMENT}})';
$this->withSyn()->executeJsOnXpath($xpath, $script);
$this->trigger($xpath, 'focus');
}

/**
* {@inheritdoc}
*/
public function blur($xpath)
{
$script = 'Syn.trigger("blur", {}, {{ELEMENT}})';
$this->withSyn()->executeJsOnXpath($xpath, $script);
$this->trigger($xpath, 'blur');
}

/**
Expand All @@ -838,8 +837,7 @@ public function blur($xpath)
public function keyPress($xpath, $char, $modifier = null)
{
$options = self::charToOptions($char, $modifier);
$script = "Syn.trigger('keypress', $options, {{ELEMENT}})";
$this->withSyn()->executeJsOnXpath($xpath, $script);
$this->trigger($xpath, 'keypress', $options);
}

/**
Expand All @@ -848,8 +846,7 @@ public function keyPress($xpath, $char, $modifier = null)
public function keyDown($xpath, $char, $modifier = null)
{
$options = self::charToOptions($char, $modifier);
$script = "Syn.trigger('keydown', $options, {{ELEMENT}})";
$this->withSyn()->executeJsOnXpath($xpath, $script);
$this->trigger($xpath, 'keydown', $options);
}

/**
Expand All @@ -858,8 +855,7 @@ public function keyDown($xpath, $char, $modifier = null)
public function keyUp($xpath, $char, $modifier = null)
{
$options = self::charToOptions($char, $modifier);
$script = "Syn.trigger('keyup', $options, {{ELEMENT}})";
$this->withSyn()->executeJsOnXpath($xpath, $script);
$this->trigger($xpath, 'keyup', $options);
}

/**
Expand Down Expand Up @@ -1113,4 +1109,15 @@ private function ensureInputType(Element $element, $xpath, $type, $action)
throw new DriverException(sprintf($message, $action, $xpath, $type));
}
}

/**
* @param $xpath
* @param $event
* @param string $options
*/
private function trigger($xpath, $event, $options = '{}')
{
$script = 'Syn.trigger("' . $event . '", ' . $options . ', {{ELEMENT}})';
$this->withSyn()->executeJsOnXpath($xpath, $script);
}
}