<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*/
- function webtestFillAutocomplete($sortName, $fieldName = 'contact_1') {
- $this->click($fieldName);
- $this->type($fieldName, $sortName);
- $this->typeKeys($fieldName, $sortName);
- $this->waitForElementPresent("css=div.ac_results-inner li");
- $this->click("css=div.ac_results-inner li");
- $this->assertContains($sortName, $this->getValue($fieldName), "autocomplete expected $sortName but didn’t find it in " . $this->getValue($fieldName));
+ function webtestFillAutocomplete($sortName, $fieldName = 'contact_id') {
+ $this->select2($fieldName,$sortName);
+ //$this->assertContains($sortName, $this->getValue($fieldName), "autocomplete expected $sortName but didn’t find it in " . $this->getValue($fieldName));
}
/**
*/
function webtestOrganisationAutocomplete($sortName) {
- $this->type('contact_name', $sortName);
- $this->click('contact_name');
- $this->waitForElementPresent("css=div.ac_results-inner li");
- $this->click("css=div.ac_results-inner li");
+ $this->clickAt("//*[@id='contact_id']/../div/a");
+ $this->waitForElementPresent("//*[@id='select2-drop']/div/input");
+ $this->keyDown("//*[@id='select2-drop']/div/input", " ");
+ $this->type("//*[@id='select2-drop']/div/input", $sortName);
+ $this->typeKeys("//*[@id='select2-drop']/div/input", $sortName);
+ $this->waitForElementPresent("//*[@class='select2-result-label']");
+ $this->clickAt("//*[@class='select2-results']/li[1]");
//$this->assertContains($sortName, $this->getValue('contact_1'), "autocomplete expected $sortName but didn’t find it in " . $this->getValue('contact_1'));
}
$this->waitForPageToLoad($this->getTimeoutMsec());
}
- function webtestAddMembershipType($period_type = 'rolling', $duration_interval = 1, $duration_unit = 'year', $auto_renew = 'no') {
+ function webtestAddMembershipType($period_type = 'Rolling', $duration_interval = 1, $duration_unit = 'year', $auto_renew = 'no') {
$membershipTitle = substr(sha1(rand()), 0, 7);
$membershipOrg = $membershipTitle . ' memorg';
$this->webtestAddOrganization($membershipOrg, TRUE);
break;
}
- $this->type('member_of_contact', $membershipTitle);
- $this->click('member_of_contact');
- $this->waitForElementPresent("css=div.ac_results-inner li");
- $this->click("css=div.ac_results-inner li");
+ $this->select2('member_of_contact_id',$membershipTitle);
$this->type('minimum_fee', '100');
$this->select('financial_type_id', "value={$memTypeParams['financial_type']}");
else {
$this->click("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[oldname]']/../td[7]/span/a[text()='Edit']");
}
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->waitForElementPresent("name");
$this->type('name', $financialType['name']);
if ($option == 'new') {
$this->type('description', $financialType['name'] . ' description');
}
}
- //sleep method is used as to wait for custom field div to load -
- //we cant use wait for the div element as we are asserting for the same,
- //so wait for some time till the div loads
- sleep(1);
-
//checking for proper custom data which is loading through ajax
- $this->assertElementPresent("xpath=//div[@id='{$customData['cgtitle']}'][@class='crm-accordion-body']",
+ $this->waitForElementPresent("xpath=//div[contains(@class, 'custom-group-{$customData['cgtitle']}')]",
"The on the fly custom group has not been rendered for entity : {$entity} => {$entityData}");
- $this->assertElementPresent("xpath=//div[@id='{$customData['cgtitle']}'][@class='crm-accordion-body']/table/tbody/tr/td[2]/input",
+ $this->assertElementPresent("xpath=//div[contains(@class, 'custom-group-{$customData['cgtitle']}')]/[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}");
}
}
}
return $return;
}
+
+ /**
+ * function to type and select first occurance of autocomplete
+ */
+ function select2($fieldName,$label) {
+ $this->clickAt("//*[@id='$fieldName']/../div/a");
+ $this->waitForElementPresent("//*[@id='select2-drop']/div/input");
+ $this->keyDown("//*[@id='select2-drop']/div/input", " ");
+ $this->type("//*[@id='select2-drop']/div/input", $label);
+ $this->typeKeys("//*[@id='select2-drop']/div/input", $label);
+ $this->waitForElementPresent("//*[@class='select2-result-label']");
+ $this->clickAt("//*[@class='select2-results']/li[1]");
+ }
}