Code Duplication    Length = 12-14 lines in 2 locations

src/Context/BrowserContext.php 2 locations

@@ 203-216 (lines=14) @@
200
        $message = "The text '$expected' was not found after a $count seconds timeout";
201
202
        $found = false;
203
        do {
204
            try {
205
                usleep(1000);
206
                $node = $this->getSession()->getPage()->find('css', $element);
207
                $this->assertContains($expected, $node->getText(), $message);
208
                return;
209
            }
210
            catch (ExpectationException $e) {
211
                /* Intentionally leave blank */
212
            }
213
            catch (StaleElementReference $e) {
214
                // assume page reloaded whilst we were still waiting
215
            }
216
        } while (!$found && (time() - $startTime < $count));
217
218
        // final assertion...
219
        $node = $this->getSession()->getPage()->find('css', $element);
@@ 262-273 (lines=12) @@
259
        $startTime = time();
260
        $e = null;
261
262
        do {
263
            try {
264
                usleep(1000);
265
                $node = $this->getSession()->getPage()->findAll('css', $element);
266
                $this->assertCount(1, $node);
267
                $found = true;
268
            }
269
            catch (ExpectationException $e) {
270
                /* Intentionally leave blank */
271
            }
272
        }
273
        while (!$found && (time() - $startTime < $count));
274
275
        if ($found === false) {
276
            $message = "The element '$element' was not found after a $count seconds timeout";