Merge pull request #13462 from devenbansod/fix_db_selenium_tests
Fix Database-related selenium tests
This commit is contained in:
commit
7e28cb3d62
@ -30,6 +30,12 @@ class PMA_SeleniumCreateDropDatabaseTest extends PMA_SeleniumBase
|
||||
$this->skipIfNotSuperUser();
|
||||
}
|
||||
|
||||
public function setUpPage()
|
||||
{
|
||||
parent::setUpPage();
|
||||
$this->login();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a database and drops it
|
||||
*
|
||||
@ -39,9 +45,10 @@ class PMA_SeleniumCreateDropDatabaseTest extends PMA_SeleniumBase
|
||||
*/
|
||||
public function testCreateDropDatabase()
|
||||
{
|
||||
$this->login();
|
||||
|
||||
$this->_dropDatabase();
|
||||
// Drop database if it exists
|
||||
$this->dbQuery(
|
||||
'DROP DATABASE IF EXISTS ' . $this->database_name . ';'
|
||||
);
|
||||
|
||||
$this->waitForElement('byPartialLinkText','Databases')->click();
|
||||
$this->waitForElementNotPresent('byCssSelector', 'div#loading_parent');
|
||||
@ -54,6 +61,11 @@ class PMA_SeleniumCreateDropDatabaseTest extends PMA_SeleniumBase
|
||||
|
||||
$element = $this->waitForElement('byLinkText', 'Database: ' . $this->database_name);
|
||||
|
||||
$result = $this->dbQuery(
|
||||
'SHOW DATABASES LIKE \'' . $this->database_name . '\';'
|
||||
);
|
||||
$this->assertEquals(1, $result->num_rows);
|
||||
|
||||
$this->_dropDatabase();
|
||||
}
|
||||
|
||||
@ -85,5 +97,10 @@ class PMA_SeleniumCreateDropDatabaseTest extends PMA_SeleniumBase
|
||||
$this->waitForElement(
|
||||
"byCssSelector", "span.ajax_notification div.success"
|
||||
);
|
||||
|
||||
$result = $this->dbQuery(
|
||||
'SHOW DATABASES LIKE \'' . $this->database_name . '\';'
|
||||
);
|
||||
$this->assertEquals(0, $result->num_rows);
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,6 +47,12 @@ class PMA_SeleniumCreateRemoveUserTest extends PMA_SeleniumBase
|
||||
$this->_txtPassword = 'abc_123';
|
||||
}
|
||||
|
||||
public function setUpPage()
|
||||
{
|
||||
parent::setUpPage();
|
||||
$this->login();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and removes a user
|
||||
*
|
||||
@ -56,16 +62,26 @@ class PMA_SeleniumCreateRemoveUserTest extends PMA_SeleniumBase
|
||||
*/
|
||||
public function testCreateRemoveUser()
|
||||
{
|
||||
$this->login();
|
||||
$this->waitForElement('byPartialLinkText', "User accounts")->click();
|
||||
|
||||
// Let the User Accounts page load
|
||||
$this->waitForElementNotPresent('byId', 'ajax_message_num_1');
|
||||
|
||||
$this->scrollIntoView('add_user_anchor');
|
||||
$link = $this->waitForElement("byId", "add_user_anchor");
|
||||
$link->click();
|
||||
$this->waitForElement('byId', 'usersForm');
|
||||
$ele = $this->waitForElement("byId", "add_user_anchor");
|
||||
$this->moveto($ele);
|
||||
|
||||
// Let the click go through
|
||||
// If click happened before complete page load, it didn't go through
|
||||
while ($this->isElementPresent('byId', 'add_user_anchor')
|
||||
&& ! $this->isElementPresent('byId', 'ajax_message_num_1')
|
||||
) {
|
||||
$ele->click();
|
||||
usleep(1000000);
|
||||
}
|
||||
|
||||
$this->waitForElementNotPresent('byId', 'ajax_message_num_1');
|
||||
$userField = $this->waitForElement("byName", "username");
|
||||
$userField->value($this->_txtUsername);
|
||||
|
||||
@ -107,6 +123,8 @@ class PMA_SeleniumCreateRemoveUserTest extends PMA_SeleniumBase
|
||||
)->click();
|
||||
|
||||
$this->byId("checkbox_drop_users_db")->click();
|
||||
$this->scrollIntoView('fieldset_delete_user_footer');
|
||||
|
||||
$this->byId("buttonGo")->click();
|
||||
$this->waitForElement("byCssSelector", "button.submitOK")->click();
|
||||
$this->acceptAlert();
|
||||
|
||||
@ -48,6 +48,8 @@ class PMA_SeleniumDbEventsTest extends PMA_SeleniumBase
|
||||
*/
|
||||
public function setUpPage()
|
||||
{
|
||||
parent::setUpPage();
|
||||
|
||||
$this->login();
|
||||
$this->waitForElement('byPartialLinkText','Databases')->click();
|
||||
$this->waitForElementNotPresent('byCssSelector', 'div#loading_parent');
|
||||
|
||||
@ -26,13 +26,19 @@ class PMA_SeleniumDbOperationsTest extends PMA_SeleniumBase
|
||||
*/
|
||||
public function setUpPage()
|
||||
{
|
||||
parent::setUpPage();
|
||||
$this->login();
|
||||
}
|
||||
|
||||
private function _getToDBOperations()
|
||||
{
|
||||
$this->gotoHomepage();
|
||||
$this->waitForElement('byLinkText', $this->database_name)->click();
|
||||
$this->waitForElement("byLinkText", "Structure");
|
||||
$this->waitForElement('byPartialLinkText', 'Structure');
|
||||
$this->expandMore();
|
||||
$this->waitForElement("byLinkText", "Operations")->click();
|
||||
$this->waitForElement('byPartialLinkText', 'Operations')->click();
|
||||
$this->waitForElement(
|
||||
"byXPath", "//legend[contains(., 'Rename database to')]"
|
||||
'byXPath', '//legend[contains(., \'Rename database to\')]'
|
||||
);
|
||||
}
|
||||
|
||||
@ -46,6 +52,8 @@ class PMA_SeleniumDbOperationsTest extends PMA_SeleniumBase
|
||||
public function testDbComment()
|
||||
{
|
||||
$this->skipIfNotPMADB();
|
||||
|
||||
$this->_getToDBOperations();
|
||||
$this->byName("comment")->value("comment_foobar");
|
||||
$this->byCssSelector(
|
||||
"form#formDatabaseComment input[type='submit']"
|
||||
@ -68,14 +76,18 @@ class PMA_SeleniumDbOperationsTest extends PMA_SeleniumBase
|
||||
*/
|
||||
public function testRenameDB()
|
||||
{
|
||||
$this->_getToDBOperations();
|
||||
|
||||
$new_db_name = $this->database_name . 'rename';
|
||||
|
||||
$this->scrollIntoView('create_table_form_minimal');
|
||||
$this->byCssSelector("form#rename_db_form input[name=newname]")
|
||||
->value($new_db_name);
|
||||
|
||||
$this->byCssSelector("form#rename_db_form input[type='submit']")->click();
|
||||
|
||||
$this->waitForElement(
|
||||
"byXPath", "//button[contains(., 'OK')]"
|
||||
"byCssSelector", "button.submitOK"
|
||||
)->click();
|
||||
|
||||
$this->waitForElement(
|
||||
@ -105,6 +117,8 @@ class PMA_SeleniumDbOperationsTest extends PMA_SeleniumBase
|
||||
*/
|
||||
public function testCopyDb()
|
||||
{
|
||||
$this->_getToDBOperations();
|
||||
|
||||
$new_db_name = $this->database_name . 'copy';
|
||||
$this->byCssSelector("form#copy_db_form input[name=newname]")
|
||||
->value($new_db_name);
|
||||
|
||||
@ -44,11 +44,19 @@ class PMA_SeleniumDbProceduresTest extends PMA_SeleniumBase
|
||||
*/
|
||||
public function setUpPage()
|
||||
{
|
||||
parent::setUpPage();
|
||||
|
||||
$this->login();
|
||||
$this->waitForElement('byLinkText', $this->database_name)->click();
|
||||
|
||||
$this->waitForElement('byPartialLinkText','Databases')->click();
|
||||
$this->waitForElementNotPresent('byCssSelector', 'div#loading_parent');
|
||||
$this->waitForElement('byPartialLinkText', $this->database_name)->click();
|
||||
$this->waitForElement(
|
||||
"byXPath", "//a[contains(., 'test_table')]"
|
||||
);
|
||||
|
||||
// Let the Database page load
|
||||
$this->waitForElementNotPresent('byId', 'ajax_message_num_1');
|
||||
$this->expandMore();
|
||||
}
|
||||
|
||||
@ -78,7 +86,7 @@ class PMA_SeleniumDbProceduresTest extends PMA_SeleniumBase
|
||||
$ele = $this->waitForElement("byPartialLinkText", "Routines");
|
||||
$ele->click();
|
||||
|
||||
$ele = $this->waitForElement("byLinkText", "Add routine");
|
||||
$ele = $this->waitForElement("byPartialLinkText", "Add routine");
|
||||
$ele->click();
|
||||
|
||||
$this->waitForElement("byClassName", "rte_form");
|
||||
@ -100,7 +108,7 @@ class PMA_SeleniumDbProceduresTest extends PMA_SeleniumBase
|
||||
$ele->value("outp");
|
||||
|
||||
$proc = "SELECT char_length(inp) + count(*) FROM test_table INTO outp";
|
||||
$this->typeInTextArea($proc);
|
||||
$this->typeInTextArea($proc, 2);
|
||||
|
||||
$this->select(
|
||||
$this->byName("item_sqldataaccess")
|
||||
@ -119,7 +127,7 @@ class PMA_SeleniumDbProceduresTest extends PMA_SeleniumBase
|
||||
);
|
||||
|
||||
$this->assertEquals(1, $result->num_rows);
|
||||
$this->_executeProcedure("abcabcabcabcabcabcabc", 10);
|
||||
$this->_executeProcedure("test_procedure", 10);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,7 +148,7 @@ class PMA_SeleniumDbProceduresTest extends PMA_SeleniumBase
|
||||
"//legend[contains(., 'Routines')]"
|
||||
);
|
||||
|
||||
$this->byLinkText("Edit")->click();
|
||||
$this->byPartialLinkText("Edit")->click();
|
||||
$this->waitForElement("byClassName", "rte_form");
|
||||
$this->byName("item_param_length[0]")->clear();
|
||||
$this->byName("item_param_length[0]")->value("12");
|
||||
@ -153,7 +161,7 @@ class PMA_SeleniumDbProceduresTest extends PMA_SeleniumBase
|
||||
. "'Routine `test_procedure` has been modified')]"
|
||||
);
|
||||
|
||||
$this->_executeProcedure("abcabcabcabcabcabcabc", 12);
|
||||
$this->_executeProcedure("test_procedure", 12);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,9 +182,9 @@ class PMA_SeleniumDbProceduresTest extends PMA_SeleniumBase
|
||||
"//legend[contains(., 'Routines')]"
|
||||
);
|
||||
|
||||
$this->byLinkText("Drop")->click();
|
||||
$this->byPartialLinkText("Drop")->click();
|
||||
$this->waitForElement(
|
||||
"byXPath", "//button[contains(., 'OK')]"
|
||||
"byCssSelector", "button.submitOK"
|
||||
)->click();
|
||||
|
||||
$this->waitForElement("byId", "nothing2display");
|
||||
@ -198,7 +206,7 @@ class PMA_SeleniumDbProceduresTest extends PMA_SeleniumBase
|
||||
*/
|
||||
private function _executeProcedure($text, $length)
|
||||
{
|
||||
$this->waitForElement("byLinkText", "Execute")->click();
|
||||
$this->waitForElement("byPartialLinkText", "Execute")->click();
|
||||
$this->waitForElement("byName", "params[inp]")->value($text);
|
||||
$this->byCssSelector("div.ui-dialog-buttonset button:nth-child(1)")->click();
|
||||
$this->waitForElement(
|
||||
|
||||
@ -52,8 +52,12 @@ class PMA_SeleniumDbStructureTest extends PMA_SeleniumBase
|
||||
*/
|
||||
public function setUpPage()
|
||||
{
|
||||
parent::setUpPage();
|
||||
|
||||
$this->login();
|
||||
$this->waitForElement('byLinkText', $this->database_name)->click();
|
||||
$this->waitForElement('byPartialLinkText','Databases')->click();
|
||||
$this->waitForElementNotPresent('byCssSelector', 'div#loading_parent');
|
||||
$this->waitForElement('byPartialLinkText', $this->database_name)->click();
|
||||
$this->waitForElement(
|
||||
'byCssSelector',
|
||||
'li.last.table'
|
||||
@ -61,6 +65,10 @@ class PMA_SeleniumDbStructureTest extends PMA_SeleniumBase
|
||||
$this->waitForElement(
|
||||
"byXPath", "//a[contains(., 'test_table')]"
|
||||
);
|
||||
|
||||
// Let the Database page load
|
||||
$this->waitForElementNotPresent('byId', 'ajax_message_num_1');
|
||||
$this->expandMore();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,8 +83,8 @@ class PMA_SeleniumDbStructureTest extends PMA_SeleniumBase
|
||||
$this->byXPath("(//a[contains(., 'Empty')])[1]")->click();
|
||||
|
||||
$this->waitForElement(
|
||||
"byXPath",
|
||||
"//button[contains(., 'OK')]"
|
||||
"byCssSelector",
|
||||
"button.submitOK"
|
||||
)->click();
|
||||
|
||||
$this->assertNotNull(
|
||||
@ -109,7 +117,7 @@ class PMA_SeleniumDbStructureTest extends PMA_SeleniumBase
|
||||
|
||||
$this->waitForElement(
|
||||
"byXPath",
|
||||
"//p[contains(., 'No tables found in database')]"
|
||||
"//*[contains(., 'No tables found in database')]"
|
||||
);
|
||||
|
||||
$result = $this->dbQuery("SHOW TABLES;");
|
||||
|
||||
@ -53,11 +53,16 @@ class PMA_SeleniumDbTriggersTest extends PMA_SeleniumBase
|
||||
*/
|
||||
public function setUpPage()
|
||||
{
|
||||
parent::setUpPage();
|
||||
|
||||
$this->login();
|
||||
$this->waitForElement('byLinkText', $this->database_name)->click();
|
||||
$this->waitForElement('byPartialLinkText','Databases')->click();
|
||||
$this->waitForElementNotPresent('byCssSelector', 'div#loading_parent');
|
||||
$this->waitForElement('byPartialLinkText', $this->database_name)->click();
|
||||
$this->waitForElement(
|
||||
"byXPath", "//a[contains(., 'test_table')]"
|
||||
);
|
||||
$this->waitForElementNotPresent('byCssSelector', 'div#loading_parent');
|
||||
$this->expandMore();
|
||||
}
|
||||
|
||||
@ -85,10 +90,11 @@ class PMA_SeleniumDbTriggersTest extends PMA_SeleniumBase
|
||||
*/
|
||||
public function testAddTrigger()
|
||||
{
|
||||
$this->expandMore();
|
||||
$ele = $this->waitForElement("byPartialLinkText", "Triggers");
|
||||
$ele->click();
|
||||
|
||||
$ele = $this->waitForElement("byLinkText", "Add trigger");
|
||||
$ele = $this->waitForElement("byPartialLinkText", "Add trigger");
|
||||
$ele->click();
|
||||
|
||||
$this->waitForElement("byClassName", "rte_form");
|
||||
@ -105,7 +111,7 @@ class PMA_SeleniumDbTriggersTest extends PMA_SeleniumBase
|
||||
->selectOptionByLabel("INSERT");
|
||||
|
||||
$proc = "UPDATE " . $this->database_name . ".`test_table2` SET val=val+1";
|
||||
$this->typeInTextArea($proc);
|
||||
$this->typeInTextArea($proc, 2);
|
||||
|
||||
$this->byXPath("//button[contains(., 'Go')]")->click();
|
||||
|
||||
@ -143,6 +149,8 @@ class PMA_SeleniumDbTriggersTest extends PMA_SeleniumBase
|
||||
*/
|
||||
public function testEditTriggers()
|
||||
{
|
||||
$this->expandMore();
|
||||
|
||||
$this->_triggerSQL();
|
||||
$ele = $this->waitForElement("byPartialLinkText", "Triggers");
|
||||
$ele->click();
|
||||
@ -152,10 +160,11 @@ class PMA_SeleniumDbTriggersTest extends PMA_SeleniumBase
|
||||
"//legend[contains(., 'Triggers')]"
|
||||
);
|
||||
|
||||
$this->byLinkText("Edit")->click();
|
||||
$this->byPartialLinkText("Edit")->click();
|
||||
|
||||
$this->waitForElement("byClassName", "rte_form");
|
||||
$this->typeInTextArea("0");
|
||||
$proc = "UPDATE " . $this->database_name . ".`test_table2` SET val=val+10";
|
||||
$this->typeInTextArea($proc, 2);
|
||||
|
||||
$this->byXPath("//button[contains(., 'Go')]")->click();
|
||||
|
||||
@ -181,6 +190,8 @@ class PMA_SeleniumDbTriggersTest extends PMA_SeleniumBase
|
||||
*/
|
||||
public function testDropTrigger()
|
||||
{
|
||||
$this->expandMore();
|
||||
|
||||
$this->_triggerSQL();
|
||||
$ele = $this->waitForElement("byPartialLinkText", "Triggers");
|
||||
$ele->click();
|
||||
@ -190,13 +201,21 @@ class PMA_SeleniumDbTriggersTest extends PMA_SeleniumBase
|
||||
"//legend[contains(., 'Triggers')]"
|
||||
);
|
||||
|
||||
$this->byLinkText("Drop")->click();
|
||||
$this->byPartialLinkText("Drop")->click();
|
||||
$this->waitForElement(
|
||||
"byXPath", "//button[contains(., 'OK')]"
|
||||
"byCssSelector", "button.submitOK"
|
||||
)->click();
|
||||
|
||||
$this->waitForElement("byId", "nothing2display");
|
||||
|
||||
usleep(1000000);
|
||||
|
||||
// test trigger
|
||||
$this->dbQuery("INSERT INTO `test_table` (val) VALUES (1);");
|
||||
$result = $this->dbQuery("SELECT val FROM `test_table2`;");
|
||||
$row = $result->fetch_assoc();
|
||||
$this->assertEquals(2, $row['val']);
|
||||
|
||||
$result = $this->dbQuery(
|
||||
"SHOW TRIGGERS FROM `" . $this->database_name . "`;"
|
||||
);
|
||||
|
||||
@ -198,6 +198,17 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the browser window.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function setUpPage()
|
||||
{
|
||||
$this->currentWindow()->maximize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether user is a superuser.
|
||||
*
|
||||
@ -233,7 +244,8 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
|
||||
protected function skipIfNotPMADB()
|
||||
{
|
||||
$this->url('chk_rel.php');
|
||||
if ($this->isElementPresent("byXPath", "//*[@color=\"red\"]")) {
|
||||
$this->waitForElement('byId', 'page_content');
|
||||
if ($this->isElementPresent('byXPath', '//span[contains(@style, \'color:red\')]')) {
|
||||
$this->markTestSkipped(
|
||||
'The phpMyAdmin configuration storage is not working.'
|
||||
);
|
||||
@ -542,20 +554,6 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
|
||||
*/
|
||||
public function typeInTextArea($text, $index=0)
|
||||
{
|
||||
/**
|
||||
* Firefox needs some escaping of a text, see
|
||||
* https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/1723
|
||||
*/
|
||||
if (mb_strtolower($this->getBrowser()) == 'firefox') {
|
||||
$text = str_replace(
|
||||
"(",
|
||||
PHPUnit_Extensions_Selenium2TestCase_Keys::SHIFT
|
||||
. PHPUnit_Extensions_Selenium2TestCase_Keys::NUMPAD9
|
||||
. PHPUnit_Extensions_Selenium2TestCase_Keys::NULL,
|
||||
$text
|
||||
);
|
||||
}
|
||||
|
||||
$this->execute(
|
||||
array(
|
||||
'script' => "var cm = $('.CodeMirror')[" . $index . "].CodeMirror;"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user