Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests to verify, that iframe switching by an id works #87

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading