}
$this->open("{$this->sboxPath}civicrm/$url");
$this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->checkForErrorsOnPage();
if ($waitFor) {
$this->waitForElementPresent($waitFor);
}
// conditional wait for page load e.g for ajax form save
if ($waitForPageLoad) {
$this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->checkForErrorsOnPage();
}
if ($waitFor) {
$this->waitForElementPresent($waitFor);
}
/**
- * Click a link or button and wait for the ajax content to load
+ * Click a link or button and wait for an ajax dialog to load
* @param string $element
* @param string $waitFor
*/
- function clickAjaxLink($element, $waitFor = 'css=.ui-dialog') {
+ function clickPopupLink($element, $waitFor=NULL) {
+ $this->clickAjaxLink($element, 'css=.ui-dialog');
+ if ($waitFor) {
+ $this->waitForElementPresent($waitFor);
+ }
+ }
+
+ /**
+ * Click a link or button and wait for ajax content to load or refresh
+ * @param string $element
+ * @param string $waitFor
+ */
+ function clickAjaxLink($element, $waitFor=NULL) {
$this->click($element);
if ($waitFor) {
$this->waitForElementPresent($waitFor);
}
/**
- * @param $option_group_name
+ * @param string $option_group_name
*
* @return array|int
*/
}
}
if ($added) {
- $this->click("_qf_Component_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForText('crm-notification-container', "Saved");
+ $this->clickLink("_qf_Component_next-bottom");
+ $this->checkCRMAlert("Saved");
}
}
//$this->assertContains($sortName, $this->getValue('contact_1'), "autocomplete expected $sortName but didn’t find it in " . $this->getValue('contact_1'));
}
- /*
- * 1. By default, when no strtotime arg is specified, sets date to "now + 1 month"
- * 2. Does not set time. For setting both date and time use webtestFillDateTime() method.
- * 3. Examples of $strToTime arguments -
- * webtestFillDate('start_date',"now")
- * webtestFillDate('start_date',"10 September 2000")
- * webtestFillDate('start_date',"+1 day")
- * webtestFillDate('start_date',"+1 week")
- * webtestFillDate('start_date',"+1 week 2 days 4 hours 2 seconds")
- * webtestFillDate('start_date',"next Thursday")
- * webtestFillDate('start_date',"last Monday")
- */
/**
+ * 1. By default, when no strtotime arg is specified, sets date to "now + 1 month"
+ * 2. Does not set time. For setting both date and time use webtestFillDateTime() method.
+ * 3. Examples of $strToTime arguments -
+ * webtestFillDate('start_date',"now")
+ * webtestFillDate('start_date',"10 September 2000")
+ * webtestFillDate('start_date',"+1 day")
+ * webtestFillDate('start_date',"+1 week")
+ * webtestFillDate('start_date',"+1 week 2 days 4 hours 2 seconds")
+ * webtestFillDate('start_date',"next Thursday")
+ * webtestFillDate('start_date',"last Monday")
* @param $dateElement
* @param null $strToTimeArgs
*/
$this->click("link=$day");
}
- // 1. set both date and time.
/**
+ * 1. set both date and time.
* @param $dateElement
* @param null $strToTimeArgs
*/
// 6 - Household profile
$profile = array('4' => 'New Individual', '5' => 'New Organization', '6' => 'New Household');
$this->clickAt("xpath=//div[@id='$selectId']/a");
- $this->clickAjaxLink("xpath=//li[@class='select2-no-results']//a[contains(text(),' $profile[$type]')]");
-
- $this->waitForElementPresent('_qf_Edit_next');
+ $this->clickPopupLink("xpath=//li[@class='select2-no-results']//a[contains(text(),' $profile[$type]')]", '_qf_Edit_next');
switch ($type) {
case 4:
* @param bool $pledges
* @param bool $recurring
* @param bool $membershipTypes
- * @param null $memPriceSetId
+ * @param int $memPriceSetId
* @param bool $friend
* @param int $profilePreId
* @param int $profilePostId
}
/**
- * Function to update default strict rule.
+ * Update default strict rule.
*
- * @params string $contactType Contact type
* @param string $contactType
- * @param array $fields Fields to be set for strict rule
- * @param Integer $threshold Rule's threshold value
+ * @param array $fields Fields to be set for strict rule
+ * @param int $threshold Rule's threshold value
*/
function webtestStrictDedupeRuleDefault($contactType = 'Individual', $fields = array(), $threshold = 10) {
// set default strict rule.
// Request a record from the DB by seachColumn+searchValue. Success if a record is found.
/**
- * @param $daoName
+ * @param string $daoName
* @param $searchValue
* @param $returnColumn
* @param $searchColumn
// Request a record from the DB by seachColumn+searchValue. Success if returnColumn value is NULL.
/**
- * @param $daoName
+ * @param string $daoName
* @param $searchValue
* @param $returnColumn
* @param $searchColumn
// Request a record from the DB by id. Success if row not found.
/**
- * @param $daoName
- * @param $id
+ * @param string $daoName
+ * @param int $id
* @param $message
*/
function assertDBRowNotExist($daoName, $id, $message) {
// Compare a single column value in a retrieved DB record to an expected value
/**
- * @param $daoName
+ * @param string $daoName
* @param $searchValue
* @param $returnColumn
* @param $searchColumn
// Compare all values in a single retrieved DB record to an array of expected values
/**
- * @param $daoName
- * @param $searchParams
+ * @param string $daoName
+ * @param array $searchParams
* @param $expectedValues
*/
function assertDBCompareValues($daoName, $searchParams, $expectedValues) {
}
/**
- * @param $name
+ * @param string $name
* @param $sku
* @param $amount
* @param $price
* @param $financialType
*/
function addPremium($name, $sku, $amount, $price, $cost, $financialType) {
- $this->waitForElementPresent("_qf_ManagePremiums_next-bottom");
+ $this->waitForElementPresent("_qf_ManagePremiums_upload-bottom");
$this->type("name", $name);
$this->type("sku", $sku);
$this->click("CIVICRM_QFID_noImage_16");
if ($financialType) {
$this->select("financial_type_id", "label={$financialType}");
}
- $this->click("_qf_ManagePremiums_next-bottom");
+ $this->click("_qf_ManagePremiums_upload-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
}
* @return void
*/
function customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl, $beforeTriggering = NULL) {
+ // FIXME: Testing a theory that these failures have something to do with permissions
+ $this->webtestLogin('admin');
+
//add the custom set
$return = $this->addCustomGroupField($customSets);
}
$this->openCiviPage($pageUrl['url'], $pageUrl['args']);
- // Open the page again just to make sure caches are cleared
- $this->openCiviPage($pageUrl['url'], $pageUrl['args']);
+
+ // FIXME: Try to find out what the heck is going on with these tests
+ $this->waitForAjaxContent();
+ $this->checkForErrorsOnPage();
+
foreach($return as $values) {
foreach ($values as $entityType => $customData) {
//initiate necessary variables
$this->select2($elementName, $entityData);
}
}
+ // FIXME: Try to find out what the heck is going on with these tests
+ $this->waitForAjaxContent();
+ $this->checkForErrorsOnPage();
+
//checking for proper custom data which is loading through ajax
- $this->waitForElementPresent("xpath=//div[contains(@class, 'custom-group-{$customData['cgtitle']}')]");
+ $this->waitForElementPresent("css=.custom-group-{$customData['cgtitle']}");
$this->assertElementPresent("xpath=//div[contains(@class, 'custom-group-{$customData['cgtitle']}')]/div[contains(@class, 'crm-accordion-body')]/table/tbody/tr/td[2]/input",
"The on the fly custom group field is not present for entity : {$entity} => {$entityData}");
}
}
/**
- * function to type and select first occurance of autocomplete
+ * Type and select first occurance of autocomplete
*/
function select2($fieldName,$label, $multiple = FALSE, $xpath=FALSE) {
// In the case of chainSelect, wait for options to load
}
/**
- * function to select multiple options
+ * Select multiple options
*/
function multiselect2($fieldid, $params) {
// In the case of chainSelect, wait for options to load
}
/**
- * function to enable or disable Pop-ups via Display Preferences
+ * Enable or disable Pop-ups via Display Preferences
*/
function enableDisablePopups($enabled = TRUE) {
$this->openCiviPage('admin/setting/preferences/display', 'reset=1');
}
$this->clickLink("_qf_Display_next-bottom");
}
+
+ /**
+ * Attempt to get information about what went wrong if we encounter an error when loading a page
+ */
+ function checkForErrorsOnPage() {
+ foreach (array('Access denied', 'Page not found') as $err) {
+ if ($this->isElementPresent("xpath=//h1[contains(., '$err')]")) {
+ $this->fail("'$err' encountered at " . $this->getLocation() . "\nwhile logged in as '{$this->loggedInAs}'");
+ }
+ }
+ if ($this->isElementPresent("xpath=//span[text()='Sorry but we are not able to provide this at the moment.']")) {
+ $msg = '"Fatal Error" encountered at ' . $this->getLocation();
+ if ($this->isElementPresent('css=div.crm-section.crm-error-message')) {
+ $msg .= "\nError Message: " . $this->getText('css=div.crm-section.crm-error-message');
+ }
+ $this->fail($msg);
+ }
+ }
}