diff --git a/tests/Basic/IFrameTest.php b/tests/Basic/IFrameTest.php index 08441a4..24f14e1 100644 --- a/tests/Basic/IFrameTest.php +++ b/tests/Basic/IFrameTest.php @@ -6,7 +6,10 @@ 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(); @@ -14,14 +17,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 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'), + ); + } } 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