ElixirVault/tests/DataSetup/Traits/Cms/cmsDialogTrait.php

49 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace ElixirAudit\Tests\DataSetup\traits\Cms;
/**
* Trait for common CMS Dialog interactions
*/
trait cmsDialogTrait
{
public function getNewButtonId(): string
{
return '#bButtonNew';
}
public function openCmsConfirmDialog(string $triggerSelector): void
{
$this->scrollIntoViewHoverClick($triggerSelector, self::CSS_SELECTOR);
}
/**
* Click the confirmation button on a CMS dialog
*/
public function cmsConfirmDialogActionYes(): void
{
$selector = 'buttonYes';
// Wait for the button to be ready
$this->waitForElementDisplay($selector, self::ID);
$this->waitForElementEnabled($selector, self::ID);
// Move to the element to simulate human focus before clicking
$element = $this->byId($selector);
$this->webDriver->action()->moveToElement($element)->perform();
$element->click();
$this->waitUntilDomReadyState();
}
public function cmsConfirmDialogActionCancel(): void
{
$selector = '#confirmDialog > div > div.header.ui-draggable-handle > a';
$this->waitForElementDisplay($selector, self::CSS_SELECTOR);
$this->byCssSelector($selector)->click();
$this->waitUntilDomReadyState();
}
}