diff --git a/tests/Form/GeneralTest.php b/tests/Form/GeneralTest.php index a55f0fa..77df511 100644 --- a/tests/Form/GeneralTest.php +++ b/tests/Form/GeneralTest.php @@ -48,11 +48,9 @@ public function testBasicForm(): void $page->pressButton('Save'); - if ($this->safePageWait(5000, 'document.getElementById("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()); - } + $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,11 +68,7 @@ public function testFormSubmitWays(string $submitVia): void $page->pressButton($submitVia); - if ($this->safePageWait(5000, 'document.getElementById("first") !== null')) { - $this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText()); - } else { - $this->fail('Form was never submitted'); - } + $this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText()); } /** @@ -98,9 +92,7 @@ public function testFormSubmit(): void $webAssert->elementExists('xpath', 'descendant-or-self::form[1]')->submit(); - if ($this->safePageWait(5000, 'document.getElementById("first") !== null')) { - $this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText()); - } + $this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText()); } public function testFormSubmitWithoutButton(): void @@ -113,9 +105,7 @@ public function testFormSubmitWithoutButton(): void $webAssert->elementExists('xpath', 'descendant-or-self::form[1]')->submit(); - if ($this->safePageWait(5000, 'document.getElementById("first") !== null')) { - $this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText()); - } + $this->assertEquals('Firstname: Konstantin', $webAssert->elementExists('css', '#first')->getText()); } public function testBasicGetForm(): void @@ -204,8 +194,8 @@ public function testAdvancedForm(): void $button->press(); - if ($this->safePageWait(5000, 'document.getElementsByTagName("title") === "Advanced form save"')) { - $out = <<<'OUT' + $this->assertStringContainsString( + <<<'OUT' array( agreement = `on`, email = `ever.zet@gmail.com`, @@ -218,9 +208,9 @@ public function testAdvancedForm(): void ) some_file.txt 1 uploaded file -OUT; - $this->assertStringContainsString($out, $page->getContent()); - } +OUT, + $page->getContent() + ); } public function testQuoteInValue(): void @@ -245,22 +235,27 @@ public function testQuoteInValue(): void $button->press(); - if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) { - $out = <<<'OUT' + $this->assertThat( + $page->getContent(), + $this->logicalOr( + $this->stringContains( + <<<'OUT' first_name = `Foo "item"`, last_name = `Bar`, -OUT; +OUT + ), + $this->stringContains( // Escaping of double quotes are optional in HTML text nodes. Even though our backend escapes // the quote in the HTML when returning it, browsers may apply only the minimal escaping in // the content they expose to Selenium depending of how they build it (they might serialize - // their DOM again rathet than returning the raw HTTP response content). - $minEscapedOut = <<<'OUT' + // their DOM again rather than returning the raw HTTP response content). + <<<'OUT' first_name = `Foo "item"`, last_name = `Bar`, -OUT; - - $this->assertThat($page->getContent(), $this->logicalOr($this->stringContains($out), $this->stringContains($minEscapedOut))); - } +OUT + ) + ) + ); } public function testMultiInput(): void diff --git a/tests/Form/Html5Test.php b/tests/Form/Html5Test.php index 928a422..ed24ee2 100644 --- a/tests/Form/Html5Test.php +++ b/tests/Form/Html5Test.php @@ -24,14 +24,14 @@ public function testHtml5FormInputAttribute(): void $page->pressButton('Submit in form'); - if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) { - $out = <<<'OUT' + $this->assertStringContainsString( + <<<'OUT' first_name = `John`, last_name = `Doe`, -OUT; - $this->assertStringContainsString($out, $page->getContent()); - $this->assertStringNotContainsString('other_field', $page->getContent()); - } +OUT, + $page->getContent() + ); + $this->assertStringNotContainsString('other_field', $page->getContent()); } public function testHtml5FormRadioAttribute(): void @@ -72,14 +72,14 @@ public function testHtml5FormButtonAttribute(): void $page->pressButton('Submit outside form'); - if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) { - $out = <<<'OUT' + $this->assertStringContainsString( + <<<'OUT' first_name = `John`, last_name = `Doe`, submit_button = `test`, -OUT; - $this->assertStringContainsString($out, $page->getContent()); - } +OUT, + $page->getContent() + ); } public function testHtml5FormOutside(): void @@ -91,13 +91,13 @@ public function testHtml5FormOutside(): void $page->pressButton('Submit separate form'); - if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) { - $out = <<<'OUT' + $this->assertStringContainsString( + <<<'OUT' other_field = `hello`, -OUT; - $this->assertStringContainsString($out, $page->getContent()); - $this->assertStringNotContainsString('first_name', $page->getContent()); - } +OUT, + $page->getContent() + ); + $this->assertStringNotContainsString('first_name', $page->getContent()); } public function testHtml5Types(): void @@ -115,7 +115,8 @@ public function testHtml5Types(): void $page->pressButton('Submit'); - $out = <<<'OUT' + $this->assertStringContainsString( + <<<'OUT' color = `#ff00aa`, date = `1111-11-11`, email = `mink@example.org`, @@ -124,9 +125,9 @@ public function testHtml5Types(): void submit_button = `Submit`, time = `14:12`, url = `https://mink.behat.org/`, -OUT; - - $this->assertStringContainsString($out, $page->getContent()); +OUT, + $page->getContent() + ); } public function testHtml5FormAction(): void @@ -137,10 +138,8 @@ public function testHtml5FormAction(): void $page->fillField('first_name', 'Jimmy'); $page->pressButton('Submit to basic form'); - if ($this->safePageWait(5000, 'document.getElementsByTagName("title") !== null')) { - $this->assertStringContainsString('