Merge pull request #12855 from devenbansod/fix_selenium
Fix some Selenium tests
This commit is contained in:
commit
a1e7922c62
@ -43,7 +43,7 @@ class PMA_SeleniumCreateDropDatabaseTest extends PMA_SeleniumBase
|
||||
|
||||
$this->_dropDatabase();
|
||||
|
||||
$this->waitForElement('byLinkText', "Databases")->click();
|
||||
$this->waitForElement('byPartialLinkText','Databases')->click();
|
||||
$this->waitForElementNotPresent('byCssSelector', 'div#loading_parent');
|
||||
|
||||
$element = $this->waitForElement('byId', 'text_create_db');
|
||||
@ -52,9 +52,7 @@ class PMA_SeleniumCreateDropDatabaseTest extends PMA_SeleniumBase
|
||||
|
||||
$this->byId("buttonGo")->click();
|
||||
|
||||
$element = $this->waitForElement(
|
||||
"byCssSelector", "span.ajax_notification div.success"
|
||||
);
|
||||
$element = $this->waitForElement('byLinkText', 'Database: ' . $this->database_name);
|
||||
|
||||
$this->_dropDatabase();
|
||||
}
|
||||
@ -68,15 +66,16 @@ class PMA_SeleniumCreateDropDatabaseTest extends PMA_SeleniumBase
|
||||
{
|
||||
$this->gotoHomepage();
|
||||
|
||||
$this->byLinkText("Databases")->click();
|
||||
$this->byPartialLinkText('Databases')->click();
|
||||
$this->waitForElementNotPresent('byCssSelector', 'div#loading_parent');
|
||||
|
||||
$this->scrollIntoView('tableslistcontainer');
|
||||
$this->byCssSelector(
|
||||
"input[name='selected_dbs[]'][value='" . $this->database_name . "']"
|
||||
)->click();
|
||||
|
||||
$this->byCssSelector("button.mult_submit")->click();
|
||||
$this->byCssSelector("span.ui-button-text:nth-child(1)")->click();
|
||||
$this->byCssSelector("button.submitOK")->click();
|
||||
|
||||
$this->waitForElementNotPresent(
|
||||
"byCssSelector",
|
||||
|
||||
@ -57,8 +57,12 @@ class PMA_SeleniumCreateRemoveUserTest extends PMA_SeleniumBase
|
||||
public function testCreateRemoveUser()
|
||||
{
|
||||
$this->login();
|
||||
$this->waitForElement('byLinkText', "Users")->click();
|
||||
$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();
|
||||
|
||||
@ -68,22 +72,32 @@ class PMA_SeleniumCreateRemoveUserTest extends PMA_SeleniumBase
|
||||
$select = $this->select($this->byId("select_pred_hostname"));
|
||||
$select->selectOptionByLabel("Local");
|
||||
|
||||
$this->byId("button_generate_password")->click();
|
||||
$this->scrollIntoView('button_generate_password');
|
||||
$genButton = $this->waitForElement('byId', 'button_generate_password');
|
||||
$genButton->click();
|
||||
|
||||
$this->assertNotEquals("", $this->byId("text_pma_pw")->value());
|
||||
$this->assertNotEquals("", $this->byId("text_pma_pw2")->value());
|
||||
$this->assertNotEquals("", $this->byId("generated_pw")->value());
|
||||
|
||||
$this->byId("text_pma_pw")->value($this->_txtPassword);
|
||||
$this->byId("text_pma_pw2")->value($this->_txtPassword);
|
||||
$this->byId("createdb-1")->click();
|
||||
$this->byId("createdb-2")->click();
|
||||
|
||||
// Make sure the element is visible before clicking
|
||||
$this->scrollIntoView('createdb-1');
|
||||
$this->waitForElement('byId', 'createdb-1')->click();
|
||||
$this->waitForElement('byId', 'createdb-2')->click();
|
||||
|
||||
$this->scrollIntoView('addUsersForm_checkall');
|
||||
$this->byId("addUsersForm_checkall")->click();
|
||||
$this->byName("adduser_submit")->click();
|
||||
|
||||
$this->waitForElement('byId', "adduser_submit")->click();
|
||||
|
||||
$success = $this->waitForElement("byCssSelector", "div.success");
|
||||
$this->assertContains('You have added a new user', $success->text());
|
||||
|
||||
$this->waitForElement('byLinkText', "Users")->click();
|
||||
// Removing the newly added user
|
||||
$this->waitForElement('byPartialLinkText', "User accounts")->click();
|
||||
$el = $this->waitForElement("byId", "usersForm");
|
||||
$temp = $this->_txtUsername . "localhost";
|
||||
|
||||
@ -93,7 +107,7 @@ class PMA_SeleniumCreateRemoveUserTest extends PMA_SeleniumBase
|
||||
|
||||
$this->byId("checkbox_drop_users_db")->click();
|
||||
$this->byId("buttonGo")->click();
|
||||
$this->waitForElement("byCssSelector", "button.confirmOK")->click();
|
||||
$this->waitForElement("byCssSelector", "button.submitOK")->click();
|
||||
$this->acceptAlert();
|
||||
|
||||
$success = $this->waitForElement("byCssSelector", "div.success");
|
||||
|
||||
@ -36,7 +36,9 @@ class PMA_SeleniumDbEventsTest extends PMA_SeleniumBase
|
||||
$this->dbQuery(
|
||||
"INSERT INTO `test_table` (val) VALUES (2);"
|
||||
);
|
||||
|
||||
$this->dbQuery(
|
||||
"SET GLOBAL event_scheduler=\"ON\""
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,13 +49,27 @@ class PMA_SeleniumDbEventsTest extends PMA_SeleniumBase
|
||||
public function setUpPage()
|
||||
{
|
||||
$this->login();
|
||||
$this->waitForElement('byLinkText', $this->database_name)->click();
|
||||
$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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear Down function for test cases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
$this->dbQuery("SET GLOBAL event_scheduler=\"OFF\"");
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates procedure for tests
|
||||
*
|
||||
@ -65,7 +81,7 @@ class PMA_SeleniumDbEventsTest extends PMA_SeleniumBase
|
||||
$end = date('Y-m-d H:i:s', strtotime('+1 day'));
|
||||
|
||||
$this->dbQuery(
|
||||
"CREATE EVENT `test_event` ON SCHEDULE EVERY 2 MINUTE_SECOND STARTS "
|
||||
"CREATE EVENT `test_event` ON SCHEDULE EVERY 1 MINUTE_SECOND STARTS "
|
||||
. "'$start' ENDS '$end' ON COMPLETION NOT PRESERVE ENABLE "
|
||||
. "DO UPDATE `" . $this->database_name
|
||||
. "`.`test_table` SET val = val + 1"
|
||||
@ -84,21 +100,21 @@ class PMA_SeleniumDbEventsTest extends PMA_SeleniumBase
|
||||
$ele = $this->waitForElement("byPartialLinkText", "Events");
|
||||
$ele->click();
|
||||
|
||||
$ele = $this->waitForElement("byLinkText", "Add event");
|
||||
$ele = $this->waitForElement("byPartialLinkText", "Add event");
|
||||
$ele->click();
|
||||
|
||||
$this->waitForElement("byClassName", "rte_form");
|
||||
|
||||
$this->byName("item_name")->value("test_event");
|
||||
|
||||
$this->select($this->byName("item_type"))
|
||||
->selectOptionByLabel("RECURRING");
|
||||
|
||||
$this->byName("item_interval_value")->value("1");
|
||||
|
||||
$this->byName("item_name")->value("test_event");
|
||||
$this->select($this->byName("item_interval_field"))
|
||||
->selectOptionByLabel("MINUTE_SECOND");
|
||||
|
||||
$ele = $this->waitForElement('byName', "item_interval_value");
|
||||
$ele->value('1');
|
||||
|
||||
$this->byName("item_starts")
|
||||
->value(date('Y-m-d H:i:s', strtotime('-1 day')));
|
||||
|
||||
@ -106,7 +122,7 @@ class PMA_SeleniumDbEventsTest extends PMA_SeleniumBase
|
||||
->value(date('Y-m-d H:i:s', strtotime('+1 day')));
|
||||
|
||||
$proc = "UPDATE " . $this->database_name . ".`test_table` SET val=val+1";
|
||||
$this->typeInTextArea($proc);
|
||||
$this->typeInTextArea($proc, 2);
|
||||
|
||||
$this->byXPath("//button[contains(., 'Go')]")->click();
|
||||
|
||||
@ -155,13 +171,13 @@ class PMA_SeleniumDbEventsTest extends PMA_SeleniumBase
|
||||
"//legend[contains(., 'Events')]"
|
||||
);
|
||||
|
||||
$this->byLinkText("Edit")->click();
|
||||
$this->byPartialLinkText("Edit")->click();
|
||||
|
||||
$this->waitForElement("byClassName", "rte_form");
|
||||
$this->byName("item_interval_value")->clear();
|
||||
$this->byName("item_interval_value")->value("1");
|
||||
$this->typeInTextArea("00");
|
||||
$this->byName("item_interval_value")->value("2");
|
||||
|
||||
$this->sleep();
|
||||
$this->byXPath("//button[contains(., 'Go')]")->click();
|
||||
|
||||
$ele = $this->waitForElement(
|
||||
@ -170,12 +186,12 @@ class PMA_SeleniumDbEventsTest extends PMA_SeleniumBase
|
||||
. "'Event `test_event` has been modified')]"
|
||||
);
|
||||
|
||||
usleep(2000000);
|
||||
usleep(2200000);
|
||||
$result = $this->dbQuery(
|
||||
"SELECT val FROM `" . $this->database_name . "`.`test_table`"
|
||||
);
|
||||
$row = $result->fetch_assoc();
|
||||
$this->assertGreaterThan(100, $row['val']);
|
||||
$this->assertGreaterThan(4, $row['val']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,9 +211,9 @@ class PMA_SeleniumDbEventsTest extends PMA_SeleniumBase
|
||||
"//legend[contains(., 'Events')]"
|
||||
);
|
||||
|
||||
$this->byLinkText("Drop")->click();
|
||||
$this->byPartialLinkText("Drop")->click();
|
||||
$this->waitForElement(
|
||||
"byXPath", "//button[contains(., 'OK')]"
|
||||
"byClassName", "submitOK"
|
||||
)->click();
|
||||
|
||||
$this->waitForElement("byId", "nothing2display");
|
||||
|
||||
@ -535,11 +535,12 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
|
||||
/**
|
||||
* Type text in textarea (CodeMirror enabled)
|
||||
*
|
||||
* @param string $text Text to type
|
||||
* @param string $text Text to type
|
||||
* @param string $index Index of CodeMirror instance to write to
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function typeInTextArea($text)
|
||||
public function typeInTextArea($text, $index=0)
|
||||
{
|
||||
/**
|
||||
* Firefox needs some escaping of a text, see
|
||||
@ -555,8 +556,13 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
|
||||
);
|
||||
}
|
||||
|
||||
$this->byClassName("CodeMirror-scroll")->click();
|
||||
$this->keys($text);
|
||||
$this->execute(
|
||||
array(
|
||||
'script' => "var cm = $('.CodeMirror')[" . $index . "].CodeMirror;"
|
||||
. "cm.setValue('" . $text . "');",
|
||||
'args' => array()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -566,19 +572,17 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
|
||||
*/
|
||||
public function expandMore()
|
||||
{
|
||||
$ele = null;
|
||||
try {
|
||||
$this->waitForElement('byCssSelector', 'li.submenu > a');
|
||||
$ele = $this->waitForElement('byCssSelector', 'li.submenu > a');
|
||||
} catch (PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
|
||||
return;
|
||||
}
|
||||
/* We need to resize to ensure it fits into accessible area */
|
||||
$this->execute(
|
||||
array(
|
||||
'script' => "$('#topmenu').css('font-size', '50%');"
|
||||
. "$(window).resize()",
|
||||
'args' => array()
|
||||
)
|
||||
);
|
||||
|
||||
// Will never be 'null' here
|
||||
$ele->click();
|
||||
$this->waitForElement('byCssSelector', 'li.submenuhover > a');
|
||||
|
||||
$this->sleep();
|
||||
}
|
||||
|
||||
@ -615,4 +619,28 @@ abstract class PMA_SeleniumBase extends PHPUnit_Extensions_Selenium2TestCase
|
||||
"//a[@class='tabactive' and contains(., 'Browse')]"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls to a coordinate such that the element with given id is visible
|
||||
*
|
||||
* @param string $element_id Id of the element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function scrollIntoView($element_id)
|
||||
{
|
||||
// 70pt offset so that the topmenu does not cover the element
|
||||
$this->execute(
|
||||
array(
|
||||
'script' => 'var element = document.getElementById("'
|
||||
. $element_id . '");'
|
||||
. 'var position = element.getBoundingClientRect();'
|
||||
. 'var x = position.left;'
|
||||
. 'var y = position.top;'
|
||||
. 'window.scrollTo(x, y-70);',
|
||||
'args' => array()
|
||||
)
|
||||
);
|
||||
usleep(10000);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user