JSInteractionTest.php in Drupal 10
File
core/tests/Drupal/FunctionalJavascriptTests/Tests/JSInteractionTest.php
View source
<?php
namespace Drupal\FunctionalJavascriptTests\Tests;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use WebDriver\Exception;
class JSInteractionTest extends WebDriverTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'js_interaction_test',
];
public function testNotClickable() {
$this
->expectException(Exception::class);
$this
->drupalGet('/js_interaction_test');
$this
->assertSession()
->elementExists('named', [
'link',
'Target link',
])
->click();
}
public function testFieldValueNotSettable() {
$this
->expectException(Exception::class);
$this
->drupalGet('/js_interaction_test');
$this
->assertSession()
->fieldExists('target_field')
->setValue('Test');
}
public function testElementsInteraction() {
$this
->drupalGet('/js_interaction_test');
$this
->clickLink('Remove Blocker Trigger');
$this
->clickLink('Target link');
$this
->clickLink('Enable Field Trigger');
$this
->assertSession()
->fieldExists('target_field')
->setValue('Test');
$this
->assertSession()
->fieldValueEquals('target_field', 'Test');
}
}