From c8cf063b980f50291f371a2c2f3b23b86ac53da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sun, 23 Oct 2022 12:38:06 +0200 Subject: [PATCH 1/5] Test pressed charCode also for keydown event --- tests/Js/EventsTest.php | 6 +++--- web-fixtures/js_test.html | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Js/EventsTest.php b/tests/Js/EventsTest.php index f06999b..b323476 100644 --- a/tests/Js/EventsTest.php +++ b/tests/Js/EventsTest.php @@ -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()); $input2->keyPress('r', $modifier); - $this->assertEquals('key pressed:114 / '.$eventProperties, $event->getText()); + $this->assertEquals('key pressed: 114 / ' . $eventProperties, $event->getText()); $input3->keyUp(78, $modifier); - $this->assertEquals('key upped:78 / '.$eventProperties, $event->getText()); + $this->assertEquals('key upped: 78 / ' . $eventProperties, $event->getText()); } public function provideKeyboardEventsModifiers() diff --git a/web-fixtures/js_test.html b/web-fixtures/js_test.html index b18047e..b902534 100644 --- a/web-fixtures/js_test.html +++ b/web-fixtures/js_test.html @@ -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); }); $('.elements input.input.second').keypress(function(ev) { - $('.text-event').text('key pressed:' + (ev.keyCode || ev.charCode) + ' / ' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1); + $('.text-event').text('key pressed: ' + (ev.keyCode || ev.charCode) + ' / ' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1); }); $('.elements input.input.third').keyup(function(ev) { - $('.text-event').text('key upped:' + (ev.keyCode || ev.charCode) + ' / ' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1); + $('.text-event').text('key upped: ' + (ev.keyCode || ev.charCode) + ' / ' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1); }); $( "#draggable" ).draggable(); From 28280b258f2daa53cfd5a444b8f7138f7eafb8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 24 Oct 2022 00:55:52 +0200 Subject: [PATCH 2/5] Fix iframe switching test for Selenium 3.x --- tests/Basic/IFrameTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Basic/IFrameTest.php b/tests/Basic/IFrameTest.php index 0ed0f9e..2f4dce6 100644 --- a/tests/Basic/IFrameTest.php +++ b/tests/Basic/IFrameTest.php @@ -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); $el = $webAssert->elementExists('css', '#text'); $this->assertSame('iFrame div text', $el->getText()); From 147493b517636530992a92d84146811c9e354c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 24 Oct 2022 00:56:20 +0200 Subject: [PATCH 3/5] Fix input file paths must be reachable from browser --- tests/Js/ChangeEventTest.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/Js/ChangeEventTest.php b/tests/Js/ChangeEventTest.php index 8ff837d..784bf3b 100644 --- a/tests/Js/ChangeEventTest.php +++ b/tests/Js/ChangeEventTest.php @@ -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 + if (getenv('GITHUB_ACTION')) { + $file1 = '/etc/hosts.allow'; + $file2 = '/etc/hosts.deny'; + } else { + $file1 = realpath(__DIR__ . '/../../web-fixtures/file1.txt'); + $file2 = realpath(__DIR__ . '/../../web-fixtures/file2.txt'); + } return array( 'input default' => array('the-input-default', 'from empty', 'from existing'), From 545be837b8cba365b144c07858be9c2b128323c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 24 Oct 2022 00:56:49 +0200 Subject: [PATCH 4/5] Fix WindowTest::testWindow test for Selenium 3.x --- tests/Js/WindowTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Js/WindowTest.php b/tests/Js/WindowTest.php index 998db8c..7ce44dd 100644 --- a/tests/Js/WindowTest.php +++ b/tests/Js/WindowTest.php @@ -14,19 +14,21 @@ public function testWindow() $webAssert = $this->getAssertSession(); $page->clickLink('Popup #1'); + $popup1WindowHandle = array_slice($session->getDriver()->getWindowNames(), -1)[0]; $session->switchToWindow(null); $page->clickLink('Popup #2'); + $popup2WindowHandle = array_slice($session->getDriver()->getWindowNames(), -1)[0]; $session->switchToWindow(null); $el = $webAssert->elementExists('css', '#text'); $this->assertSame('Main window div text', $el->getText()); - $session->switchToWindow('popup_1'); + $session->switchToWindow($popup1WindowHandle); $el = $webAssert->elementExists('css', '#text'); $this->assertSame('Popup#1 div text', $el->getText()); - $session->switchToWindow('popup_2'); + $session->switchToWindow($popup2WindowHandle); $el = $webAssert->elementExists('css', '#text'); $this->assertSame('Popup#2 div text', $el->getText()); From 38c6b3dcd8d06606421815d68b978c635b79b988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 18 Nov 2022 12:03:55 +0100 Subject: [PATCH 5/5] address review feedback --- tests/Js/EventsTest.php | 6 +++--- web-fixtures/js_test.html | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Js/EventsTest.php b/tests/Js/EventsTest.php index b323476..5e25d6d 100644 --- a/tests/Js/EventsTest.php +++ b/tests/Js/EventsTest.php @@ -99,13 +99,13 @@ public function testKeyboardEvents($modifier, $eventProperties) $event = $webAssert->elementExists('css', '.elements .text-event'); $input1->keyDown('u', $modifier); - $this->assertEquals('key downed: 117 / ' . $eventProperties, $event->getText()); + $this->assertEquals('key downed:117 / ' . $eventProperties, $event->getText()); $input2->keyPress('r', $modifier); - $this->assertEquals('key pressed: 114 / ' . $eventProperties, $event->getText()); + $this->assertEquals('key pressed:114 / ' . $eventProperties, $event->getText()); $input3->keyUp(78, $modifier); - $this->assertEquals('key upped: 78 / ' . $eventProperties, $event->getText()); + $this->assertEquals('key upped:78 / ' . $eventProperties, $event->getText()); } public function provideKeyboardEventsModifiers() diff --git a/web-fixtures/js_test.html b/web-fixtures/js_test.html index b902534..b25e3d0 100644 --- a/web-fixtures/js_test.html +++ b/web-fixtures/js_test.html @@ -73,15 +73,15 @@ }); $('.elements input.input.first').keydown(function(ev) { - $('.text-event').text('key downed: ' + (ev.keyCode || ev.charCode) + ' / ' + 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); }); $('.elements input.input.second').keypress(function(ev) { - $('.text-event').text('key pressed: ' + (ev.keyCode || ev.charCode) + ' / ' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1); + $('.text-event').text('key pressed:' + (ev.keyCode || ev.charCode) + ' / ' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1); }); $('.elements input.input.third').keyup(function(ev) { - $('.text-event').text('key upped: ' + (ev.keyCode || ev.charCode) + ' / ' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1); + $('.text-event').text('key upped:' + (ev.keyCode || ev.charCode) + ' / ' + ev.altKey * 1 + ' / ' + ev.ctrlKey * 1 + ' / ' + ev.shiftKey * 1 + ' / ' + ev.metaKey * 1); }); $( "#draggable" ).draggable();