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

Allow specify frame index in the "switchToIFrame" driver/session method #867

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions src/Driver/CoreDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to $nameOrIndex in this and similar places?

{
throw new UnsupportedDriverActionException('iFrames management is not supported by %s', $this);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Driver/DriverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
22 changes: 19 additions & 3 deletions tests/SessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading