From d1c6861b2c3303cb90b5ff1a199dd4af016b5d7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Tue, 23 May 2023 17:12:01 -0300 Subject: [PATCH] Fix some failing Selenium tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- test/selenium/Database/EventsTest.php | 12 ++++-------- test/selenium/Database/ProceduresTest.php | 12 ++++-------- test/selenium/Database/StructureTest.php | 8 ++------ test/selenium/Database/TriggersTest.php | 12 ++++-------- test/selenium/Table/OperationsTest.php | 12 ++++-------- test/selenium/Table/StructureTest.php | 6 ++---- test/selenium/TrackingTest.php | 6 ++---- 7 files changed, 22 insertions(+), 46 deletions(-) diff --git a/test/selenium/Database/EventsTest.php b/test/selenium/Database/EventsTest.php index 0f1dbd0e3f..fdfd30cbcd 100644 --- a/test/selenium/Database/EventsTest.php +++ b/test/selenium/Database/EventsTest.php @@ -113,10 +113,8 @@ class EventsTest extends TestBase $this->byCssSelector('div.ui-dialog-buttonset button:nth-child(1)')->click(); - $this->waitForElement( - 'xpath', - '//div[@class=\'alert alert-success\' and contains(., \'Event `test_event` has been created\')]', - ); + $success = $this->waitForElement('cssSelector', '.alert-success'); + $this->assertStringContainsString('Event `test_event` has been created', $success->getText()); $this->waitForElementNotPresent( 'xpath', '//div[@id=\'alertLabel\' and not(contains(@style,\'display: none;\'))]', @@ -176,10 +174,8 @@ class EventsTest extends TestBase $this->byCssSelector('div.ui-dialog-buttonset button:nth-child(1)')->click(); - $this->waitForElement( - 'xpath', - '//div[@class=\'alert alert-success\' and contains(., \'Event `test_event` has been modified\')]', - ); + $success = $this->waitForElement('cssSelector', '.alert-success'); + $this->assertStringContainsString('Event `test_event` has been modified', $success->getText()); sleep(2); $this->dbQuery( diff --git a/test/selenium/Database/ProceduresTest.php b/test/selenium/Database/ProceduresTest.php index 6ec3c3e371..9415128c5c 100644 --- a/test/selenium/Database/ProceduresTest.php +++ b/test/selenium/Database/ProceduresTest.php @@ -145,10 +145,8 @@ class ProceduresTest extends TestBase $this->byCssSelector('div.ui-dialog-buttonset button:nth-child(1)')->click(); - $this->waitForElement( - 'xpath', - '//div[@class=\'alert alert-success\' and contains(., \'Routine `test_procedure` has been created\')]', - ); + $success = $this->waitForElement('cssSelector', '.alert-success'); + $this->assertStringContainsString('Routine `test_procedure` has been created', $success->getText()); $this->dbQuery( "SHOW PROCEDURE STATUS WHERE Db='" . $this->databaseName . "'", @@ -181,10 +179,8 @@ class ProceduresTest extends TestBase $this->byCssSelector('div.ui-dialog-buttonset button:nth-child(1)')->click(); - $this->waitForElement( - 'xpath', - '//div[@class=\'alert alert-success\' and contains(., \'Routine `test_procedure` has been modified\')]', - ); + $success = $this->waitForElement('cssSelector', '.alert-success'); + $this->assertStringContainsString('Routine `test_procedure` has been modified', $success->getText()); $this->executeProcedure('test_procedure', 14); } diff --git a/test/selenium/Database/StructureTest.php b/test/selenium/Database/StructureTest.php index 39867c2843..5dfcc51f62 100644 --- a/test/selenium/Database/StructureTest.php +++ b/test/selenium/Database/StructureTest.php @@ -50,12 +50,8 @@ class StructureTest extends TestBase $this->waitForElement('id', 'functionConfirmOkButton')->click(); - $this->assertNotNull( - $this->waitForElement( - 'xpath', - '//div[@class=\'alert alert-success\' and contains(., \'MySQL returned an empty result\')]', - ), - ); + $success = $this->waitForElement('cssSelector', '.alert-success'); + $this->assertStringContainsString('MySQL returned an empty result', $success->getText()); $this->dbQuery( 'SELECT CONCAT("Count: ", COUNT(*)) as c FROM `' . $this->databaseName . '`.`test_table`', diff --git a/test/selenium/Database/TriggersTest.php b/test/selenium/Database/TriggersTest.php index e48827ce1f..afea588550 100644 --- a/test/selenium/Database/TriggersTest.php +++ b/test/selenium/Database/TriggersTest.php @@ -93,10 +93,8 @@ class TriggersTest extends TestBase $this->byCssSelector('div.ui-dialog-buttonset button:nth-child(1)')->click(); - $this->waitForElement( - 'xpath', - '//div[@class=\'alert alert-success\' and contains(., \'Trigger `test_trigger` has been created\')]', - ); + $success = $this->waitForElement('cssSelector', '.alert-success'); + $this->assertStringContainsString('Trigger `test_trigger` has been created', $success->getText()); $this->assertTrue( $this->isElementPresent( @@ -148,10 +146,8 @@ class TriggersTest extends TestBase $this->byCssSelector('div.ui-dialog-buttonset button:nth-child(1)')->click(); - $this->waitForElement( - 'xpath', - '//div[@class=\'alert alert-success\' and contains(., \'Trigger `test_trigger` has been modified\')]', - ); + $success = $this->waitForElement('cssSelector', '.alert-success'); + $this->assertStringContainsString('Trigger `test_trigger` has been modified', $success->getText()); // test trigger $this->dbQuery('USE `' . $this->databaseName . '`;INSERT INTO `test_table` (val) VALUES (1);'); diff --git a/test/selenium/Table/OperationsTest.php b/test/selenium/Table/OperationsTest.php index 6b41b573f0..bc3cb2afe2 100644 --- a/test/selenium/Table/OperationsTest.php +++ b/test/selenium/Table/OperationsTest.php @@ -186,10 +186,8 @@ class OperationsTest extends TestBase $this->waitForElement('id', 'functionConfirmOkButton')->click(); $this->waitAjax(); - $this->waitForElement( - 'xpath', - '//div[@class=\'alert alert-success\' and contains(., \'MySQL returned an empty result set\')]', - ); + $success = $this->waitForElement('cssSelector', '.alert-success'); + $this->assertStringContainsString('MySQL returned an empty result set', $success->getText()); $this->dbQuery( 'SELECT CONCAT("Count: ", COUNT(*)) as c FROM `' . $this->databaseName . '`.test_table', @@ -213,10 +211,8 @@ class OperationsTest extends TestBase $this->waitForElement('id', 'functionConfirmOkButton')->click(); $this->waitAjax(); - $this->waitForElement( - 'xpath', - '//div[@class=\'alert alert-success\' and contains(., \'MySQL returned an empty result set\')]', - ); + $success = $this->waitForElement('cssSelector', '.alert-success'); + $this->assertStringContainsString('MySQL returned an empty result set', $success->getText()); $this->dbQuery( 'USE `' . $this->databaseName . '`;' diff --git a/test/selenium/Table/StructureTest.php b/test/selenium/Table/StructureTest.php index 6971de9a5e..c7f0a0d28b 100644 --- a/test/selenium/Table/StructureTest.php +++ b/test/selenium/Table/StructureTest.php @@ -108,10 +108,8 @@ class StructureTest extends TestBase $this->waitForElement('cssSelector', "input[id='buttonYes']")->click(); - $this->waitForElement( - 'xpath', - '//div[@class=\'alert alert-success\' and contains(., \'2 columns have been dropped successfully.\')]', - ); + $success = $this->waitForElement('cssSelector', '.alert-success'); + $this->assertStringContainsString('2 columns have been dropped successfully.', $success->getText()); $this->waitAjax(); $this->assertFalse( diff --git a/test/selenium/TrackingTest.php b/test/selenium/TrackingTest.php index f347cbb196..b61024f047 100644 --- a/test/selenium/TrackingTest.php +++ b/test/selenium/TrackingTest.php @@ -159,10 +159,8 @@ class TrackingTest extends TestBase $this->waitForElement('id', 'functionConfirmOkButton')->click(); $this->waitAjax(); - $this->waitForElement( - 'xpath', - '//div[@class=\'alert alert-success\' and contains(., \'Tracking data deleted successfully.\')]', - ); + $success = $this->waitForElement('cssSelector', '.alert-success'); + $this->assertStringContainsString('Tracking data deleted successfully.', $success->getText()); // Can not use getCellByTableId, // since this is under 'th' and not 'td'