From f7a9cb2cb9cf74b1e764f66c2d6c7f9717d6000d Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 18 Feb 2024 15:13:19 +0200 Subject: [PATCH] Added tests to verify, that iframe switching by an id works --- tests/Basic/IFrameTest.php | 26 ++++++++++++++++++++++---- web-fixtures/iframe.html | 4 +++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/tests/Basic/IFrameTest.php b/tests/Basic/IFrameTest.php index 08441a4..ed7d666 100644 --- a/tests/Basic/IFrameTest.php +++ b/tests/Basic/IFrameTest.php @@ -6,7 +6,14 @@ 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(); @@ -14,14 +21,25 @@ public function testIFrame(): void $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'), + ); + } } diff --git a/web-fixtures/iframe.html b/web-fixtures/iframe.html index c54797f..f429658 100644 --- a/web-fixtures/iframe.html +++ b/web-fixtures/iframe.html @@ -2,7 +2,9 @@ - + + +
Main window div text