elementWait('.module-title', self::CSS_SELECTOR); $this->assertElementTextByCss('.module-title', $moduleTitle); } public function assertFormTitle(string $expectedTitle): void { $this->elementWait('h2.title', self::CSS_SELECTOR); $this->assertElementTextContainsByCss('h2.title', $expectedTitle); } public function assertFormSuccessfullySavedMessage(): void { $selector = '.form-data .save-status'; $this->scrollElementIntoView($selector, self::CSS_SELECTOR); $this->assertElementTextContainsByCss($selector, "DATA SUCCESSFULLY SAVED"); } public function assertTableSuccessfullyDeletedMessage(): void { $selector = '.cnt .save-status'; $this->scrollElementIntoView($selector, self::CSS_SELECTOR); $this->assertElementTextByCss($selector, 'RECORD SUCCESSFULLY DELETED'); } public function assertElementValueById(string $id, string $expectedValue, string $message = ''): void { $actualValue = $this->byId($id)->getAttribute('value'); $this->assertSame($expectedValue, $actualValue, $message); } public function assertElementValueByCss(string $selector, string $expectedText, string $message = ''): void { $actualText = $this->byCssSelector($selector)->getAttribute('value'); $this->assertSame($expectedText, $actualText, $message); } public function assertElementTextByCss(string $selector, string $expectedText, string $message = ''): void { $actualText = $this->byCssSelector($selector)->getText(); $this->assertSame($expectedText, $actualText, $message); } public function assertElementTextContainsByCss(string $selector, string $expectedText, string $message = ''): void { $actualText = $this->byCssSelector($selector)->getText(); $this->assertStringContainsString($expectedText, $actualText, $message); } public function assertCmsCheckboxState(string $selector, bool $shouldBeChecked, string $message = ''): void { $exists = $this->elementExists($selector . ' .chk.chked', self::CSS_SELECTOR, true); $this->assertSame($shouldBeChecked, $exists, $message); } public function assertFieldHasNotValidNumberError(string $id): void { $this->assertFieldHasError($id, 'Not a valid number specified!'); } public function assertFieldHasCompulsoryError(string $id): void { $this->assertFieldHasError($id, 'Please fill in the field!'); } public function assertFieldHasError(string $id, string $expectedMessage): void { // Use XPath to find the .validate container that has the specific input ID and the v-error class $containerXPath = "//div[contains(@class, 'validate') and contains(@class, 'v-error') and .//input[@id='$id']]"; $errorXPath = "$containerXPath//div[contains(@class, 'errMsg')]"; $this->elementWait($containerXPath, self::XPATH); // Hover the input field to trigger the visibility of the error bubble (as done in formLayoutTrait) $inputElement = $this->byId($id); $this->webDriver->action()->moveToElement($inputElement)->perform(); // Wait for the error message element to be present and visible $this->elementWait($errorXPath, self::XPATH, true, true, true, false); $actualMessage = $this->byXPath($errorXPath)->getText(); $this->assertEquals($expectedMessage, $actualMessage); } public function assertFieldIsOk(string $id): void { // Use XPath to find the .validate container with v-ok class for the specific input $containerXPath = "//div[contains(@class, 'validate') and contains(@class, 'v-ok') and .//input[@id='$id']]"; $this->assertTrue($this->elementExists($containerXPath, self::XPATH)); } public function assertCmsTableRowData($row, $column, $expectedText): void { $selector = "#cms-table-drop-marker > div.table-rows > div > ul:nth-child($row) > li:nth-child($column) > div"; $errorMessage = "Table record with text '$expectedText' not found in column $column"; $this->assertElementTextByCss($selector, $expectedText, $errorMessage); } }