|
6 | 6 |
|
7 | 7 | final class IFrameTest extends TestCase |
8 | 8 | { |
9 | | - public function testIFrame(): void |
| 9 | + /** |
| 10 | + * @dataProvider iFrameDataProvider |
| 11 | + */ |
| 12 | + public function testIFrame(string $iframeIdentifier, string $elementSelector, string $elementContent): void |
10 | 13 | { |
11 | 14 | $this->getSession()->visit($this->pathTo('/iframe.html')); |
12 | 15 | $webAssert = $this->getAssertSession(); |
13 | 16 |
|
14 | 17 | $el = $webAssert->elementExists('css', '#text'); |
15 | 18 | $this->assertSame('Main window div text', $el->getText()); |
16 | 19 |
|
17 | | - $this->getSession()->switchToIFrame('subframe'); |
| 20 | + $this->getSession()->switchToIFrame($iframeIdentifier); |
18 | 21 |
|
19 | | - $el = $webAssert->elementExists('css', '#text'); |
20 | | - $this->assertSame('iFrame div text', $el->getText()); |
| 22 | + $el = $webAssert->elementExists('css', $elementSelector); |
| 23 | + $this->assertSame($elementContent, $el->getText()); |
21 | 24 |
|
22 | 25 | $this->getSession()->switchToIFrame(); |
23 | 26 |
|
24 | 27 | $el = $webAssert->elementExists('css', '#text'); |
25 | 28 | $this->assertSame('Main window div text', $el->getText()); |
26 | 29 | } |
| 30 | + |
| 31 | + /** |
| 32 | + * @return array |
| 33 | + */ |
| 34 | + public static function iFrameDataProvider() |
| 35 | + { |
| 36 | + return array( |
| 37 | + 'by name' => array('subframe_by_name', '#text', 'iFrame div text'), |
| 38 | + 'by id' => array('subframe_by_id', '#foobar', 'Some accentués characters'), |
| 39 | + ); |
| 40 | + } |
27 | 41 | } |
0 commit comments