Existing selenium tests refactored s that they work with the latest revision.5

This commit is contained in:
Supun Nakandala 2013-02-10 15:57:41 +05:30
parent 84e8341abb
commit 8163dc1c0b
6 changed files with 40 additions and 37 deletions

View File

@ -10,13 +10,12 @@
/**
*
*/
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once dirname(__FILE__).'/selenium/PmaSeleniumTestCase.php';
require_once dirname(__FILE__).'/selenium/PmaSeleniumLoginTest.php';
require_once dirname(__FILE__).'/selenium/PmaSeleniumXssTest.php';
require_once dirname(__FILE__).'/selenium/PmaSeleniumPrivilegesTest.php';
require_once dirname(__FILE__).'/selenium/PmaSeleniumCreateDropDatabaseTest.php';
class AllSeleniumTests
{
public static function main()
@ -27,13 +26,13 @@ class AllSeleniumTests
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('phpMyAdmin');
$suite = new PHPUnit_Extensions_SeleniumTestSuite('phpMyAdmin');
$suite->addTestSuite('PmaSeleniumLoginTest');
$suite->addTestSuite('PmaSeleniumXssTest');
$suite->addTestSuite('PmaSeleniumPrivilegesTest');
$suite->addTestSuite('PmaSeleniumCreateDropDatabaseTest');
$suite->addTestSuite('PmaSeleniumCreateDropDatabaseTest');
return $suite;
}
}
?>
?>

View File

@ -26,8 +26,7 @@ class Helper
public static function logOutIfLoggedIn($selenium)
{
if (self::isLoggedIn($selenium)) {
$selenium->selectFrame("frame_navigation");
$selenium->clickAndWait("css=img.icon.ic_b_home");
$selenium->clickAndWait("css=img.icon.ic_s_loggoff");
}
}

View File

@ -23,19 +23,18 @@ class PmaSeleniumCreateDropDatabaseTest extends PHPUnit_Extensions_SeleniumTestC
{
$log = new PmaSeleniumTestCase($this);
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
$this->selectFrame("frame_content");
$this->click("link=Databases");
$this->waitForPageToLoad("30000");
$this->type("id=text_create_db", "pma");
$this->click("id=buttonGo");
$this->assertTrue($this->isTextPresent("pma"));
$this->click("link=pma");
$this->waitForPageToLoad("30000");
$this->click("link=Operations");
$this->waitForPageToLoad("30000");
$this->click("id=drop_db_anchor");
$this->click("//button[@type='button']");
sleep(10);
$this->type("id=text_create_db", "pma_testdb");
$this->click("id=buttonGo");
sleep(10);
$this->assertTrue($this->isTextPresent("pma_testdb"));
$this->click("xpath=(//input[@name='selected_dbs[]'])[@value='pma_testdb']");
$this->click("css=button.mult_submit.ajax");
$this->click("//button[@type='button']");
$this->click("css=img.icon.ic_b_home");
sleep(10);
$this->assertFalse($this->isTextPresent("pma_testdb"));
}
}

View File

@ -22,9 +22,9 @@ class PmaSeleniumPrivilegesTest extends PHPUnit_Extensions_SeleniumTestCase
{
$log = new PmaSeleniumTestCase($this);
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
$this->selectFrame("frame_content");
$this->click("link=Change password");
$this->waitForPageToLoad("20000");
$this->waitForCondition($this->isElementPresent("id=change_password_anchor")==TRUE,30000);
sleep(5);
try {
$this->assertEquals("", $this->getValue("text_pma_pw"));
} catch (PHPUnit_Framework_AssertionFailedError $e) {
@ -40,16 +40,23 @@ class PmaSeleniumPrivilegesTest extends PHPUnit_Extensions_SeleniumTestCase
} catch (PHPUnit_Framework_AssertionFailedError $e) {
array_push($this->verificationErrors, $e->toString());
}
$this->click("button_generate_password");
$this->assertNotEquals("", $this->getValue("text_pma_pw"));
$this->assertNotEquals("", $this->getValue("text_pma_pw2"));
$this->assertNotEquals("", $this->getValue("generated_pw"));
$this->type("text_pma_pw", TESTSUITE_PASSWORD);
$this->type("text_pma_pw2", TESTSUITE_PASSWORD);
$this->click("//button[@type='button']");
$this->waitForPageToLoad("20000");
$this->assertTrue($this->isTextPresent(""));
$this->assertTrue($this->isTextPresent(""));
}
$this->click("button_generate_password");
$this->assertNotEquals("", $this->getValue("text_pma_pw"));
$this->assertNotEquals("", $this->getValue("text_pma_pw2"));
$this->assertNotEquals("", $this->getValue("generated_pw"));
if(TESTSUITE_PASSWORD!=""){
$this->type("text_pma_pw",TESTSUITE_PASSWORD);
$this->type("text_pma_pw2",TESTSUITE_PASSWORD);
$this->click("xpath=(//button[@type='button'])[1]");
}else{
$this->click("id=nopass_1");
$this->click("xpath=(//button[@type='button'])[1]");
}
sleep(5);
$this->assertTrue($this->isTextPresent("The profile has been updated."));
}
}
?>

View File

@ -61,7 +61,7 @@ class PmaSeleniumTestCase
public function isUnsuccessLogin()
{
$val = $this->_selenium->getValue('input_go');
if ($this->_selenium->isElementPresent("//html/body/div/div[@class='error']")) {
if ($this->_selenium->isElementPresent("//html/body/div/div/div[@class='error']")) {
return true;
} else {
return false;

View File

@ -22,11 +22,10 @@ class PmaSeleniumXSSTest extends PHPUnit_Extensions_SeleniumTestCase
{
$log = new PmaSeleniumTestCase($this);
$log->login(TESTSUITE_USER, TESTSUITE_PASSWORD);
$this->selectFrame("frame_content");
$this->click("link=SQL");
$this->waitForPageToLoad("30000");
sleep(10);
$this->click("button_submit_query");
$this->assertAlert("Missing value in the form!");
}
}
?>
?>