Issue #3211838 by mondrake, longwave: Convert assertions involving use of xpath on spans to WebAssert
(cherry picked from commit 13c5855165
)
merge-requests/688/head
parent
06cdce73dc
commit
5e5ec6c500
|
@ -74,8 +74,8 @@ class NodeTitleTest extends NodeTestBase {
|
|||
$xpath = '//nav[@class="breadcrumb"]/ol/li[last()]/a';
|
||||
$this->assertEqual($this->xpath($xpath)[0]->getText(), $node->label(), 'Node breadcrumb is equal to node title.', 'Node');
|
||||
|
||||
// Test node title in comment preview.
|
||||
$this->assertEqual($this->xpath('//article[contains(concat(" ", normalize-space(@class), " "), :node-class)]/h2/a/span', [':node-class' => ' node--type-' . $node->bundle() . ' '])[0]->getText(), $node->label(), 'Node preview title is equal to node title.', 'Node');
|
||||
// Verify that node preview title is equal to node title.
|
||||
$this->assertSession()->elementTextEquals('xpath', "//article[contains(concat(' ', normalize-space(@class), ' '), ' node--type-{$node->bundle()} ')]/h2/a/span", $node->label());
|
||||
|
||||
// Test node title is clickable on teaser list (/node).
|
||||
$this->drupalGet('node');
|
||||
|
|
|
@ -98,8 +98,8 @@ class NodeViewTest extends NodeTestBase {
|
|||
$this->assertLessThan(strlen($title), mb_strlen($title, 'utf-8'));
|
||||
$node = $this->drupalCreateNode(['title' => $title]);
|
||||
$this->drupalGet($node->toUrl());
|
||||
$result = $this->xpath('//span[contains(@class, "field--name-title")]');
|
||||
$this->assertEqual($title, $result[0]->getText(), 'The passed title was returned.');
|
||||
// Verify that the passed title was returned.
|
||||
$this->assertSession()->elementTextEquals('xpath', '//span[contains(@class, "field--name-title")]', $title);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,11 +65,8 @@ class ElementsLabelsTest extends BrowserTestBase {
|
|||
$this->assertSession()->elementExists('xpath', '//div[contains(@class, "js-form-item-form-textfield-test-title-invisible") and contains(@class, "form-no-label")]');
|
||||
|
||||
// Check #field_prefix and #field_suffix placement.
|
||||
$elements = $this->xpath('//span[@class="field-prefix"]/following-sibling::div[@id="edit-form-radios-test"]');
|
||||
$this->assertTrue(isset($elements[0]), 'Properly placed the #field_prefix element after the label and before the field.');
|
||||
|
||||
$elements = $this->xpath('//span[@class="field-suffix"]/preceding-sibling::div[@id="edit-form-radios-test"]');
|
||||
$this->assertTrue(isset($elements[0]), 'Properly places the #field_suffix element immediately after the form field.');
|
||||
$this->assertSession()->elementExists('xpath', '//span[@class="field-prefix"]/following-sibling::div[@id="edit-form-radios-test"]');
|
||||
$this->assertSession()->elementExists('xpath', '//span[@class="field-suffix"]/preceding-sibling::div[@id="edit-form-radios-test"]');
|
||||
|
||||
// Check #prefix and #suffix placement. Both elements placed before the form
|
||||
// item.
|
||||
|
@ -80,11 +77,13 @@ class ElementsLabelsTest extends BrowserTestBase {
|
|||
$this->assertSession()->elementAttributeContains('css', '#edit-form-checkboxes-title-attribute', 'title', 'Checkboxes test (Required)');
|
||||
$this->assertSession()->elementAttributeContains('css', '#edit-form-radios-title-attribute', 'title', 'Radios test (Required)');
|
||||
|
||||
$elements = $this->xpath('//fieldset[@id="edit-form-checkboxes-title-invisible--wrapper"]/legend/span[contains(@class, "visually-hidden")]');
|
||||
$this->assertTrue(!empty($elements), "Title/Label not displayed when 'visually-hidden' attribute is set in checkboxes.");
|
||||
// Check Title/Label not displayed when 'visually-hidden' attribute is set
|
||||
// in checkboxes.
|
||||
$this->assertSession()->elementExists('xpath', '//fieldset[@id="edit-form-checkboxes-title-invisible--wrapper"]/legend/span[contains(@class, "visually-hidden")]');
|
||||
|
||||
$elements = $this->xpath('//fieldset[@id="edit-form-radios-title-invisible--wrapper"]/legend/span[contains(@class, "visually-hidden")]');
|
||||
$this->assertTrue(!empty($elements), "Title/Label not displayed when 'visually-hidden' attribute is set in radios.");
|
||||
// Check Title/Label not displayed when 'visually-hidden' attribute is set
|
||||
// in radios.
|
||||
$this->assertSession()->elementExists('xpath', '//fieldset[@id="edit-form-radios-title-invisible--wrapper"]/legend/span[contains(@class, "visually-hidden")]');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,43 +48,45 @@ class DisplayPageWebTest extends ViewTestBase {
|
|||
* Tests arguments.
|
||||
*/
|
||||
public function testArguments() {
|
||||
$xpath = '//span[@class="field-content"]';
|
||||
|
||||
// Ensure that all the entries are returned.
|
||||
$this->drupalGet('test_route_without_arguments');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
$result = $this->xpath('//span[@class="field-content"]');
|
||||
$this->assertCount(5, $result, 'All entries was returned');
|
||||
$this->assertSession()->elementsCount('xpath', $xpath, 5);
|
||||
|
||||
$this->drupalGet('test_route_without_arguments/1');
|
||||
$this->assertSession()->statusCodeEquals(404);
|
||||
|
||||
// Ensure that just the filtered entry is returned.
|
||||
$this->drupalGet('test_route_with_argument/1');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
$this->assertCacheContexts(['languages:language_interface', 'route', 'theme', 'url']);
|
||||
$result = $this->xpath('//span[@class="field-content"]');
|
||||
$this->assertCount(1, $result, 'Ensure that just the filtered entry was returned.');
|
||||
$this->assertEqual(1, $result[0]->getText(), 'The passed ID was returned.');
|
||||
$this->assertSession()->elementsCount('xpath', $xpath, 1);
|
||||
$this->assertSession()->elementTextEquals('xpath', $xpath, 1);
|
||||
|
||||
// Ensure that just the filtered entry is returned.
|
||||
$this->drupalGet('test_route_with_suffix/1/suffix');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
$result = $this->xpath('//span[@class="field-content"]');
|
||||
$this->assertCount(1, $result, 'Ensure that just the filtered entry was returned.');
|
||||
$this->assertEqual(1, $result[0]->getText(), 'The passed ID was returned.');
|
||||
$this->assertSession()->elementsCount('xpath', $xpath, 1);
|
||||
$this->assertSession()->elementTextEquals('xpath', $xpath, 1);
|
||||
|
||||
// Ensure that no result is returned.
|
||||
$this->drupalGet('test_route_with_suffix_and_argument/1/suffix/2');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
$result = $this->xpath('//span[@class="field-content"]');
|
||||
$this->assertCount(0, $result, 'No result was returned.');
|
||||
$this->assertSession()->elementNotExists('xpath', $xpath);
|
||||
|
||||
// Ensure that just the filtered entry is returned.
|
||||
$this->drupalGet('test_route_with_suffix_and_argument/1/suffix/1');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
$result = $this->xpath('//span[@class="field-content"]');
|
||||
$this->assertCount(1, $result, 'Ensure that just the filtered entry was returned.');
|
||||
$this->assertEqual(1, $result[0]->getText(), 'The passed ID was returned.');
|
||||
$this->assertSession()->elementsCount('xpath', $xpath, 1);
|
||||
$this->assertSession()->elementTextEquals('xpath', $xpath, 1);
|
||||
|
||||
// Ensure that just the filtered entry is returned.
|
||||
$this->drupalGet('test_route_with_long_argument/1');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
$result = $this->xpath('//span[@class="field-content"]');
|
||||
$this->assertCount(1, $result, 'Ensure that just the filtered entry was returned.');
|
||||
$this->assertEqual(1, $result[0]->getText(), 'The passed ID was returned.');
|
||||
$this->assertSession()->elementsCount('xpath', $xpath, 1);
|
||||
$this->assertSession()->elementTextEquals('xpath', $xpath, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,8 +72,9 @@ class InstallerTest extends InstallerTestBase {
|
|||
PerformanceTestRecorder::registerService($this->siteDirectory . '/services.yml', TRUE);
|
||||
// Assert that the expected title is present.
|
||||
$this->assertEqual('Select an installation profile', $this->cssSelect('main h2')[0]->getText());
|
||||
$result = $this->xpath('//span[contains(@class, :class) and contains(text(), :text)]', [':class' => 'visually-hidden', ':text' => 'Select an installation profile']);
|
||||
$this->assertCount(1, $result, "Title/Label not displayed when '#title_display' => 'invisible' attribute is set");
|
||||
// Verify that Title/Label are not displayed when '#title_display' =>
|
||||
// 'invisible' attribute is set.
|
||||
$this->assertSession()->elementsCount('xpath', "//span[contains(@class, 'visually-hidden') and contains(text(), 'Select an installation profile')]", 1);
|
||||
|
||||
parent::setUpProfile();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue