Skip to content

Commit

Permalink
Merge pull request #87 from aik099/frame-switching-by-index
Browse files Browse the repository at this point in the history
Added tests to verify, that iframe switching by an id works
  • Loading branch information
aik099 authored Feb 27, 2024
2 parents 811a5bf + 0bdf4f6 commit f9d36b6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
22 changes: 18 additions & 4 deletions tests/Basic/IFrameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,36 @@

final class IFrameTest extends TestCase
{
public function testIFrame(): void
/**
* @dataProvider iFrameDataProvider
*/
public function testIFrame(string $iframeIdentifier, string $elementSelector, string $elementContent): void
{
$this->getSession()->visit($this->pathTo('/iframe.html'));
$webAssert = $this->getAssertSession();

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

$this->getSession()->switchToIFrame('subframe');
$this->getSession()->switchToIFrame($iframeIdentifier);

$el = $webAssert->elementExists('css', '#text');
$this->assertSame('iFrame div text', $el->getText());
$el = $webAssert->elementExists('css', $elementSelector);
$this->assertSame($elementContent, $el->getText());

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

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

/**
* @return array
*/
public static function iFrameDataProvider()
{
return array(
'by name' => array('subframe_by_name', '#text', 'iFrame div text'),
'by id' => array('subframe_by_id', '#foobar', 'Some accentués characters'),
);
}
}
4 changes: 3 additions & 1 deletion web-fixtures/iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<html>
<body>

<iframe src="iframe_inner.html" name="subframe"></iframe>
<iframe src="iframe_inner.html" name="subframe_by_name"></iframe>

<iframe src="issue131.html" name="subframe_by_id"></iframe>

<div id="text">
Main window div text
Expand Down

0 comments on commit f9d36b6

Please sign in to comment.