File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414use Behat \Mink \Selector \Xpath \Escaper ;
1515use WebDriver \Element ;
1616use WebDriver \Exception \NoSuchElement ;
17+ use WebDriver \Exception \StaleElementReference ;
1718use WebDriver \Exception \UnknownCommand ;
1819use WebDriver \Exception \UnknownError ;
1920use WebDriver \Exception ;
@@ -707,7 +708,15 @@ public function setValue($xpath, $value)
707708 document.activeElement.blur();
708709}
709710JS ;
710- $ this ->executeJsOnElement ($ element , $ script );
711+
712+ // Cover case, when an element was removed from DOM after its value was
713+ // changed (e.g. by a JavaScript of a SPA) and therefore can't be focused.
714+ try {
715+ $ this ->executeJsOnElement ($ element , $ script );
716+ } catch (StaleElementReference $ e ) {
717+ // Do nothing because an element was already removed and therefore
718+ // blurring is not needed.
719+ }
711720 }
712721
713722 /**
You can’t perform that action at this time.
0 commit comments