assertNotVisibleInViewport example

$this->drupalGet('node/add/page');

    $session->getPage();

    // Add a bottom margin to the title field to be sure the body field is not     // visible.     $session->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = window.innerHeight*2 +'px';");

    $this->assertSession()->waitForElementVisible('css', $ckeditor_id);
    // Check that the CKEditor 5-enabled body field is currently not visible in     // the viewport.     $web_assert->assertNotVisibleInViewport('css', $ckeditor_class, 'topLeft', 'CKEditor 5-enabled body field is visible.');

    $before_url = $session->getCurrentUrl();

    // Trigger a hash change with as target the hidden textarea.     $session->executeScript("location.hash = '#edit-body-0-value';");

    // Check that the CKEditor 5-enabled body field is visible in the viewport.     // The hash change adds an ID to the CKEditor 5 instance so check its     // visibility using the ID now.     $web_assert->assertVisibleInViewport('css', $ckeditor_id, 'topLeft', 'CKEditor 5-enabled body field is not visible.');

    
    $edit = ['edit-title-0-value' => 'Test inline form error with CKEditor 5'];

    $this->submitForm($edit, 'Save');

    $this->assertSession()->waitForElement('css', '#cke_edit-body-0-value');
    // Add a bottom margin to the title field to be sure the body field is not     // visible.     $session->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = window.innerHeight*2 + 'px';");

    // Check that the CKEditor5-enabled body field is currently not visible in     // the viewport.     $web_assert->assertNotVisibleInViewport('css', $ckeditor_class, 'topLeft', 'CKEditor5-enabled body field is not visible.');

    // Check if we can find the error fragment link within the errors summary     // message.
    $errors_link = $this->assertSession()->waitForElementVisible('css', 'a[href$="#edit-body-0-value"]');
    $this->assertNotEmpty($errors_link, 'Error fragment link is visible.');

    $errors_link->click();

    // Check that the CKEditor5-enabled body field is visible in the viewport.     // The hash change adds an ID to the CKEditor 5 instance so check its visibility using the ID now.
Home | Imprint | This part of the site doesn't use cookies.