diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php index 448cb9d..beee43b 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php @@ -21,20 +21,20 @@ class JavascriptStatesTest extends JavascriptTestBase { */ public function testJavascriptStates() { $this->drupalGet('form-test/javascript-states-form'); - $driver = $this->getSession()->getDriver(); + $page = $this->getSession()->getPage(); $this->assertElementNotVisible('#edit-name'); // This should make the name element visible. - $this->click('#edit-anonymous'); + $page->uncheckField('I prefer to remain anonymous'); $this->assertElementVisible('#edit-name'); // This should make the name element invisible. - $this->click('#edit-anonymous'); + $page->checkField('I prefer to remain anonymous'); $this->assertElementNotVisible('#edit-name'); // This should make the name element visible. - $this->click('#edit-anonymous'); + $page->uncheckField('I prefer to remain anonymous'); $this->assertElementVisible('#edit-name'); // Ensure all the details elements are invisible. @@ -71,12 +71,12 @@ public function testJavascriptStates() { $this->assertElementVisible('#edit-average'); $this->assertElementNotVisible('#edit-comment--description'); - $driver->selectOption($this->cssSelect('#edit-how-many-years'), '5'); + $page->selectFieldOption('How many years have you completed?', '5'); $this->assertElementVisible('#edit-comment--description'); $this->assertElementNotVisible('#edit-country-writein'); - $driver->selectOption($this->cssSelect('#edit-school-country'), 'Other'); + $page->selectFieldOption('In what country is your college or university located?', 'Other'); $this->assertElementVisible('#edit-country-writein'); - $driver->selectOption($this->cssSelect('#edit-school-country'), 'UK'); + $page->selectFieldOption('In what country is your college or university located?', 'UK'); $this->assertElementNotVisible('#edit-country-writein'); // Graduate form testing. @@ -86,19 +86,19 @@ public function testJavascriptStates() { $this->assertElementVisible('#edit-graduate'); $this->assertElementNotVisible('#edit-average'); - $this->assertFalse($driver->isChecked($this->cssSelect('#edit-info-provide')), '#edit-info-provide is not checked'); - $driver->setValue($this->cssSelect('#edit-more-info'), 'Some text'); - $this->assertTrue($driver->isChecked($this->cssSelect('#edit-info-provide')), '#edit-info-provide is checked'); - // This is not working for some reason. - $driver->setValue($this->cssSelect('#edit-more-info'), NULL); - $this->assertJsCondition('!jQuery("#edit-more-info").val()'); - $this->assertFalse($driver->isChecked($this->cssSelect('#edit-info-provide')), '#edit-info-provide is not checked'); + $this->assertSession()->checkboxNotChecked('Check here if you have provided information above'); + $page->fillField('Please describe your graduate studies', 'Some text'); + $this->assertSession()->checkboxChecked('Check here if you have provided information above'); + $page->fillField('Please describe your graduate studies', ''); + // Empty and filled states are triggered on keyup event. + $page->findField('Please describe your graduate studies')->keyUp('a'); + $this->assertSession()->checkboxNotChecked('Check here if you have provided information above'); // Feedback testing. $this->assertElementNotVisible('#edit-feedback'); - $this->click('#edit-expand-more-info'); + $page->checkField('Check here if you want to add more information.'); $this->assertElementVisible('#edit-feedback'); - $this->click('#edit-expand-more-info'); + $page->uncheckField('Check here if you want to add more information.'); $this->assertElementNotVisible('#edit-feedback'); } diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php index 55c7f77..2862d4c 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php @@ -44,7 +44,7 @@ protected function initMink() { */ protected function assertElementVisible($css_selector, $message = '') { $message = $message ?: "Element ($css_selector) is visible."; - $this->assertTrue($this->getSession()->getDriver()->isVisible($this->cssSelect($css_selector)), $message); + $this->assertTrue($this->getSession()->getDriver()->isVisible(CssSelector::toXPath($css_selector)), $message); } /** @@ -57,7 +57,7 @@ protected function assertElementVisible($css_selector, $message = '') { */ protected function assertElementNotVisible($css_selector, $message = '') { $message = $message ?: "Element ($css_selector) is not visible."; - $this->assertFalse($this->getSession()->getDriver()->isVisible($this->cssSelect($css_selector)), $message); + $this->assertFalse($this->getSession()->getDriver()->isVisible(CssSelector::toXPath($css_selector)), $message); } /** diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index a3fa3a7..8d8ea2b 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -20,7 +20,6 @@ use Drupal\Core\StreamWrapper\StreamWrapperInterface; use Drupal\Core\Test\TestRunnerKernel; use Drupal\Core\Url; -use Drupal\simpletest\AssertContentTrait; use Drupal\simpletest\RandomGeneratorTrait; use Drupal\simpletest\SessionTestTrait; use Drupal\simpletest\WebAssert; @@ -45,7 +44,6 @@ * @todo Move these into Drupal\Tests namespace and leave deprecated stubs * in simpletest module. See https://www.drupal.org/node/2702281 */ - use AssertContentTrait; use RandomGeneratorTrait; use SessionTestTrait;