From 6cbe4dc37a61aa522e54572b92a3103e116d82d7 Mon Sep 17 00:00:00 2001 From: Atif Shaikh Date: Mon, 28 Apr 2014 19:51:54 +0530 Subject: [PATCH] WebtestFix related to FinancialType and Address Import --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 10 ++--- .../Financial/FinancialAccountTest.php | 19 +++++---- .../Financial/FinancialAccountTypeTest.php | 17 +++++--- .../WebTest/Import/AddressImportTest.php | 41 +++++++++++-------- 4 files changed, 51 insertions(+), 36 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index ec2e16bbb0..44cda181bf 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -1531,7 +1531,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$editfinancialAccount}']/../td[9]/span/a[text()='Edit']"); - $this->clickLink("xpath=//table/tbody//tr/td[1][text()='{$editfinancialAccount}']/../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom'); + $this->clickLink("xpath=//table/tbody//tr/td[1][text()='{$editfinancialAccount}']/../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE); // Change Financial Account Name if ($financialAccountTitle) { @@ -1595,7 +1595,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->uncheck('is_active'); } $this->click('_qf_FinancialAccount_next-botttom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('link=Add Financial Account'); } /** @@ -1606,7 +1606,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->waitForElementPresent('_qf_FinancialAccount_next-botttom'); $this->click('_qf_FinancialAccount_next-botttom'); $this->waitForElementPresent('link=Add Financial Account'); - $this->assertTrue($this->isTextPresent("Selected Financial Account has been deleted.")); + $this->waitForText('crm-notification-container', "Selected Financial Account has been deleted."); } /** @@ -1640,8 +1640,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[7]/span[2]/ul/li[2]/a"); $this->waitForElementPresent("_qf_FinancialType_next"); $this->click("_qf_FinancialType_next"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertTrue($this->isTextPresent('Selected financial type has been deleted.'), 'Missing text: ' . 'Selected financial type has been deleted.'); + $this->waitForElementPresent("newFinancialType"); + $this->waitForText('crm-notification-container', 'Selected financial type has been deleted.'); return; } if ($option == 'new') { diff --git a/tests/phpunit/WebTest/Financial/FinancialAccountTest.php b/tests/phpunit/WebTest/Financial/FinancialAccountTest.php index 0eed4edfa2..d8f14719f8 100644 --- a/tests/phpunit/WebTest/Financial/FinancialAccountTest.php +++ b/tests/phpunit/WebTest/Financial/FinancialAccountTest.php @@ -36,6 +36,7 @@ class WebTest_Financial_FinancialAccountTest extends CiviSeleniumTestCase { // Add new Financial Account $orgName = 'Alberta '.substr(sha1(rand()), 0, 7); + $uniqueName = explode(" ",$orgName); $financialAccountTitle = 'Financial Account '.substr(sha1(rand()), 0, 4); $financialAccountDescription = "{$financialAccountTitle} Description"; $accountingCode = 1033; @@ -54,7 +55,7 @@ class WebTest_Financial_FinancialAccountTest extends CiviSeleniumTestCase { $this->_testAddFinancialAccount($financialAccountTitle, $financialAccountDescription, $accountingCode, - $orgName, + $uniqueName[1], $financialAccountType, $taxDeductible, $isActive, @@ -65,17 +66,18 @@ class WebTest_Financial_FinancialAccountTest extends CiviSeleniumTestCase { $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']"); - $this->clickLink("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom'); + $this->clickLink("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE); //Varify Data after Adding new Financial Account $verifyData = array('name' => $financialAccountTitle, 'description' => $financialAccountDescription, 'accounting_code' => $accountingCode, - 'contact_name' => $orgName, 'tax_rate' => $taxRate, 'is_tax' => 'on', 'is_deductible' => 'off', 'is_default' => 'off' ); + + $this->assertEquals($orgName, $this->getText("xpath=//*[@id='s2id_contact_id']/a/span[1]")); $this->_assertFinancialAccount($verifyData); $verifySelectFieldData = array('financial_account_type_id' => $financialAccountType); @@ -91,13 +93,14 @@ class WebTest_Financial_FinancialAccountTest extends CiviSeleniumTestCase { if ($orgNameEdit) { $orgNameEdit = 'NGO '.substr(sha1(rand()), 0, 7); $this->webtestAddOrganization($orgNameEdit); + $uniqueName = explode(" ",$orgNameEdit); } $this->_testEditFinancialAccount($editfinancialAccount, $financialAccountTitle, $financialAccountDescription, $accountingCode, - $orgNameEdit, + $uniqueName[1], $financialAccountType, $taxDeductible, $isActive, @@ -110,19 +113,21 @@ class WebTest_Financial_FinancialAccountTest extends CiviSeleniumTestCase { $orgName = $orgNameEdit; } $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']"); - $this->clickLink("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom'); + $this->clickLink("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE); $verifyData = array( 'name' => $financialAccountTitle, 'description' => $financialAccountDescription, 'accounting_code' => $accountingCode, - 'contact_name' => $orgName, 'tax_rate' => $taxRate, 'is_tax' => 'on', 'is_deductible' => 'off', 'is_default' => 'off', ); - $verifySelectFieldData = array('financial_account_type_id' => $financialAccountType); + + $this->assertEquals($orgName, $this->getText("xpath=//*[@id='s2id_contact_id']/a/span[1]")); + $this->_assertFinancialAccount($verifyData); + $verifySelectFieldData = array('financial_account_type_id' => $financialAccountType); $this->_assertSelectVerify($verifySelectFieldData); $this->click('_qf_FinancialAccount_cancel-botttom'); $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Delete']"); diff --git a/tests/phpunit/WebTest/Financial/FinancialAccountTypeTest.php b/tests/phpunit/WebTest/Financial/FinancialAccountTypeTest.php index 2b7d917514..b4c5c2dec7 100644 --- a/tests/phpunit/WebTest/Financial/FinancialAccountTypeTest.php +++ b/tests/phpunit/WebTest/Financial/FinancialAccountTypeTest.php @@ -61,14 +61,19 @@ class WebTest_Financial_FinancialAccountTypeTest extends CiviSeleniumTestCase { ), ); + $this->waitForElementPresent('newFinancialType'); + $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[7]/span/a[text()='Accounts']"); + $this->waitForElementPresent('newfinancialTypeAccount'); + foreach ($expected as $value => $label) { - $this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='$label[financial_account]']/../td[1]", preg_quote($label['account_relationship'])); + $this->verifyText("xpath=//div[@id='ltype']/div/table/tbody/tr/td[2][text()='$label[financial_account]']/../td[1]", preg_quote($label['account_relationship'])); } + $this->openCiviPage('admin/financial/financialType', 'reset=1', 'newFinancialType'); $this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[3]", 'Accounts Receivable,Banking Fees,Premiums,' . $financialType['name']); $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[7]/span/a[text()='Accounts']"); $this->waitForElementPresent('newfinancialTypeAccount'); - $this->click("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Banking Fees']/../td[7]/span/a[text()='Edit']"); + $this->click("xpath=//div[@id='ltype']/div/table/tbody/tr/td[2][text()='Banking Fees']/../td[7]/span/a[text()='Edit']"); $this->waitForElementPresent('_qf_FinancialTypeAccount_next'); $this->select('account_relationship', "value=select"); // Because it tends to cause problems, all uses of sleep() must be justified in comments @@ -78,11 +83,11 @@ class WebTest_Financial_FinancialAccountTypeTest extends CiviSeleniumTestCase { $this->select('account_relationship', "label=Premiums Inventory Account is"); $this->select('financial_account_id', "label=Premiums inventory"); $this->click('_qf_FinancialTypeAccount_next'); - $this->waitForElementPresent("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[7]/span/a[text()='Edit']"); - $this->verifyText("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[1]", preg_quote('Premiums Inventory Account is')); - $this->clickLink("xpath=id('ltype')/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[7]/span/a[text()='Delete']", '_qf_FinancialTypeAccount_next-botttom'); + $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[7]/span/a[text()='Edit']"); + $this->verifyText("xpath=//div[@id='ltype']/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[1]", preg_quote('Premiums Inventory Account is')); + $this->clickLink("xpath=//div[@id='ltype']/div/table/tbody/tr/td[2][text()='Premiums inventory']/../td[7]/span/a[text()='Delete']", '_qf_FinancialTypeAccount_next-botttom', FALSE); $this->click('_qf_FinancialTypeAccount_next-botttom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("newfinancialTypeAccount"); $this->waitForText('crm-notification-container', 'Selected financial type account has been deleted.'); //edit financial type diff --git a/tests/phpunit/WebTest/Import/AddressImportTest.php b/tests/phpunit/WebTest/Import/AddressImportTest.php index f658b084cf..5904fa3b8c 100644 --- a/tests/phpunit/WebTest/Import/AddressImportTest.php +++ b/tests/phpunit/WebTest/Import/AddressImportTest.php @@ -49,10 +49,10 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { $this->typeKeys('css=input#sort_name_navigation', $firstName1); // Wait for result list. - $this->waitForElementPresent("css=div.ac_results-inner li"); + $this->waitForElementPresent("css=ul.ui-autocomplete li"); // Visit contact summary page. - $this->click("css=div.ac_results-inner li"); + $this->click("css=ul.ui-autocomplete li"); $this->waitForPageToLoad($this->getTimeoutMsec()); foreach($customDataParams['customFields'] as $key => $value){ @@ -129,13 +129,13 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { $this->click('_qf_Field_next-bottom'); $this->waitForElementPresent('newCustomField'); - $this->waitForText('crm-notification-container',"Your custom field '{$customField}' has been saved."); + $this->waitForText('crm-notification-container',"Custom field '{$customField}' has been saved."); $customFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField']/../../td[8]/span/a@href")); $customFieldId = $customFieldId[1]; // create custom field - Integer $this->click("newCustomField"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_Field_next-bottom'); $customField1 = 'Customfield_int ' . substr(sha1(rand()), 0, 4); $this->type('label', $customField1); $this->select("data_type[0]","value=1"); @@ -143,13 +143,14 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { // clicking save $this->click('_qf_Field_next-bottom'); $this->waitForElementPresent('newCustomField'); - $this->waitForText('crm-notification-container', "Your custom field '{$customField1}' has been saved."); + $this->waitForText('crm-notification-container', "Custom field '{$customField1}' has been saved."); + $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField1']"); $customFieldId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField1']/../../td[8]/span/a@href")); $customFieldId1 = $customFieldId1[1]; // create custom field - Number $this->click("newCustomField"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_Field_next-bottom'); $customField2 = 'Customfield_Number ' . substr(sha1(rand()), 0, 4); $this->type('label', $customField2); $this->select("data_type[0]","value=2"); @@ -157,49 +158,50 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { // clicking save $this->click('_qf_Field_next-bottom'); $this->waitForElementPresent('newCustomField'); - $this->waitForText('crm-notification-container', "Your custom field '{$customField2}' has been saved."); + $this->waitForText('crm-notification-container', "Custom field '{$customField2}' has been saved."); + $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField2']"); $customFieldId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField2']/../../td[8]/span/a@href")); $customFieldId2 = $customFieldId2[1]; // create custom field - "alphanumeric select" $this->click("newCustomField"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_Field_next-bottom'); $customField3 = 'Customfield_alp_select' . substr(sha1(rand()), 0, 4); $customFieldId3 = $this->_createMultipleValueCustomField($customField3,'Select'); // create custom field - "alphanumeric radio" $this->click("newCustomField"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_Field_next-bottom'); $customField4 = 'Customfield_alp_radio' . substr(sha1(rand()), 0, 4); $customFieldId4 = $this->_createMultipleValueCustomField($customField4,'Radio'); // create custom field - "alphanumeric checkbox" $this->click("newCustomField"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_Field_next-bottom'); $customField5 = 'Customfield_alp_checkbox' . substr(sha1(rand()), 0, 4); $customFieldId5 = $this->_createMultipleValueCustomField($customField5,'CheckBox'); // create custom field - "alphanumeric multiselect" $this->click("newCustomField"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_Field_next-bottom'); $customField6 = 'Customfield_alp_multiselect' . substr(sha1(rand()), 0, 4); $customFieldId6 = $this->_createMultipleValueCustomField($customField6,'Multi-Select'); // create custom field - "alphanumeric advmultiselect" $this->click("newCustomField"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_Field_next-bottom'); $customField7 = 'Customfield_alp_advmultiselect' . substr(sha1(rand()), 0, 4); $customFieldId7 = $this->_createMultipleValueCustomField($customField7,'AdvMulti-Select'); // create custom field - "alphanumeric autocompleteselect" $this->click("newCustomField"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_Field_next-bottom'); $customField8 = 'Customfield_alp_autocompleteselect' . substr(sha1(rand()), 0, 4); $customFieldId8 = $this->_createMultipleValueCustomField($customField8,'Autocomplete-Select'); // create custom field - Money $this->click("newCustomField"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_Field_next-bottom'); $customField9 = 'Customfield_Money' . substr(sha1(rand()), 0, 4); $this->type('label', $customField9); $this->select("data_type[0]","value=3"); @@ -207,13 +209,14 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { // clicking save $this->click('_qf_Field_next-bottom'); $this->waitForElementPresent('newCustomField'); - $this->waitForText('crm-notification-container', "Your custom field '{$customField9}' has been saved."); + $this->waitForText('crm-notification-container', "Custom field '{$customField9}' has been saved."); + $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField9']"); $customFieldId9 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField9']/../../td[8]/span/a@href")); $customFieldId9 = $customFieldId9[1]; // create custom field - Date $this->click("newCustomField"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_Field_next-bottom'); $customField10 = 'Customfield_Date' . substr(sha1(rand()), 0, 4); $this->type('label', $customField10); $this->select("data_type[0]","value=5"); @@ -222,7 +225,8 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { // clicking save $this->click('_qf_Field_next-bottom'); $this->waitForElementPresent('newCustomField'); - $this->waitForText('crm-notification-container', "Your custom field '{$customField10}' has been saved."); + $this->waitForText('crm-notification-container', "Custom field '{$customField10}' has been saved."); + $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField10']"); $customFieldId10 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField10']/../../td[8]/span/a@href")); $customFieldId10 = $customFieldId10[1]; @@ -282,7 +286,8 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { // clicking save $this->click('_qf_Field_next-bottom'); $this->waitForElementPresent('newCustomField'); - $this->waitForText('crm-notification-container', "Your custom field '{$customFieldName}' has been saved."); + $this->waitForText('crm-notification-container', "Custom field '{$customFieldName}' has been saved."); + $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customFieldName']"); $customFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customFieldName']/../../td[8]/span/a@href")); $customFieldId = $customFieldId[1]; return $customFieldId; -- 2.25.1