Skip to content

Commit

Permalink
Added tests to verify, that iframe switching by an id works
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Feb 23, 2024
1 parent e02c787 commit f7a9cb2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
26 changes: 22 additions & 4 deletions tests/Basic/IFrameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,40 @@

final class IFrameTest extends TestCase
{
public function testIFrame(): void
/**
* @param string $iframeIdentifier
* @param string $elementSelector
* @param string $elementContent
*
* @dataProvider iFrameDataProvider
*/
public function testIFrame($iframeIdentifier, $elementSelector, $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 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 f7a9cb2

Please sign in to comment.