diff --git a/src/Selenium2Driver.php b/src/Selenium2Driver.php index cabdb606..1e7b7a84 100755 --- a/src/Selenium2Driver.php +++ b/src/Selenium2Driver.php @@ -683,7 +683,20 @@ public function setValue($xpath, $value) } $element->postValue(array('value' => array($value))); - $this->trigger($xpath, 'change'); + // Remove the focus from the element if the field still has focus in + // order to trigger the change event. By doing this instead of simply + // triggering the change event for the given xpath we ensure that the + // change event will not be triggered twice for the same element if it + // has lost focus in the meanwhile. If the element has lost focus + // already then there is nothing to do as this will already have caused + // the triggering of the change event for that element. + $script = <<executeJsOnElement($element, $script); } /**