// @source http://phptest.club/t/browser-tab-open-new-swicht-to-last-1-2-3-4-5-close/866
/**
* $I->newBrowserTab();
*/
public function newBrowserTab()
{
$I = $this;
$I->pressKey('body', array("ctrl", "t"));
}
/**
* $I->lastBrowserTab();
*/
public function lastBrowserTab()
{
$I = $this;
$I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
$handles=$webdriver->getWindowHandles();
$last_window = end($handles);
$webdriver->switchTo()->window($last_window);
});
}
/**
* $I->closeBrowserTab();
*/
public function closeBrowserTab()
{
$I = $this;
$I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
$webdriver->close();
});
}
/**
* $I->nextBrowserTab2();
*/
public function nextBrowserTab2()
{
$I = $this;
$I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
$handles=$webdriver->getWindowHandles();
$last_window = next($handles);
$webdriver->switchTo()->window($last_window);
});
}
/**
* $I->nextBrowserTab3();
*/
public function nextBrowserTab3()
{
$I = $this;
$I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
$handles=$webdriver->getWindowHandles();
$last_window = next($handles);
$webdriver->switchTo()->window($last_window);
$last_window = next($handles);
$webdriver->switchTo()->window($last_window);
});
}
/**
* $I->nextBrowserTab4();
*/
public function nextBrowserTab4()
{
$I = $this;
$I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
$handles=$webdriver->getWindowHandles();
$last_window = next($handles);
$webdriver->switchTo()->window($last_window);
$last_window = next($handles);
$webdriver->switchTo()->window($last_window);
$last_window = next($handles);
$webdriver->switchTo()->window($last_window);
});
}
/**
* $I->nextBrowserTab5();
*/
public function nextBrowserTab5()
{
$I = $this;
$I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
$handles=$webdriver->getWindowHandles();
$last_window = next($handles);
$webdriver->switchTo()->window($last_window);
$last_window = next($handles);
$webdriver->switchTo()->window($last_window);
$last_window = next($handles);
$webdriver->switchTo()->window($last_window);
$last_window = next($handles);
$webdriver->switchTo()->window($last_window);
});
}
Created
June 22, 2017 12:31
-
-
Save yugaego/83362570fc2ac9bf4377dd59addb4327 to your computer and use it in GitHub Desktop.
Codeception Browser Tabs Switching (Not Tested)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment