From b9fdba0ad09a4f0717a7cd440731b4ab2afd58c5 Mon Sep 17 00:00:00 2001 From: Web Access Date: Fri, 6 Nov 2015 18:48:57 +0530 Subject: [PATCH] Webtests fixes --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 32 +++++++++++++++++++ .../Campaign/OfflineContributionTest.php | 4 +-- .../Campaign/OnlineEventRegistrationTest.php | 10 +++--- .../WebTest/Case/CaseCustomFieldsTest.php | 2 +- .../WebTest/Contact/AddViaProfileTest.php | 30 +++-------------- .../AdvancedSearchedRelatedContactTest.php | 6 ++-- .../phpunit/WebTest/Contact/GroupAddTest.php | 3 +- .../WebTest/Contact/SearchBuilderTest.php | 4 +-- .../WebTest/Contact/UpdateProfileTest.php | 3 +- .../phpunit/WebTest/Event/TellAFriendTest.php | 4 +-- .../WebTest/Pledge/ContactContextAddTest.php | 2 +- tests/phpunit/WebTest/Profile/SearchTest.php | 1 + 12 files changed, 56 insertions(+), 45 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 2d8cea4dfd..abe1651220 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -2504,4 +2504,36 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { return $contact; } + /** + * Add a contact via profile + */ + public function webtestAddViaCreateProfile() { + $this->webtestLogin(); + + $this->openCiviPage('profile/create', 'reset=1&gid=1', '_qf_Edit_next'); + + $firstName = 'Jo' . substr(sha1(rand()), 0, 4); + $lastName = 'Ad' . substr(sha1(rand()), 0, 7); + + //contact details section + //fill in first name + $this->type("first_name", $firstName); + + //fill in last name + $this->type("last_name", $lastName); + + //address section + $this->type("street_address-1", "902C El Camino Way SW"); + $this->type("city-1", "Dumfries"); + $this->type("postal_code-1", "1234"); + $this->assertSelected('country-1', "UNITED STATES"); + $this->select("state_province-1", "value=1019"); + + // Clicking save. + $this->click("_qf_Edit_next"); + $this->waitForPageToLoad($this->getTimeoutMsec()); + + $this->assertElementContainsText('css=.msg-text', "Your information has been saved."); + } + } diff --git a/tests/phpunit/WebTest/Campaign/OfflineContributionTest.php b/tests/phpunit/WebTest/Campaign/OfflineContributionTest.php index b9fa7aed05..e4e9db7582 100644 --- a/tests/phpunit/WebTest/Campaign/OfflineContributionTest.php +++ b/tests/phpunit/WebTest/Campaign/OfflineContributionTest.php @@ -221,8 +221,8 @@ class WebTest_Campaign_OfflineContributionTest extends CiviSeleniumTestCase { $this->type('sort_name', $firstName); $this->click("_qf_Search_refresh"); - $this->waitForElementPresent("xpath=//div[@id='contributionSearch']/table/tbody/tr/td[11]/span/a[text()='Edit']"); - $this->click("xpath=//div[@id='contributionSearch']/table/tbody/tr/td[11]/span/a[text()='Edit']"); + $this->waitForElementPresent("xpath=//div[@id='contributionSearch']/table/tbody/tr/td[11]/span//a[text()='Edit']"); + $this->click("xpath=//div[@id='contributionSearch']/table/tbody/tr/td[11]/span//a[text()='Edit']"); $this->waitForElementPresent("_qf_Contribution_cancel-bottom"); $this->assertTrue($this->isTextPresent("$campaignTitle")); } diff --git a/tests/phpunit/WebTest/Campaign/OnlineEventRegistrationTest.php b/tests/phpunit/WebTest/Campaign/OnlineEventRegistrationTest.php index 5fde52f109..791153271d 100644 --- a/tests/phpunit/WebTest/Campaign/OnlineEventRegistrationTest.php +++ b/tests/phpunit/WebTest/Campaign/OnlineEventRegistrationTest.php @@ -130,7 +130,7 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase $streetAddress = "100 Main Street"; $this->_testAddLocation($streetAddress); - $this->_testAddFees(FALSE, FALSE, $paymentProcessorId); + $this->_testAddFees(FALSE, FALSE, $processorName); // intro text for registration page $registerIntro = "Fill in all the fields below and click Continue."; @@ -212,12 +212,12 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase * @param bool $priceSet * @param int $processorId */ - public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorId) { + public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName) { // Go to Fees tab $this->click("link=Fees"); $this->waitForElementPresent("_qf_Fee_upload-bottom"); $this->click("CIVICRM_QFID_1_is_monetary"); - $this->check("payment_processor[$processorId]"); + $this->select2('payment_processor', $processorName, TRUE); $this->select("financial_type_id", "value=4"); if ($priceSet) { // get one - TBD @@ -257,8 +257,8 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase $this->assertChecked("is_multiple_registrations"); } - $this->click('intro_text-plain'); - $this->fillRichTextField("intro_text", $registerIntro); + $this->click("xpath=//div[@id='registration_screen']/table/tbody/tr[1]/td[2]/div[@class='replace-plain']"); + $this->fillRichTextField("cke_wysiwyg_frame", $registerIntro); // enable confirmation email $this->click("CIVICRM_QFID_1_is_email_confirm"); diff --git a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php index 85871e0917..6501cfc44e 100644 --- a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php +++ b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php @@ -138,7 +138,7 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { "Priority" => "Normal", ); $this->webtestVerifyTabularData($openCaseData); - $this->click("xpath=//span[@class='ui-button-icon-primary ui-icon ui-icon-closethick']"); + $this->click("xpath=//span[@class='ui-button-icon-primary ui-icon fa-times']"); // verify if custom data is present $this->openCiviPage('case', 'reset=1'); diff --git a/tests/phpunit/WebTest/Contact/AddViaProfileTest.php b/tests/phpunit/WebTest/Contact/AddViaProfileTest.php index 31f9901546..f606401345 100644 --- a/tests/phpunit/WebTest/Contact/AddViaProfileTest.php +++ b/tests/phpunit/WebTest/Contact/AddViaProfileTest.php @@ -35,33 +35,11 @@ class WebTest_Contact_AddViaProfileTest extends CiviSeleniumTestCase { parent::setUp(); } + /** + * Add a contact via profile + */ public function testAddViaCreateProfile() { - $this->webtestLogin(); - - $this->openCiviPage('profile/create', 'reset=1&gid=1', '_qf_Edit_next'); - - $firstName = 'Jo' . substr(sha1(rand()), 0, 4); - $lastName = 'Ad' . substr(sha1(rand()), 0, 7); - - //contact details section - //fill in first name - $this->type("first_name", $firstName); - - //fill in last name - $this->type("last_name", $lastName); - - //address section - $this->type("street_address-1", "902C El Camino Way SW"); - $this->type("city-1", "Dumfries"); - $this->type("postal_code-1", "1234"); - $this->assertSelected('country-1', "UNITED STATES"); - $this->select("state_province-1", "value=1019"); - - // Clicking save. - $this->click("_qf_Edit_next"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - - $this->assertElementContainsText('css=.msg-text', "Your information has been saved."); + $this->webtestAddViaCreateProfile(); } } diff --git a/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php b/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php index ca80dee5b7..3f8ffeae4f 100644 --- a/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php +++ b/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php @@ -52,7 +52,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes $streetAddress = "100 Main Street"; $this->_testAddLocation($streetAddress); - $this->_testAddFees(FALSE, FALSE, $paymentProcessorId); + $this->_testAddFees(FALSE, FALSE, $processorName); $this->openCiviPage('event/manage', 'reset=1'); $this->type('title', $eventTitle); $this->click('_qf_SearchEvent_refresh'); @@ -200,12 +200,12 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes * @param bool $priceSet * @param int $processorId */ - public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorId) { + public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName) { // Go to Fees tab $this->click("link=Fees"); $this->waitForElementPresent("_qf_Fee_upload-bottom"); $this->click("CIVICRM_QFID_1_is_monetary"); - $this->check("payment_processor[{$processorId}]"); + $this->select2('payment_processor', $processorName, TRUE); $this->select("financial_type_id", "value=4"); if ($priceSet) { // get one - TBD diff --git a/tests/phpunit/WebTest/Contact/GroupAddTest.php b/tests/phpunit/WebTest/Contact/GroupAddTest.php index 36852c3172..d6e64fe617 100644 --- a/tests/phpunit/WebTest/Contact/GroupAddTest.php +++ b/tests/phpunit/WebTest/Contact/GroupAddTest.php @@ -74,9 +74,10 @@ class WebTest_Contact_GroupAddTest extends CiviSeleniumTestCase { $this->openCiviPage('group', 'reset=1'); $this->type('title', $params['name']); $this->click('_qf_Search_refresh'); + $this->waitForAjaxContent(); $this->waitForElementPresent("xpath=//table[@class='crm-group-selector no-footer dataTable']/tbody/tr/td/span[contains(text(), '{$params['name']}')]"); $createdBy = $this->getText("xpath=//table[@class='crm-group-selector no-footer dataTable']/tbody/tr/td[3]/a"); - $this->click("xpath=//table[@class='crm-group-selector no-footer dataTable']/tbody/tr/td[7]/span/a[2]"); + $this->click("xpath=//table[@class='crm-group-selector no-footer dataTable']/tbody/tr/td[7]//span/a[text()='Settings']"); $this->waitForElementPresent("xpath=//form[@id='Edit']/div[2]/div/table[1]/tbody/tr[2]/td[contains(text(), '{$createdBy}')]"); $this->openCiviPage('group', 'reset=1'); diff --git a/tests/phpunit/WebTest/Contact/SearchBuilderTest.php b/tests/phpunit/WebTest/Contact/SearchBuilderTest.php index 7b350e0131..075f0e18a6 100644 --- a/tests/phpunit/WebTest/Contact/SearchBuilderTest.php +++ b/tests/phpunit/WebTest/Contact/SearchBuilderTest.php @@ -523,7 +523,7 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { // Find Membership $this->openCiviPage("member/search", "reset=1", "_qf_Search_refresh"); - $this->multiselect2("membership_type_id", array($membershipTypes['membership_type'])); + $this->select2('membership_type_id', $membershipTypes['membership_type'], TRUE); $this->clickLink('_qf_Search_refresh'); $this->waitForText('search-status', "2 Results"); @@ -534,7 +534,7 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { $this->openCiviPage("member/search", "reset=1", "_qf_Search_refresh"); $this->click("xpath=//div[@class='crm-accordion-header crm-master-accordion-header']"); - $this->multiselect2("membership_type_id", array($membershipTypes['membership_type'])); + $this->select2('membership_type_id', $membershipTypes['membership_type'], TRUE); $this->multiselect2("membership_status_id", array("New")); $this->clickLink('_qf_Search_refresh'); $this->waitForText('search-status', "1 Result"); diff --git a/tests/phpunit/WebTest/Contact/UpdateProfileTest.php b/tests/phpunit/WebTest/Contact/UpdateProfileTest.php index f99f5b295a..cfcf5071f2 100644 --- a/tests/phpunit/WebTest/Contact/UpdateProfileTest.php +++ b/tests/phpunit/WebTest/Contact/UpdateProfileTest.php @@ -37,8 +37,7 @@ class WebTest_Contact_UpdateProfileTest extends CiviSeleniumTestCase { public function testUpdateProfile() { // Create new via profile - include_once 'WebTest/Contact/AddViaProfileTest.php'; - WebTest_Contact_AddViaProfileTest::testAddViaCreateProfile(); + $this->webtestAddViaCreateProfile(); // Open profile for editing $locationUrl = $this->getLocation(); diff --git a/tests/phpunit/WebTest/Event/TellAFriendTest.php b/tests/phpunit/WebTest/Event/TellAFriendTest.php index 9563676112..71854be7c9 100644 --- a/tests/phpunit/WebTest/Event/TellAFriendTest.php +++ b/tests/phpunit/WebTest/Event/TellAFriendTest.php @@ -238,8 +238,8 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase { $this->assertChecked("is_multiple_registrations"); } - $this->click('intro_text'); - $this->fillRichTextField("intro_text", $registerIntro); + $this->click("xpath=//div[@id='registration_screen']/table/tbody/tr[1]/td[2]/div[@class='replace-plain']"); + $this->fillRichTextField("cke_wysiwyg_frame", $registerIntro); // enable confirmation email $this->click('xpath=//fieldset[@id="mail"]/div/table/tbody/tr/td[2]/label[contains(text(), "Yes")]'); diff --git a/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php b/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php index 87addb7b24..28bab7a985 100644 --- a/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php +++ b/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php @@ -109,7 +109,7 @@ class WebTest_Pledge_ContactContextAddTest extends CiviSeleniumTestCase { $this->verifyText("xpath=//form[@id='PledgeView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value)); } - $this->clickLink("_qf_PledgeView_next-bottom", "xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']", FALSE); + $this->clickLink("_qf_PledgeView_next-bottom", "xpath=//form[@class='CRM_Pledge_Form_Search crm-search-form']/div/table/tbody/tr[1]/td[10]/span[1]/a[text()='View']", FALSE); $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a"); $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a"); diff --git a/tests/phpunit/WebTest/Profile/SearchTest.php b/tests/phpunit/WebTest/Profile/SearchTest.php index 14b29f6789..a1a6286953 100644 --- a/tests/phpunit/WebTest/Profile/SearchTest.php +++ b/tests/phpunit/WebTest/Profile/SearchTest.php @@ -86,6 +86,7 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase { $this->waitForElementPresent("field_name[0]"); $this->click('field_name[0]'); $this->select('field_name[0]', 'value=Contact'); + $this->waitForElementPresent('field_name[1]'); $this->click('field_name[1]'); $this->select('field_name[1]', 'value=email'); $this->click("//option[@value='Contact']"); -- 2.25.1