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

Fix tests for Selenium 3.x #60

Closed
wants to merge 5 commits into from

Conversation

mvorisek
Copy link
Contributor

@@ -73,15 +73,15 @@
});

$('.elements input.input.first').keydown(function(ev) {
$('.text-event').text('key downed:' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1);
$('.text-event').text('key downed: ' + (ev.keyCode || ev.charCode) + ' / ' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just unify/improve keyXxx testing

Copy link
Member

Choose a reason for hiding this comment

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

Please don't add a space after :.

$session->switchToWindow(null);

$el = $webAssert->elementExists('css', '#text');
$this->assertSame('Main window div text', $el->getText());

$session->switchToWindow('popup_1');
$session->switchToWindow($popup1WindowHandle);
Copy link
Contributor Author

@mvorisek mvorisek Oct 23, 2022

Choose a reason for hiding this comment

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

since Selenium 3.x and newer Firefox names are handles

and only handle must be sent to webdriver, no name is supported (/w or /wo handle) - fixed in instaclick/php-webdriver#119

Copy link
Member

Choose a reason for hiding this comment

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

Should we preserve backwards-compatible behavior by using the window name on Selenium2 and handle on Selenium3?

Copy link
Member

Choose a reason for hiding this comment

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

The ability to switch a window by name on Selenium 3 was fixed in the minkphp/MinkSelenium2Driver#384.

@@ -60,8 +60,14 @@ public function testSetValueChangeEvent($elementId, $valueForEmpty, $valueForFil

public function setValueChangeEventDataProvider()
{
$file1 = __DIR__ . '/../../web-fixtures/file1.txt';
$file2 = __DIR__ . '/../../web-fixtures/file2.txt';
// paths must be canonical and reachable from browser
Copy link
Contributor Author

Choose a reason for hiding this comment

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

newer browsers, for security reasons, validate the paths if they exist and are canonical, of course from browser POV, thus we must use some paths available within the browser container

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't introduce any BC beaks for the Selenium2?

Copy link
Member

Choose a reason for hiding this comment

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

#67 should fix this part.

Copy link
Member

Choose a reason for hiding this comment

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

The combination of #67 and #88 will fix it.

@@ -14,7 +14,7 @@ public function testIFrame()
$el = $webAssert->elementExists('css', '#text');
$this->assertSame('Main window div text', $el->getText());

$this->getSession()->switchToIFrame('subframe');
$this->getSession()->switchToIFrame(0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

since Selenium 3.x both Chrome and Firefox accepts only iframe index instead of iframe name

passing webdriver element is not supported https://github.com/instaclick/php-webdriver

Copy link
Member

Choose a reason for hiding this comment

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

Should we preserve backwards-compatible behavior by using the iframe name on Selenium2 and index on Selenium3?

Copy link
Member

Choose a reason for hiding this comment

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

The frame switching support by name/id on Selenium 3 was fixed in the minkphp/MinkSelenium2Driver#382.

@mvorisek
Copy link
Contributor Author

PR with test fixes is RTM, I will then submit fixes for the driver itself

tests/Js/EventsTest.php Outdated Show resolved Hide resolved
tests/Js/EventsTest.php Outdated Show resolved Hide resolved
tests/Js/EventsTest.php Outdated Show resolved Hide resolved
@@ -73,15 +73,15 @@
});

$('.elements input.input.first').keydown(function(ev) {
$('.text-event').text('key downed:' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1);
$('.text-event').text('key downed: ' + (ev.keyCode || ev.charCode) + ' / ' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1);
Copy link
Member

Choose a reason for hiding this comment

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

Please don't add a space after :.

web-fixtures/js_test.html Outdated Show resolved Hide resolved
web-fixtures/js_test.html Outdated Show resolved Hide resolved
@mvorisek mvorisek requested a review from aik099 November 18, 2022 11:05
@@ -14,7 +14,7 @@ public function testIFrame()
$el = $webAssert->elementExists('css', '#text');
$this->assertSame('Main window div text', $el->getText());

$this->getSession()->switchToIFrame('subframe');
$this->getSession()->switchToIFrame(0);
Copy link
Member

Choose a reason for hiding this comment

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

Should we preserve backwards-compatible behavior by using the iframe name on Selenium2 and index on Selenium3?

@@ -60,8 +60,14 @@ public function testSetValueChangeEvent($elementId, $valueForEmpty, $valueForFil

public function setValueChangeEventDataProvider()
{
$file1 = __DIR__ . '/../../web-fixtures/file1.txt';
$file2 = __DIR__ . '/../../web-fixtures/file2.txt';
// paths must be canonical and reachable from browser
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't introduce any BC beaks for the Selenium2?

$session->switchToWindow(null);

$el = $webAssert->elementExists('css', '#text');
$this->assertSame('Main window div text', $el->getText());

$session->switchToWindow('popup_1');
$session->switchToWindow($popup1WindowHandle);
Copy link
Member

Choose a reason for hiding this comment

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

Should we preserve backwards-compatible behavior by using the window name on Selenium2 and handle on Selenium3?

@@ -14,7 +14,7 @@ public function testIFrame()
$el = $webAssert->elementExists('css', '#text');
$this->assertSame('Main window div text', $el->getText());

$this->getSession()->switchToIFrame('subframe');
$this->getSession()->switchToIFrame(0);
Copy link
Member

Choose a reason for hiding this comment

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

The frame switching support by name/id on Selenium 3 was fixed in the minkphp/MinkSelenium2Driver#382.

@@ -60,8 +60,14 @@ public function testSetValueChangeEvent($elementId, $valueForEmpty, $valueForFil

public function setValueChangeEventDataProvider()
{
$file1 = __DIR__ . '/../../web-fixtures/file1.txt';
$file2 = __DIR__ . '/../../web-fixtures/file2.txt';
// paths must be canonical and reachable from browser
Copy link
Member

Choose a reason for hiding this comment

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

The combination of #67 and #88 will fix it.

$session->switchToWindow(null);

$el = $webAssert->elementExists('css', '#text');
$this->assertSame('Main window div text', $el->getText());

$session->switchToWindow('popup_1');
$session->switchToWindow($popup1WindowHandle);
Copy link
Member

Choose a reason for hiding this comment

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

The ability to switch a window by name on Selenium 3 was fixed in the minkphp/MinkSelenium2Driver#384.

@@ -99,13 +99,13 @@ public function testKeyboardEvents($modifier, $eventProperties)
$event = $webAssert->elementExists('css', '.elements .text-event');

$input1->keyDown('u', $modifier);
$this->assertEquals('key downed:'.$eventProperties, $event->getText());
$this->assertEquals('key downed:117 / ' . $eventProperties, $event->getText());
Copy link
Member

Choose a reason for hiding this comment

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

@mvorisek , why this is needed?

Copy link
Contributor Author

@mvorisek mvorisek Feb 25, 2024

Choose a reason for hiding this comment

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

key presses asserts the code, but key downed not, the answer is: it is not needed, but wanted to be tested - feel free to cherrypick this from this PR (1st commit)

@uuf6429
Copy link
Member

uuf6429 commented Feb 24, 2024

@aik099 @mvorisek considering we are using the same test-suite for selenium 2, 3 and 4 in webdriver-classic-driver, I don't think this PR is relevant any more (or at least, it won't really fix selenium3-specific test problems).

@aik099
Copy link
Member

aik099 commented Feb 25, 2024

@uuf6429 , as for fixing the part I agree (the driver-specific PRs for almost all issues were created and mentioned in the minkphp/MinkSelenium2Driver#383).

I'm not closing this PR yet, because I'm curious what was the reasoning behind key code adding in the tests.

@aik099
Copy link
Member

aik099 commented Feb 25, 2024

Closing, because selenium 2 driver code was changed instead (PRs not merged yet) to make tests pass.

@aik099 aik099 closed this Feb 25, 2024
@mvorisek mvorisek deleted the fix_tests_for_selenium_3 branch February 25, 2024 23:28
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