2016-11-08 2 views
0

У меня есть Приемочный тест с Codeception. PhantomJS настроен как мой Webdriver. На моей странице у меня есть ссылка, которая имеет target="_blank". Проблема в том, что когда я инструктирую Codeception щелкнуть по нему, он не фокусируется на вновь открытой вкладке. Поэтому мой тест терпит неудачу.Codeception + PhantomJS: как открыть новую вкладку и переключиться на нее

Код:

$I->click('My Link that opens new tab'); 

То, что я пробовал:

$I->switchToWindow('Title of my new window'); // doesn't work 
$I->see('Some text in my new tab'); // also doesn't work 

Мой acceptance.suite.yml:

class_name: AcceptanceTester 
modules: 
    enabled: 
     - WebDriver 
     - \Helper\Acceptance 
    config: 
     WebDriver: 
      url: 'http://localhost' 
      browser: 'phantomjs' 
      port: 5555 
      window_size: '1024x768' 

Кто-нибудь есть идеи?

ответ

3

Я нашел решение, в случае, если есть какой-то другой разработчик страдает душа там:

$I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) { 
$handles = $webdriver->getWindowHandles(); 
$lastWindow = end($handles); 
$webdriver->switchTo()->window($lastWindow); 

});

Смежные вопросы