Code Duplication    Length = 12-14 lines in 2 locations

src/Context/BrowserContext.php 2 locations

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