Code Duplication    Length = 11-14 lines in 3 locations

tests/behat/src/CmsUiContext.php 3 locations

@@ 366-376 (lines=11) @@
363
    /**
364
     * @Given /^the preview contains "([^"]*)"$/
365
     */
366
    public function thePreviewContains($content)
367
    {
368
        $driver = $this->getSession()->getDriver();
369
        // TODO Remove once we have native support in Mink and php-webdriver,
370
        // see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
371
        $origWindowName = $driver->getWebDriverSession()->window_handle();
372
373
        $driver->switchToIFrame('cms-preview-iframe');
374
        $this->getMainContext()->assertPageContainsText($content);
375
        $driver->switchToWindow($origWindowName);
376
    }
377
378
    /**
379
     * @Given /^I set the CMS mode to "([^"]*)"$/
@@ 390-403 (lines=14) @@
387
    /**
388
     * @Given /^I wait for the preview to load$/
389
     */
390
    public function iWaitForThePreviewToLoad()
391
    {
392
        $driver = $this->getSession()->getDriver();
393
        // TODO Remove once we have native support in Mink and php-webdriver,
394
        // see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
395
        $origWindowName = $driver->getWebDriverSession()->window_handle();
396
397
        $driver->switchToIFrame('cms-preview-iframe');
398
        $this->getSession()->wait(
399
            5000,
400
            "window.jQuery && !window.jQuery('iframe[name=cms-preview-iframe]').hasClass('loading')"
401
        );
402
        $driver->switchToWindow($origWindowName);
403
    }
404
405
    /**
406
     * @Given /^I switch the preview to "([^"]*)"$/
@@ 427-437 (lines=11) @@
424
    /**
425
     * @Given /^the preview does not contain "([^"]*)"$/
426
     */
427
    public function thePreviewDoesNotContain($content)
428
    {
429
        $driver = $this->getSession()->getDriver();
430
        // TODO Remove once we have native support in Mink and php-webdriver,
431
        // see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
432
        $origWindowName = $driver->getWebDriverSession()->window_handle();
433
434
        $driver->switchToIFrame('cms-preview-iframe');
435
        $this->getMainContext()->assertPageNotContainsText($content);
436
        $driver->switchToWindow($origWindowName);
437
    }
438
439
    /**
440
     * When I follow "my link" in preview