@@ -185,6 +185,73 @@ public function testShouldDetectVisibilityOfElementLocatedCondition()
185185 $ this ->assertSame ($ element , $ this ->wait ->until ($ condition ));
186186 }
187187
188+ public function testShouldDetectInvisibilityOfElementLocatedConditionOnNoSuchElementException ()
189+ {
190+ $ element = $ this ->createRemoteWebElementMock ();
191+
192+ $ this ->driverMock ->expects ($ this ->at (0 ))
193+ ->method ('findElement ' )
194+ ->with ($ this ->isInstanceOf (WebDriverBy::class))
195+ ->willReturn ($ element );
196+
197+ $ element ->expects ($ this ->at (0 ))
198+ ->method ('isDisplayed ' )
199+ ->willReturn (true );
200+
201+ $ this ->driverMock ->expects ($ this ->at (1 ))
202+ ->method ('findElement ' )
203+ ->with ($ this ->isInstanceOf (WebDriverBy::class))
204+ ->willThrowException (new NoSuchElementException ('' ));
205+
206+ $ condition = WebDriverExpectedCondition::invisibilityOfElementLocated (WebDriverBy::cssSelector ('.foo ' ));
207+
208+ $ this ->assertTrue ($ this ->wait ->until ($ condition ));
209+ }
210+
211+ public function testShouldDetectInvisibilityOfElementLocatedConditionOnStaleElementReferenceException ()
212+ {
213+ $ element = $ this ->createRemoteWebElementMock ();
214+
215+ $ this ->driverMock ->expects ($ this ->exactly (2 ))
216+ ->method ('findElement ' )
217+ ->with ($ this ->isInstanceOf (WebDriverBy::class))
218+ ->willReturn ($ element );
219+
220+ $ element ->expects ($ this ->at (0 ))
221+ ->method ('isDisplayed ' )
222+ ->willReturn (true );
223+
224+ $ element ->expects ($ this ->at (1 ))
225+ ->method ('isDisplayed ' )
226+ ->willThrowException (new StaleElementReferenceException ('' ));
227+
228+ $ condition = WebDriverExpectedCondition::invisibilityOfElementLocated (WebDriverBy::cssSelector ('.foo ' ));
229+
230+ $ this ->assertTrue ($ this ->wait ->until ($ condition ));
231+ }
232+
233+ public function testShouldDetectInvisibilityOfElementLocatedConditionWhenElementBecamesInvisible ()
234+ {
235+ $ element = $ this ->createRemoteWebElementMock ();
236+
237+ $ this ->driverMock ->expects ($ this ->exactly (2 ))
238+ ->method ('findElement ' )
239+ ->with ($ this ->isInstanceOf (WebDriverBy::class))
240+ ->willReturn ($ element );
241+
242+ $ element ->expects ($ this ->at (0 ))
243+ ->method ('isDisplayed ' )
244+ ->willReturn (true );
245+
246+ $ element ->expects ($ this ->at (1 ))
247+ ->method ('isDisplayed ' )
248+ ->willReturn (false );
249+
250+ $ condition = WebDriverExpectedCondition::invisibilityOfElementLocated (WebDriverBy::cssSelector ('.foo ' ));
251+
252+ $ this ->assertTrue ($ this ->wait ->until ($ condition ));
253+ }
254+
188255 public function testShouldDetectVisibilityOfCondition ()
189256 {
190257 $ element = $ this ->createRemoteWebElementMock ();
0 commit comments