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

Iframe switch - Send element info as selenium 4 require it #361

Closed
wants to merge 3 commits into from

Conversation

omarlopesino
Copy link

Problem

When I try to switch to an iframe with the switchToIframe method I receive the following error:

invalid argument: 'id' can not be string

Steps to reproduce

Call the method 'switchToIframe' method of the Selenium2DriverClass passing the 'id' of the iframe it is needed to switch to as a string:

  $driver->switchToIframe('iframe-id');

Proposed resolution

According to the current specs , it must be an object that contains the element ID inside. So, in the switchToIframe method, we must change the format to send the element ID (UUID) of the element we are switching to, instead of the plain id passed by arguments. When the name of the iframe passed is null, we must send nothing.

Currently, this solution makes the library not compatible with selenium 3, but as far as I understand selenium 4 is stable so it should be replaced.

@aik099
Copy link
Member

aik099 commented Feb 17, 2023

Currently, this solution makes the library not compatible with selenium 3, but as far as I understand selenium 4 is stable so it should be replaced.

Still a BC break.

if (!empty($name)) {
$element = $this->wdSession->element('name', $name);
$element_info = [
'ELEMENT' => $element->getID(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for this PR, it will solve minkphp/driver-testsuite#60

'ELEMENT' key is not compatible with W3C spec, see instaclick/php-webdriver@b5b18bd

Will tests pass if you pass $element directly like $this->wdSession->frame(array('id' => $element))?

Copy link
Member

Choose a reason for hiding this comment

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

Will tests pass if you pass $element directly like $this->wdSession->frame(array('id' => $element))?

No, tests will fail, because instaclick/php-webdriver doesn't support this. The instaclick/php-webdriver#132 should add this functionality.

In the meanwhile the workaround was created in the #382.

@aik099
Copy link
Member

aik099 commented Feb 24, 2024

The frame switching support (works for both Selenium 2 and 3) was implemented in #382.

For Selenium 4 support use the https://github.com/minkphp/webdriver-classic-driver driver.

Thank you, @mvorisek .

@aik099 aik099 closed this Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants