Skip to content

Commit a6226b0

Browse files
authored
Added seeNumberOfTabs method (#77)
1 parent 093747c commit a6226b0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Codeception/Module/WebDriver.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3430,6 +3430,20 @@ public function openNewTab()
34303430
$this->switchToNextTab();
34313431
}
34323432

3433+
/**
3434+
* Checks current number of opened tabs
3435+
*
3436+
* ```php
3437+
* <?php
3438+
* $I->seeNumberOfTabs(2);
3439+
* ```
3440+
* @param $number number of tabs
3441+
*/
3442+
public function seeNumberOfTabs($number)
3443+
{
3444+
$this->assertEquals(count($this->webDriver->getWindowHandles()), $number);
3445+
}
3446+
34333447
/**
34343448
* Closes current browser tab and switches to previous active tab.
34353449
*

tests/web/WebDriverTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,14 @@ public function testAppendFieldText()
393393

394394
public function testTypeOnTextField()
395395
{
396+
396397
$this->module->amOnPage('/form/field');
397398
$this->module->fillField('form #name', '');
398399
$this->module->type('Hello world');
399400
$this->module->click('Submit');
400401
$form = data::get('form');
401402
$this->assertEquals('Hello world', $form['name']);
403+
402404
}
403405

404406
public function testAppendFieldTextFails()
@@ -1033,6 +1035,7 @@ public function testBrowserTabs()
10331035
$this->module->seeInCurrentUrl('example2');
10341036
$this->module->switchToNextTab(2);
10351037
$this->module->seeInCurrentUrl('example1');
1038+
$this->module->seeNumberOfTabs(3);
10361039
}
10371040

10381041
public function testPerformOnWithArray()

0 commit comments

Comments
 (0)