diff --git a/src/Driver/CoreDriver.php b/src/Driver/CoreDriver.php index a5940ff91..da89f04e0 100644 --- a/src/Driver/CoreDriver.php +++ b/src/Driver/CoreDriver.php @@ -160,14 +160,14 @@ public function switchToWindow(?string $name = null) } /** - * @param string|null $name + * @param string|int|null $name * * @return void * * @throws UnsupportedDriverActionException When operation not supported by the driver * @throws DriverException When the operation cannot be done */ - public function switchToIFrame(?string $name = null) + public function switchToIFrame($name = null) { throw new UnsupportedDriverActionException('iFrames management is not supported by %s', $this); } diff --git a/src/Driver/DriverInterface.php b/src/Driver/DriverInterface.php index a8a96b3f9..9a7d4cd33 100644 --- a/src/Driver/DriverInterface.php +++ b/src/Driver/DriverInterface.php @@ -184,14 +184,14 @@ public function switchToWindow(?string $name = null); /** * Switches to specific iFrame. * - * @param string|null $name iframe name (null for switching back) + * @param string|int|null $name iframe name/index (null for switching back) * * @return void * * @throws UnsupportedDriverActionException When operation not supported by the driver * @throws DriverException When the operation cannot be done */ - public function switchToIFrame(?string $name = null); + public function switchToIFrame($name = null); /** * Sets specific request header on client. diff --git a/src/Session.php b/src/Session.php index 71a86bdf6..249dadc61 100644 --- a/src/Session.php +++ b/src/Session.php @@ -355,11 +355,11 @@ public function switchToWindow(?string $name = null) /** * Switches to specific iFrame. * - * @param string|null $name iframe name (null for switching back) + * @param string|int|null $name iframe name/index (null for switching back) * * @return void */ - public function switchToIFrame(?string $name = null) + public function switchToIFrame($name = null) { $this->driver->switchToIFrame($name); } diff --git a/tests/SessionTest.php b/tests/SessionTest.php index e1ecc4665..e1115de5b 100644 --- a/tests/SessionTest.php +++ b/tests/SessionTest.php @@ -296,13 +296,29 @@ public function testSwitchToWindow() $this->session->switchToWindow('test'); } - public function testSwitchToIFrame() + /** + * @param string|int $iframeIdentifier + * + * @dataProvider iFrameDataProvider + */ + public function testSwitchToIFrame($iframeIdentifier) { $this->driver->expects($this->once()) ->method('switchToIFrame') - ->with('test'); + ->with($iframeIdentifier); + + $this->session->switchToIFrame($iframeIdentifier); + } - $this->session->switchToIFrame('test'); + /** + * @return array + */ + public function iFrameDataProvider() + { + return array( + 'by name' => array('test'), + 'by index' => array(0), + ); } public function testExecuteScript()