Skip to content

Commit

Permalink
selenium: new features
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Gordo committed Apr 25, 2012
1 parent b601bb2 commit e8b7e13
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 26 deletions.
9 changes: 4 additions & 5 deletions tests/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,27 @@ function __construct() {
$this->adminPassword = $row['password'];
$this->sleepTime = intval($row['sleep']);


$db->disconnect();

$this->fullSandboxPath = $this->sandboxURL . $this->sandboxPATH;
}
}





/*
create database selenium;
use selenium;
create table `test` (tid int primary key AUTO_INCREMENT, host varchar(255) not null default 'http://sd99/',
username varchar(255) not null default 'senateroot', password varchar(255) not null default 'mysql',
searchname varchar(255) not null default 'Mike Gordo', searchemail varchar(255) not null default 'mgordo@live.com',
spousename1 varchar(100) not null default 'Ascher', spousename2 varchar(100) not null default 'Mike Gordo',
time bigint not null, browser varchar(20) not null default '*firefox', sleep int not null default 0,
testname varchar(255));
create table `log` (id int primary key AUTO_INCREMENT, tid int, text varchar(500));
*/


Expand Down
23 changes: 17 additions & 6 deletions tests/config.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# configuration file
######################
# configuration file #
######################

# FORMAT:
# testId <TAB> display name <TAB> file name <TAB> settings <TAB> help line - (optional)


1 Actions - Add case testActionsAddCase3_5.php SearchName Please input the search name. If found, case will be added to that person, then removed.

2 Actions - Add relationship testActionsAddRelationship3_7.php SpouseName Please input the names for both persons. They shouldn't be in a relationship. If found, relationship will be added, then removed.
Expand Down Expand Up @@ -47,9 +50,17 @@
22 Add Contacts to a Smart Group testAddSmartGroup4_18.php SearchName Please input the search name. If found, all contacts with this name will be added to the smart group.
# The following line must start with semicolon, it may be anywhere in this file
# it specifies the domain name. e.g. ".crmdev.nysenate.gov" (without quotes)
############################################################################################
# The following lines must start with semicolon, they may be anywhere in this file
# they specifies the available environments. e.g. ".crmdev.nysenate.gov" (without quotes)
# FORMAT: ; <TAB> id <TAB> domain
############################################################################################
; 1 .crmdev.nysenate.gov
; 2 .crmtest.nysenate.gov
; 3 .crmprod.nysenate.gov
; 4 /
; .crmtest.nysenate.gov
#; .crmdev.nysenate.gov
#; /
##################################################################
# List of databases for each environment is in databases.cfg file
##################################################################
34 changes: 34 additions & 0 deletions tests/databases.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#########################################
# List of databases for each environment
#########################################

# FORMAT: environment-id <TAB> database

# 1 .crmdev.nysenate.gov
# ========================

1 sd99
1 sd98
1 sd97


# 2 .crmtest.nysenate.gov
# =========================

2 sd99
2 sd95
2 sd90

# 3 .crmprod.nysenate.gov
# =========================

3 sd90
3 sd94

# 4 /
# =====

4 sd91
4 sd92
4 sd99

23 changes: 23 additions & 0 deletions tests/html/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,28 @@

</div> <!-- wrap -->

<script type="text/javascript">

$(document).ready(function(){
$("#envir-select").val('<?php echo $envir;?>');
$("#envir-select option:selected").trigger('click');
$("#host-list").val('<?php echo $host;?>');
});

function changed(id) {
$("#host-list option").remove();
<?php
foreach ($list as $id => $l) {
echo "if (id == '$id') {\n";
foreach ($l as $ls) {
echo "$(\"#host-list\").append(\"<option value='$ls'>$ls</option>\"); \n";
}
echo "}\n";
}
?>
}

</script>

