diff --git a/composer.json b/composer.json index 5e69c0e..7d613bf 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,8 @@ "phpstan/phpstan": "^1.10", "phpstan/phpstan-phpunit": "^1.3", "phpstan/phpstan-symfony": "^1.3", - "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0 || ^7.0 || ^8.0" + "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0 || ^7.0 || ^8.0", + "jetbrains/phpstorm-attributes": "^1.2" }, "conflict": { "symfony/http-foundation": "<4.4 || >=9", diff --git a/tests/Form/GeneralTest.php b/tests/Form/GeneralTest.php index a55f0fa..9393412 100644 --- a/tests/Form/GeneralTest.php +++ b/tests/Form/GeneralTest.php @@ -48,7 +48,7 @@ public function testBasicForm(): void $page->pressButton('Save'); - if ($this->safePageWait(5000, 'document.getElementById("first") !== null')) { + if ($this->safePageWait(5000, 'document.querySelector("#first") !== null')) { $this->assertEquals('Anket for Konstantin', $webAssert->elementExists('css', 'h1')->getText()); $this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText()); $this->assertEquals('Lastname: Kudryashov', $webAssert->elementExists('css', '#last')->getText()); @@ -70,7 +70,7 @@ public function testFormSubmitWays(string $submitVia): void $page->pressButton($submitVia); - if ($this->safePageWait(5000, 'document.getElementById("first") !== null')) { + if ($this->safePageWait(5000, 'document.querySelector("#first") !== null')) { $this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText()); } else { $this->fail('Form was never submitted'); @@ -98,7 +98,7 @@ public function testFormSubmit(): void $webAssert->elementExists('xpath', 'descendant-or-self::form[1]')->submit(); - if ($this->safePageWait(5000, 'document.getElementById("first") !== null')) { + if ($this->safePageWait(5000, 'document.querySelector("#first") !== null')) { $this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText()); } } @@ -113,7 +113,7 @@ public function testFormSubmitWithoutButton(): void $webAssert->elementExists('xpath', 'descendant-or-self::form[1]')->submit(); - if ($this->safePageWait(5000, 'document.getElementById("first") !== null')) { + if ($this->safePageWait(5000, 'document.querySelector("#first") !== null')) { $this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText()); } } @@ -204,7 +204,7 @@ public function testAdvancedForm(): void $button->press(); - if ($this->safePageWait(5000, 'document.getElementsByTagName("title") === "Advanced form save"')) { + if ($this->safePageWait(5000, 'document.querySelector("title")?.textContent === "Advanced form save"')) { $out = <<<'OUT' array( agreement = `on`, @@ -245,7 +245,7 @@ public function testQuoteInValue(): void $button->press(); - if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) { + if ($this->safePageWait(5000, 'document.querySelector("title") !== null')) { $out = <<<'OUT' first_name = `Foo "item"`, last_name = `Bar`, diff --git a/tests/Form/Html5Test.php b/tests/Form/Html5Test.php index 928a422..461196c 100644 --- a/tests/Form/Html5Test.php +++ b/tests/Form/Html5Test.php @@ -24,7 +24,7 @@ public function testHtml5FormInputAttribute(): void $page->pressButton('Submit in form'); - if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) { + if ($this->safePageWait(5000, 'document.querySelector("title") !== null')) { $out = <<<'OUT' first_name = `John`, last_name = `Doe`, @@ -72,7 +72,7 @@ public function testHtml5FormButtonAttribute(): void $page->pressButton('Submit outside form'); - if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) { + if ($this->safePageWait(5000, 'document.querySelector("title") !== null')) { $out = <<<'OUT' first_name = `John`, last_name = `Doe`, @@ -91,7 +91,7 @@ public function testHtml5FormOutside(): void $page->pressButton('Submit separate form'); - if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) { + if ($this->safePageWait(5000, 'document.querySelector("title") !== null')) { $out = <<<'OUT' other_field = `hello`, OUT; @@ -137,7 +137,7 @@ public function testHtml5FormAction(): void $page->fillField('first_name', 'Jimmy'); $page->pressButton('Submit to basic form'); - if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) { + if ($this->safePageWait(5000, 'document.querySelector("title") !== null')) { $this->assertStringContainsString('