From 3e60ff7f601a75b02405eb9ecdd309e2d8e570b4 Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Thu, 28 Aug 2014 18:54:00 +0530 Subject: [PATCH] Webtest Fix 4.5 --- CRM/Financial/Form/FinancialTypeAccount.php | 2 +- tests/phpunit/CiviTest/CiviSeleniumTestCase.php | 12 +++++++----- tests/phpunit/WebTest/Contact/AdvancedSearchTest.php | 12 ++++++------ .../Contact/AdvancedSearchedRelatedContactTest.php | 8 ++++---- tests/phpunit/WebTest/Event/AddEventTest.php | 6 +++--- tests/phpunit/WebTest/Event/AddPricesetTest.php | 10 ++++++---- tests/phpunit/WebTest/Event/EventWaitListTest.php | 1 + .../phpunit/WebTest/Event/ParticipantSearchTest.php | 11 ++++------- 8 files changed, 32 insertions(+), 30 deletions(-) diff --git a/CRM/Financial/Form/FinancialTypeAccount.php b/CRM/Financial/Form/FinancialTypeAccount.php index fc907db9e2..f5264ff54f 100644 --- a/CRM/Financial/Form/FinancialTypeAccount.php +++ b/CRM/Financial/Form/FinancialTypeAccount.php @@ -128,7 +128,7 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form { */ public function buildQuickForm() { parent::buildQuickForm(); - $this->setPageTitle(ts('Financial Type Account'));); + $this->setPageTitle(ts('Financial Type Account')); if ($this->_action & CRM_Core_Action::DELETE) { return; diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 800e2ebe1f..d4e257f952 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -2104,10 +2104,12 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->clickAt("//*[@class='select2-results']/li[1]/div"); } else { - if ($xpath) - $this->clickAt($fieldName); - else - $this->clickAt("//*[@id='$fieldName']/../div/a"); + if ($xpath) { + $this->clickAt($fieldName); + } + else { + $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); @@ -2125,7 +2127,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->clickAt("xpath=//*[@id='$fieldid']/../div/ul//li/input"); $this->waitForElementPresent("xpath=//ul[@class='select2-results']"); $this->clickAt("xpath=//ul[@class='select2-results']//li/div[text()='$value']"); - $this->waitForText("xpath=//*[@id='$fieldid']/../div", $value); + $this->assertElementContainsText("xpath=//*[@id='$fieldid']/preceding-sibling::div[1]/", $value); } } } diff --git a/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php b/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php index 3a1bb9339f..9d5ad0fb94 100644 --- a/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php +++ b/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php @@ -64,7 +64,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { // go to tag tab and add to new tag $this->click("css=li#tab_tag a"); $this->waitForElementPresent("css=div#tagtree"); - $this->click("xpath=//ul/li/label[text()=\"$tagName\"]"); + $this->click("xpath=//ul/li/span/label[text()=\"$tagName\"]"); $this->waitForElementPresent("css=.success"); // is status message correct? @@ -217,7 +217,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { //go to next page $this->click("xpath=//div[@class='crm-search-results']/div[@class='crm-pager']/span[@class='crm-pager-nav']/a[@title='next page']"); - $this->waitForElementPresent("Go"); + $this->waitForElementPresent("task"); $j = $j + $subTotal; } @@ -276,7 +276,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $stateBeforeSort = $this->getText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]"); $this->click("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(),'State')]"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(),'State')]"); $this->assertElementNotContainsText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]", $stateBeforeSort); $this->click("xpath=//form[@id='Advanced']//div//div[contains(text(),'Edit Search Criteria')]/../div"); $this->waitForElementPresent('group'); @@ -294,7 +294,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $stateBeforeSort = $this->getText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]"); $this->click("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(),'State')]"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(),'State')]"); $this->assertElementNotContainsText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]", $stateBeforeSort); } @@ -331,8 +331,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { */ function addAddressSearchDetail($firstName) { // select location type (home and main) - $this->click("xpath=//div[@id='location']/table/tbody/tr[1]/td[1]//label[text()='Home']"); - $this->click("xpath=//div[@id='location']/table/tbody/tr[1]/td[1]//label[text()='Main']"); + $this->multiselect2('location_type', array('Home', 'Main')); // fill street address $this->type("street_address", "street 1 $firstName"); // fill city @@ -343,6 +342,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { // select country $this->select("country", "United States"); // select state-province + $this->waitForElementPresent('state_province'); $this->select("state_province", "Alaska"); } diff --git a/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php b/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php index 70631e2951..479958640d 100644 --- a/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php +++ b/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php @@ -124,7 +124,6 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes $this->select("task", "label=Add Contacts to Group"); - $this->click('Go'); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click('CIVICRM_QFID_1_group_option'); @@ -182,6 +181,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes $this->type("address_1_street_address", $streetAddress); $this->type("address_1_city", "San Francisco"); $this->type("address_1_postal_code", "94117"); + $this->select('address_1_country_id', 'United States'); $this->select("address_1_state_province_id", "value=1004"); $this->type("email_1_email", "info@civicrm.org"); @@ -266,13 +266,13 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes //save the relationship //$this->click("_qf_Relationship_upload"); $this->click('_qf_Relationship_upload-bottom'); - $this->waitForElementPresent("crm-contact-relationship-selector-current_wrapper"); + $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']"); //check the status message $this->waitForText('crm-notification-container', "Relationship created."); - $this->waitForElementPresent("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='View']"); - $this->click("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']//table/tbody//tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@class='dataTables_wrapper no-footer']//table/tbody//tr/td[9]/span/a[text()='View']"); $this->waitForElementPresent("xpath=//table[@class='crm-info-panel']"); $this->webtestVerifyTabularData( diff --git a/tests/phpunit/WebTest/Event/AddEventTest.php b/tests/phpunit/WebTest/Event/AddEventTest.php index 0d9d402b02..a064963a68 100644 --- a/tests/phpunit/WebTest/Event/AddEventTest.php +++ b/tests/phpunit/WebTest/Event/AddEventTest.php @@ -317,8 +317,8 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { $this->assertChecked('is_pay_later'); $this->click("CIVICRM_QFID_0_is_monetary"); - $this->clickLink("_qf_Fee_upload-bottom", "_qf_Fee_upload-bottom", FALSE); - sleep(2); + $this->clickLink("_qf_Fee_upload-bottom", "_qf_Fee_upload-bottom"); + //check if pay later option is disabled $this->click('CIVICRM_QFID_1_is_monetary'); $this->waitForElementPresent('is_pay_later'); @@ -419,6 +419,7 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { $this->type("address_1_street_address", $streetAddress); $this->type("address_1_city", "San Francisco"); $this->type("address_1_postal_code", "94117"); + $this->select('address_1_country_id', 'United States'); $this->select("address_1_state_province_id", "value=1004"); $this->type("email_1_email", "info@civicrm.org"); @@ -786,7 +787,6 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { $this->assertTrue( $this->isElementPresent("xpath=//tr[@class='crm-participant-form-block-registered-by']/td[2]/a[contains(text(), '$primaryDisplayName')]"), 'Registered By info is wrong on additional participant edit form'); - $this->assertElementContainsText("xpath=//form[@id='Participant']/h3", 'Edit Event Registration'); $this->assertTrue( $this->isElementPresent( "xpath=//table/tbody/tr[@class='crm-participant-form-block-displayName']/td[2][contains(text(), diff --git a/tests/phpunit/WebTest/Event/AddPricesetTest.php b/tests/phpunit/WebTest/Event/AddPricesetTest.php index c06f2486e6..e4aae2d7c3 100644 --- a/tests/phpunit/WebTest/Event/AddPricesetTest.php +++ b/tests/phpunit/WebTest/Event/AddPricesetTest.php @@ -88,7 +88,7 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { $this->type('help_pre', $setHelp); $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.'); - $this->clickLink('_qf_Set_next-bottom', '_qf_Field_next-bottom'); + $this->clickLink('_qf_Set_next-bottom', 'newPriceField'); } /** @@ -97,6 +97,7 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { * @param bool $dateSpecificFields */ function _testAddPriceFields(&$fields, &$validateStrings, $dateSpecificFields = FALSE) { + $this->clickLink('newPriceField', '_qf_Field_cancel-bottom', FALSE); foreach ($fields as $label => $type) { $validateStrings[] = $label; @@ -148,7 +149,7 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { ), ); $this->addMultipleChoiceOptions($options, $validateStrings); - $this->check('is_required'); + $this->click('is_required'); if ($dateSpecificFields == TRUE) { $this->webtestFillDateTime('active_on', '-1 week'); } @@ -175,7 +176,8 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { default: break; } - $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom'); + $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom', FALSE); + $this->waitForText('crm-notification-container', "Price Field '".$label."' has been saved."); } } @@ -721,7 +723,7 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { //check the delete for price field $this->openCiviPage("admin/price/field", "reset=1&action=browse&sid={$sid}"); - $this->click("xpath=//table[@id='option11']/tbody/tr/td[9]/span[2]/ul/li[2]/a"); + $this->click("xpath=//table[@id='options']/tbody/tr/td[9]/span[2]/ul/li[2]/a"); //assert the message $this->waitForText('price_set_used_by', "it is currently in use by one or more active events or contribution pages or contributions or event templates."); diff --git a/tests/phpunit/WebTest/Event/EventWaitListTest.php b/tests/phpunit/WebTest/Event/EventWaitListTest.php index ad3a7a5133..293b700c60 100644 --- a/tests/phpunit/WebTest/Event/EventWaitListTest.php +++ b/tests/phpunit/WebTest/Event/EventWaitListTest.php @@ -79,6 +79,7 @@ class WebTest_Event_EventWaitListTest extends CiviSeleniumTestCase { $this->type("address_1_street_address", $streetAddress); $this->type("address_1_city", "San Francisco"); $this->type("address_1_postal_code", "94117"); + $this->select('address_1_country_id', 'United States'); $this->select("address_1_state_province_id", "value=1004"); $this->type("email_1_email", "info@civicrm.org"); diff --git a/tests/phpunit/WebTest/Event/ParticipantSearchTest.php b/tests/phpunit/WebTest/Event/ParticipantSearchTest.php index b24de3e25f..1fcb6878b2 100644 --- a/tests/phpunit/WebTest/Event/ParticipantSearchTest.php +++ b/tests/phpunit/WebTest/Event/ParticipantSearchTest.php @@ -182,7 +182,7 @@ class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { // visit event search page $this->openCiviPage("event/search", "reset=1"); - $this->click("xpath=//div[@id='Food_Preference']/div[2]/table/tbody/tr/td[2]//label[contains(text(),'Chicken Combo')]"); + $this->select("xpath=//div[@id='Food_Preference']/div[2]/table/tbody/tr/td[2]//select", 'Chicken Combo'); $this->click("_qf_Search_refresh"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -194,7 +194,7 @@ class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { $this->_checkStrings($stringsToCheck); - $this->click("xpath=//div[@id='Food_Preference']/div[2]/table/tbody/tr/td[2]//label[contains(text(),'Salmon Stew')]"); + $this->select("xpath=//div[@id='Food_Preference']/div[2]/table/tbody/tr/td[2]//select", 'Salmon Stew'); $this->click("_qf_Search_refresh"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -216,12 +216,10 @@ class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { $this->waitForElementPresent("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']"); $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']"); - $this->waitForElementPresent("_qf_ParticipantView_cancel-bottom"); + $this->waitForTextPresent("View Event Registration"); // ensure we get to particpant view $stringsToCheck = array( - "View Participant", - "Event Registration", "Name", "Event", "Participant Role", @@ -243,11 +241,10 @@ class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { $this->waitForElementPresent("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='Edit']"); $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='Edit']"); - $this->waitForElementPresent("_qf_Participant_cancel-bottom"); + $this->waitForTextPresent("Edit Event Registration"); // ensure we get to particpant view $stringsToCheck = array( - "Edit Event Registration", "Participant", "Event", "Participant Role", -- 2.25.1