</body>
</html>
46 changes: 44 additions & 2 deletions tests/html/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function readSettings($filename) {
$buffer = trim($buffer);
if (strlen($buffer)>0 && $buffer[0]!='#' && $buffer[0]!=';') {

$sArray = explode("\t", $buffer);
$sArray = explode("\t", $buffer);
$cfg = new configClass();
$cfg->id = trim($sArray[0]);
$cfg->displayName = $sArray[1];
Expand All @@ -41,13 +41,35 @@ function readSettings($filename) {
$config[$nConfig++] = $cfg;
}
if ($buffer[0]==';') { // setting up the domain
$domain = trim(substr($buffer,1));
$temp = explode("\t",trim(substr($buffer,1)));
$domain[] = array('id'=>trim($temp[0]), 'domain'=>trim($temp[1]));
}
}
}
fclose($handle);
}


// read databases list
function readDBlist($filename) {
global $domain;
global $list;
$handle = @fopen($filename, "r");
if ($handle) {
while (($buffer = fgets($handle, 4096)) != false ) {
$buffer = trim($buffer);
if (strlen($buffer)>0 && $buffer[0]!='#') {
$sArray = explode("\t", $buffer);
$sArray[0] = trim($sArray[0]);
$sArray[1] = trim($sArray[1]);
$list[$sArray[0]][] = $sArray[1];
}
}
}
fclose($handle);
}// function


// read help file
function readHelpFile($filename) {
global $config;
Expand Down Expand Up @@ -96,4 +118,24 @@ function dump($data) {
}


/*
Example of usage :
$content = getFile('http://codepax.com');
and the function itself :
function getFile($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$tmp = curl_exec($ch);
curl_close($ch);
if ($tmp != false){
return $tmp;
}
}
*/

?>
1 change: 1 addition & 0 deletions tests/html/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function multitest() {
$(this).css('display', 'inline-block');
});
}

</script>
</head>

Expand Down
33 changes: 22 additions & 11 deletions tests/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@

$config = array();
$nConfig = 0;
$domain = "/";
$domain = array();
$list = array();

readSettings("config.cfg");
readDBlist("databases.cfg");
readHelpFile("help.cfg");
?>


<form method="post" action="index2.php" onsubmit="javascript:givememore();" >

<div id="script-tree">
Expand Down Expand Up @@ -95,7 +96,7 @@
</div><!-- settings -->

<div class="new-settings">
<h3>General settings <span class="small">(test server: <em><?php echo $domain;?></em>)</span></h3>
<h3>General settings</h3>

