Skip to content

Commit f9d36b6

Browse files
authored
Merge pull request #87 from aik099/frame-switching-by-index
Added tests to verify, that iframe switching by an id works
2 parents 811a5bf + 0bdf4f6 commit f9d36b6

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

tests/Basic/IFrameTest.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,36 @@
66

77
final class IFrameTest extends TestCase
88
{
9-
public function testIFrame(): void
9+
/**
10+
* @dataProvider iFrameDataProvider
11+
*/
12+
public function testIFrame(string $iframeIdentifier, string $elementSelector, string $elementContent): void
1013
{
1114
$this->getSession()->visit($this->pathTo('/iframe.html'));
1215
$webAssert = $this->getAssertSession();
1316

1417
$el = $webAssert->elementExists('css', '#text');
1518
$this->assertSame('Main window div text', $el->getText());
1619

17-
$this->getSession()->switchToIFrame('subframe');
20+
$this->getSession()->switchToIFrame($iframeIdentifier);
1821

19-
$el = $webAssert->elementExists('css', '#text');
20-
$this->assertSame('iFrame div text', $el->getText());
22+
$el = $webAssert->elementExists('css', $elementSelector);
23+
$this->assertSame($elementContent, $el->getText());
2124

2225
$this->getSession()->switchToIFrame();
2326

2427
$el = $webAssert->elementExists('css', '#text');
2528
$this->assertSame('Main window div text', $el->getText());
2629
}
30+
31+
/**
32+
* @return array
33+
*/
34+
public static function iFrameDataProvider()
35+
{
36+
return array(
37+
'by name' => array('subframe_by_name', '#text', 'iFrame div text'),
38+
'by id' => array('subframe_by_id', '#foobar', 'Some accentués characters'),
39+
);
40+
}
2741
}

web-fixtures/iframe.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<html>
33
<body>
44

5-
<iframe src="iframe_inner.html" name="subframe"></iframe>
5+
<iframe src="iframe_inner.html" name="subframe_by_name"></iframe>
6+
7+
<iframe src="issue131.html" name="subframe_by_id"></iframe>
68

79
<div id="text">
810
Main window div text

0 commit comments

Comments
 (0)