From 9445497e8b82809625ac43cac43c9b1f5b796258 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Fri, 2 May 2014 17:11:57 +0530 Subject: [PATCH] Web Test Fix --- .../Contribute/UpdateContributionTest.php | 80 ++++++++++++------- .../WebTest/Report/LoggingReportTest.php | 71 ++++++++-------- 2 files changed, 82 insertions(+), 69 deletions(-) diff --git a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php index 315c4d24d0..a7609daf00 100644 --- a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php @@ -90,11 +90,13 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $amount = 100.00; //Offline Pay Later Contribution $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending"); - $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); - $this->clickLink("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); - $contId = $this->urlArg('id'); + $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']"); + $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href")); + $contId = explode('&', $contId[1]); + $contId = $contId[0]; + $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE); $this->select("contribution_status_id", "label=Completed"); - $this->clickLink("_qf_Contribution_upload"); + $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE); //Assertions $search = array('id' => $contId); @@ -123,10 +125,13 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { 'is_deductible' => 1, ); $this->addeditFinancialType($financialType); - $this->clickLink("xpath=//a[@id='newfinancialTypeAccount']"); + $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='".$financialType['name']."']/../td[7]/span/a[text()='Accounts']"); + $this->click("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='".$financialType['name']."']/../td[7]/span/a[text()='Accounts']"); + $this->waitForElementPresent("xpath=//a[@id='newfinancialTypeAccount']"); + $this->clickLink("xpath=//a[@id='newfinancialTypeAccount']", "_qf_FinancialTypeAccount_cancel-botttom", FALSE); $this->select("account_relationship", "label=Premiums Inventory Account is"); $this->select("financial_account_id", "label=$to"); - $this->clickLink("_qf_FinancialTypeAccount_next-botttom"); + $this->clickLink("_qf_FinancialTypeAccount_next-botttom", "xpath=//a[@id='newfinancialTypeAccount']", FALSE); $premiumName = 'Premium'.substr(sha1(rand()), 0, 7); $amount = 500; @@ -165,12 +170,14 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { // verify if Membership is created $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']"); //click through to the Contribution edit screen - $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom"); - $contId = $this->urlArg('id'); + $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href")); + $contId = explode('&', $contId[1]); + $contId = $contId[0]; + $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom", FALSE); $this->waitForElementPresent("product_name_0"); $this->select('product_name_0', "label=$premiumName2 ( $sku2 )"); // Clicking save. - $this->clickLink("_qf_Contribution_upload"); + $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']", FALSE); //Assertions $actualAmount = $this->_getPremiumActualCost($contId, $to, $from, $cost2, "'civicrm_contribution'"); @@ -193,11 +200,14 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { 'is_deductible' => 1, ); $this->addeditFinancialType($financialType); - $this->clickLink("xpath=//a[@id='newfinancialTypeAccount']"); + $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='".$financialType['name']."']/../td[7]/span/a[text()='Accounts']"); + $this->click("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='".$financialType['name']."']/../td[7]/span/a[text()='Accounts']"); + $this->waitForElementPresent("xpath=//a[@id='newfinancialTypeAccount']"); + $this->clickLink("xpath=//a[@id='newfinancialTypeAccount']", "_qf_FinancialTypeAccount_cancel-botttom", FALSE); $this->select("account_relationship", "label=Premiums Inventory Account is"); $this->select("financial_account_id", "label=$to"); - $this->clickLink("_qf_FinancialTypeAccount_next-botttom"); + $this->clickLink("_qf_FinancialTypeAccount_next-botttom", "xpath=//a[@id='newfinancialTypeAccount']", FALSE); $premiumName = 'Premium' . substr(sha1(rand()), 0, 7); $amount = 500; $sku = 'SKU'; @@ -227,12 +237,14 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { // verify if Membership is created $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']"); //click through to the Contribution edit screen - $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom"); - $contId = $this->urlArg('id'); + $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href")); + $contId = explode('&', $contId[1]); + $contId = $contId[0]; + $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom", FALSE); $this->waitForElementPresent("product_name_0"); $this->select('product_name_0', "value=0"); // Clicking save. - $this->clickLink("_qf_Contribution_upload"); + $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']", FALSE); //Assertions $actualAmount = $this->_getPremiumActualCost($contId, $from, $to, NULL, "'civicrm_contribution'"); @@ -251,12 +263,14 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $from = array_search('Deposit Bank Account', $financialAccount); $this->addPaymentInstrument($label, $to); $this->_testOfflineContribution($firstName, $lastName, $email, $amount); - $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); - $this->clickLink("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); - $contId = $this->urlArg('id'); + $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']"); + $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE); + $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href")); + $contId = explode('&', $contId[1]); + $contId = $contId[0]; //change payment processor to newly created value $this->select("payment_instrument_id", "label=$label"); - $this->clickLink("_qf_Contribution_upload"); + $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE); //Assertions $totalAmount = $this->_getPremiumActualCost($contId, 'Payment Processor Account', 'Accounts Receivable'); $this->assertEquals($totalAmount, $amount, "Verify amount for newly inserted values"); @@ -270,12 +284,14 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $label = 'TEST'.substr(sha1(rand()), 0, 7); $amount = 100.00; $this->_testOfflineContribution($firstName, $lastName, $email, $amount); - $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); - $this->clickLink("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); + $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']"); + $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE); //Contribution status $this->select("contribution_status_id", "label=Refunded"); - $contId = $this->urlArg('id'); - $this->clickLink("_qf_Contribution_upload"); + $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href")); + $contId = explode('&', $contId[1]); + $contId = $contId[0]; + $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE); //Assertions $lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution')); @@ -297,12 +313,14 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $label = 'TEST'.substr(sha1(rand()), 0, 7); $amount = 100.00; $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending"); - $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); - $this->clickLink("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); + $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']"); + $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE); //Contribution status $this->select("contribution_status_id", "label=Cancelled"); - $contId = $this->urlArg('id'); - $this->clickLink("_qf_Contribution_upload"); + $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href")); + $contId = explode('&', $contId[1]); + $contId = $contId[0]; + $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE); //Assertions $search = array('id' => $contId); @@ -330,12 +348,14 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $label = 'TEST'.substr(sha1(rand()), 0, 7); $amount = 100.00; $this->_testOfflineContribution($firstName, $lastName, $email, $amount); - $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); - $this->clickLink("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); + $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']"); + $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE); //Contribution status $this->select("financial_type_id", "value=3"); - $contId = $this->urlArg('id'); - $this->clickLink("_qf_Contribution_upload"); + $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href")); + $contId = explode('&', $contId[1]); + $contId = $contId[0]; + $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE); //Assertions $search = array( 'id' => $contId ); diff --git a/tests/phpunit/WebTest/Report/LoggingReportTest.php b/tests/phpunit/WebTest/Report/LoggingReportTest.php index 3f853473be..56828c4fec 100644 --- a/tests/phpunit/WebTest/Report/LoggingReportTest.php +++ b/tests/phpunit/WebTest/Report/LoggingReportTest.php @@ -59,15 +59,12 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { // Justification for this instance: FIXME sleep(3); $this->select("group_id", "label=Case Resources"); - $this->clickLink("_qf_GroupContact_next", "xpath=//form[@id='GroupContact']//div[@class='view-content']//div[@class='dataTables_wrapper']/table/tbody/tr/td[4]/a"); - $this->click("xpath=//form[@id='GroupContact']//div[@class='view-content']//div[@class='dataTables_wrapper']/table/tbody/tr/td[4]/a"); + $this->clickLink("_qf_GroupContact_next", "xpath=//form[@id='GroupContact']//div[@class='view-content view-contact-groups']//div[@class='dataTables_wrapper']/table/tbody/tr/td[4]/a", FALSE); + $this->click("xpath=//form[@id='GroupContact']//div[@class='view-content view-contact-groups']//div[@class='dataTables_wrapper']/table/tbody/tr/td[4]/a"); // Check confirmation alert. - $this->assertTrue((bool)preg_match("/^Are you sure you want to remove/", - $this->getConfirmation() - )); - $this->chooseOkOnNextConfirmation(); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForText("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']", "Remove $firstName $lastName from Case Resources?"); + $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Continue']"); //tag addition $this->waitForElementPresent("xpath=//li[@id='tab_tag']/a"); @@ -90,7 +87,7 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { // Sleep should never be used for wait for anything to load from the server // Justification for this instance: FIXME sleep(3); - $this->click("xpath=//div[@id='Notes']//div[@class='action-link']/a"); + $this->click("xpath=//div[@class='view-content']//div[@class='action-link']/a"); $this->waitForElementPresent("_qf_Note_upload-top"); $noteSubject = "test note" . substr(sha1(rand()), 0, 7); @@ -104,16 +101,13 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { $this->waitForElementPresent("_qf_Note_upload-top"); $this->type('subject', $noteSubject . "_edited"); $this->type('note', $noteText . "_edited"); - $this->clickLink("_qf_Note_upload-top", "xpath=//div[@class='crm-results-block']/div[@id='notes']/div/table/tbody/tr//td/span[2]/ul/li[2]/a[text()='Delete']"); + $this->clickLink("_qf_Note_upload-top", "xpath=//div[@class='crm-results-block']/div[@id='notes']/div/table/tbody/tr//td/span[2]/ul/li[2]/a[text()='Delete']", FALSE); $this->click("xpath=//div[@class='crm-results-block']/div[@id='notes']/div/table/tbody/tr//td/span[2]/ul/li[2]/a[text()='Delete']"); // Check confirmation alert. - $this->assertTrue((bool)preg_match("/^Are you sure you want to delete this note/", - $this->getConfirmation() - )); - $this->chooseOkOnNextConfirmation(); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForText('crm-notification-container', "deleted successfully"); + $this->waitForText("xpath=//form[@id='Note']/div[@class='view-content']/fieldset/div[@class='status']", "Are you sure you want to delete the note ''?"); + $this->click("xpath=//input[@id='_qf_Note_next']"); + $this->waitForText('crm-notification-container', "Selected Note has been deleted successfully."); //add new relationship , disable it , delete it $this->waitForElementPresent("xpath=//li[@id='tab_rel']/a"); @@ -122,22 +116,17 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { $this->click("link=Add Relationship"); $this->waitForElementPresent("_qf_Relationship_cancel"); $this->select("relationship_type_id", "label=Employee of"); - $this->webtestFillAutocomplete("Default"); - $this->waitForElementPresent("quick-save"); - $this->clickLink("quick-save", "xpath=//div[@id='current-relationships']//a[text()='Disable']"); - $this->click("xpath=//div[@id='current-relationships']//a[text()='Disable']"); - $this->assertTrue((bool)preg_match("/^Are you sure you want to disable this relationship/", - $this->getConfirmation() - )); - $this->chooseOkOnNextConfirmation(); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent(" xpath=//div[@id='inactive-relationships']//a[text()='Delete']"); - $this->click("xpath=//div[@id='inactive-relationships']//a[text()='Delete']"); - $this->assertTrue((bool)preg_match("/^Are you sure you want to delete this relationship/", - $this->getConfirmation() - )); - $this->chooseOkOnNextConfirmation(); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->select2('related_contact_id', 'Default', TRUE); + $this->click('_qf_Relationship_upload-bottom'); + $this->waitForElementPresent("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']"); + $this->click("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']"); + $this->waitForText("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']", 'Are you sure you want to disable this record?'); + $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Disable']"); + $this->waitForElementPresent("xpath=//div[@id='crm-contact-relationship-selector-past_wrapper']//table/tbody//tr/td[9]/span[2][text()='more']/ul/li[2]/a[text()='Delete']"); + $this->click("xpath=//div[@id='crm-contact-relationship-selector-past_wrapper']//table/tbody//tr/td[9]/span[2][text()='more']/ul/li[2]/a[text()='Delete']"); + $this->waitForText("xpath=//form[@id='Relationship']/div[@class='status']", "Are you sure you want to delete this Relationship?"); + $this->click("_qf_Relationship_next-bottom"); + $this->waitForElementPresent("link=Add Relationship"); //update existing contact $this->click("xpath=//ul[@id='actions']/li[2]/a"); @@ -151,29 +140,33 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { $this->click("xpath=//li[@id='tab_activity']/a"); $this->waitForElementPresent("other_activity"); $this->select("other_activity", "label=Interview"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("_qf_Activity_cancel-bottom"); $this->click('_qf_Activity_upload-bottom'); $this->waitForElementPresent("xpath=//table[@id='contact-activity-selector-activity']/tbody/tr/td[8]/span/a[2]"); - sleep(10); $this->click("xpath=//table[@id='contact-activity-selector-activity']/tbody/tr/td[8]/span/a[2]"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("_qf_Activity_cancel-bottom"); $this->select("status_id","value=2"); $this->click('_qf_Activity_upload-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForText("crm-notification-container", "Activity has been saved."); + $this->waitForElementPresent("xpath=//table[@id='contact-activity-selector-activity']/tbody/tr/td[7][text()='Completed']"); //add a case $this->click("xpath=//li[@id='tab_case']/a"); - $this->waitForElementPresent("xpath=//div[@id='Cases']//div[@class='action-link']/a"); - $this->click("xpath=//div[@id='Cases']//div[@class='action-link']/a"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("xpath=//div[@class='view-content']//div[@class='action-link']/a"); + $this->click("xpath=//div[@class='view-content']//div[@class='action-link']/a"); + $this->waitForElementPresent("_qf_Case_cancel-bottom"); $this->type('activity_subject',"subject".rand()); $this->select('case_type_id','value=1'); $this->click('_qf_Case_upload-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("xpath=//div[@class='view-content']/table[@class='caseSelector']/tbody/tr[2]/td[9]//span//a[text()='Manage']"); + $this->click("xpath=//div[@class='view-content']/table[@class='caseSelector']/tbody/tr[2]/td[9]//span//a[text()='Manage']"); + $this->waitForElementPresent("xpath=//form[@id='CaseView']/div[2]/table/tbody/tr/td[4]/a"); $this->click("xpath=//form[@id='CaseView']/div[2]/table/tbody/tr/td[4]/a"); $this->waitForElementPresent("_qf_Activity_cancel-bottom"); $this->select("case_status_id","value=2"); $this->click("_qf_Activity_upload-top"); + $this->waitForElementPresent("_qf_CaseView_cancel-bottom"); + $this->click("_qf_CaseView_cancel-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); //visit the logging contact summary report -- 2.25.1