<?php
if ($update==1) { // read some patricular settings
Expand All @@ -109,10 +110,11 @@

$host = $row['host']; // cut everything except for district name e.g. sd99
if (substr($host,0,7)=="http://") {
$host = substr($host, 7);
$_host = explode("/", $host);
$host_full = substr($host, 7);
$_host = explode("/", $host_full);
$_host = explode(".", $_host[0]);
$host = $_host[0];
$envir = substr($host_full, strlen($host)); // current environment
}

?>
Expand All @@ -124,21 +126,31 @@
<option value="*iexplore" <?php if ($row['browser']=="*iexplore") echo "selected"; ?>>Internet Explorer</option>
</select> <br />

<label>Environment:</label>
<select id="envir-select" name="domain">
<?php
foreach ($domain as $d) {
echo "<option onclick=\"changed(".$d['id'].");\" value=\"".$d['domain']."\">".$d['domain']."</option>";
}
?>
</select><br/>

<label>Host:</label>
<input type="text" name="host" class="text" value="<?php echo $host; ?>" onkeydown="return kd(event)"><br />
<select id="host-list" name="host">

</select><br />

<h3 id="more-settings-link-h3"><a id="more-settings-link" href="javascript:givememore();">More settings ...</a></h3>

<div id="more-settings" style="display:none;">
<label>Number of instances:</label>
<input type="text" name="nins" class="text" value="1" onkeydown="return kd(event)"><br />
<!--<label>Number of instances:</label>
<input type="text" name="nins" class="text" value="1" onkeydown="return kd(event)"><br />-->

<label>Username:</label>
<input type="text" name="username" class="text" value="<?php echo $row['username']; ?>" onkeydown="return kd(event)"><br />
<input style="width:150px;" type="text" name="username" class="text" value="<?php echo $row['username']; ?>" onkeydown="return kd(event)"><br />

<label>Password:</label>
<input type="text" name="password" class="text" value="<?php echo $row['password']; ?>" onkeydown="return kd(event)"><br />
<input style="width:150px;" type="text" name="password" class="text" value="<?php echo $row['password']; ?>" onkeydown="return kd(event)"><br />

<label>Pause:</label>
<input type="text" name="sleep" class="text" value="<?php echo $row['sleep']; ?>" onkeydown="return kd(event)"><br />
Expand Down Expand Up @@ -166,7 +178,6 @@


<input type="hidden" name="save" id="save" value="yes" /> <!-- IGNORE THIS LINE! -->
<input type="hidden" name="domain" id="domain" value="<?php echo $domain;?>" />
<input type="hidden" name="multi" id="multi" value="" />


Expand Down
29 changes: 27 additions & 2 deletions tests/testAddGroup4_18.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,40 @@ public function performTasks() {
// select Create New Group
$this->click("CIVICRM_QFID_1_4");
$this->waitForElementPresent("title");
$this->type("title","Group of ".$keyword."s");
$groupname = "Group of ".$keyword."s";
$this->type("title", $groupname);
$this->type("description","This group was created by the test script.");

// click Add To Group
$this->waitForElementPresent("_qf_AddToGroup_next-bottom");
$this->click("_qf_AddToGroup_next-bottom");
$this->waitForPageToLoad('30000');

$this->assertTrue($this->isTextPresent("Added"),"Error: Script could not add contacts to the group ");
$this->assertTrue($this->isTextPresent("Added"),"Error: Script could not create the group ");

$this->click("xpath=//ul[@id='nyss-menu']/li[4]"); // using xpath to find the Manage menu
$this->waitForElementPresent('link=Manage Groups'); // wait until menu opens
$this->click('link=Manage Groups'); // click the link
$this->waitForPageToLoad('30000');

// delete group
$this->waitForElementPresent('title');
$this->type('title',$groupname);
$this->waitForElementPresent('_qf_Search_refresh');
$this->click('_qf_Search_refresh');

// click on more->
$this->waitForElementPresent('crm-group-selector');
$this->click("xpath=//table[@id='crm-group-selector']/tbody[1]/tr[1]/td[6]/span[2]");
// click on Delete
$this->click("xpath=//span[@class='btn-slide']/ul[@class='panel']/li[1]/a[1]");
$this->waitForPageToLoad('30000');

$this->waitForElementPresent('_qf_Edit_next-bottom');
$this->click('_qf_Edit_next-bottom');
$this->waitForPageToLoad('30000');

$this->assertTrue($this->isTextPresent("deleted"),"Error: Script could not delete the group ");
}

private function openAdvancedSearch() {
Expand Down
24 changes: 24 additions & 0 deletions tests/testAddSmartGroup4_18.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@ public function performTasks() {
$this->waitForPageToLoad('30000');

$this->assertTrue($this->isTextPresent("has been saved"),"Error: Script could not add contacts to the smart group ");

$this->click("xpath=//ul[@id='nyss-menu']/li[4]"); // using xpath to find the Manage menu
$this->waitForElementPresent('link=Manage Groups'); // wait until menu opens
$this->click('link=Manage Groups'); // click the link
$this->waitForPageToLoad('30000');

// delete group
$this->waitForElementPresent('title');
$this->type('title',$groupname);
$this->waitForElementPresent('_qf_Search_refresh');
$this->click('_qf_Search_refresh');

// click on more->
$this->waitForElementPresent('crm-group-selector');
$this->click("xpath=//table[@id='crm-group-selector']/tbody[1]/tr[1]/td[6]/span[2]");
// click on Delete
$this->click("xpath=//span[@class='btn-slide']/ul[@class='panel']/li[1]/a[1]");
$this->waitForPageToLoad('30000');

$this->waitForElementPresent('_qf_Edit_next-bottom');
$this->click('_qf_Edit_next-bottom');
$this->waitForPageToLoad('30000');

$this->assertTrue($this->isTextPresent("deleted"),"Error: Script could not delete the group ");
}

private function openAdvancedSearch() {
Expand Down

0 comments on commit e8b7e13

Please sign in to comment.