Web Test Fix
authorjitendrapurohit <jitendra.purohit@webaccess.co.in>
Tue, 15 Apr 2014 14:46:00 +0000 (20:16 +0530)
committerjitendrapurohit <jitendra.purohit@webaccess.co.in>
Tue, 15 Apr 2014 14:46:00 +0000 (20:16 +0530)
tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/Contribute/UpdateContributionTest.php
tests/phpunit/WebTest/Member/ContactContextAddTest.php
tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php

index f0528d8682bdbdd8c170308c42a15fede4ece90d..1f815b69b19012288758135fee80e685a20b34dd 100644 (file)
@@ -1172,7 +1172,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     $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);
index 0050ec8eeb48953e626922aaeb67f0b9fa0e8c71..315c4d24d0d502ab7eb624b676c6e249fa131dcc 100644 (file)
@@ -44,14 +44,15 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
 
    $this->type("sort_name", "$lastName, $firstName");
-   $this->clickLink("_qf_Search_refresh");
+   $this->click("_qf_Search_refresh");
 
-   $contriIDOff = explode('&', $this->getAttribute("xpath=//div[@id='contributionSearch']/table/tbody/tr[1]/td[11]/span/a@href"));
+   $this->waitForElementPresent("xpath=//div[@class='crm-content-block']//div[@id='contributionSearch']");
+   $contriIDOff = explode('&', $this->getAttribute("xpath=//div[@id='contributionSearch']//table[@class='selector row-highlight']/tbody/tr[1]/td[11]/span/a[1]@href"));
    if (!empty($contriIDOff)) {
      $contriIDOff = substr($contriIDOff[1], (strrpos($contriIDOff[1], '=') + 1));
    }
 
-   $this->clickLink("xpath=//tr[@id='rowid{$contriIDOff}']/td[11]/span/a[2]", "total_amount");
+   $this->clickLink("xpath=//tr[@id='rowid{$contriIDOff}']/td[11]/span/a[2]", "total_amount", FALSE);
    $this->type("total_amount", "90");
    $this->clickLink('_qf_Contribution_upload');
 
@@ -89,7 +90,8 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $amount = 100.00;
    //Offline Pay Later Contribution
    $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending");
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $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->select("contribution_status_id", "label=Completed");
    $this->clickLink("_qf_Contribution_upload");
@@ -161,9 +163,9 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    // Is status message correct?
    $this->waitForText('crm-notification-container', "The contribution record has been saved.");
    // verify if Membership is created
-   $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
+   $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[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom");
+   $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');
    $this->waitForElementPresent("product_name_0");
    $this->select('product_name_0', "label=$premiumName2 ( $sku2 )");
@@ -223,9 +225,9 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    // Is status message correct?
    $this->waitForText('crm-notification-container', "The contribution record has been saved.");
    // verify if Membership is created
-   $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
+   $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[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom");
+   $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');
    $this->waitForElementPresent("product_name_0");
    $this->select('product_name_0', "value=0");
@@ -249,7 +251,8 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $from = array_search('Deposit Bank Account', $financialAccount);
    $this->addPaymentInstrument($label, $to);
    $this->_testOfflineContribution($firstName, $lastName, $email, $amount);
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $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');
    //change payment processor to newly created value
    $this->select("payment_instrument_id", "label=$label");
@@ -267,7 +270,8 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $label = 'TEST'.substr(sha1(rand()), 0, 7);
    $amount = 100.00;
    $this->_testOfflineContribution($firstName, $lastName, $email, $amount);
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $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']");
    //Contribution status
    $this->select("contribution_status_id", "label=Refunded");
    $contId = $this->urlArg('id');
@@ -293,7 +297,8 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $label = 'TEST'.substr(sha1(rand()), 0, 7);
    $amount = 100.00;
    $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending");
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $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']");
    //Contribution status
    $this->select("contribution_status_id", "label=Cancelled");
    $contId = $this->urlArg('id');
@@ -325,7 +330,8 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $label = 'TEST'.substr(sha1(rand()), 0, 7);
    $amount = 100.00;
    $this->_testOfflineContribution($firstName, $lastName, $email, $amount);
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $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']");
    //Contribution status
    $this->select("financial_type_id", "value=3");
    $contId = $this->urlArg('id');
@@ -446,11 +452,11 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    // Is status message correct?
    $this->waitForText('crm-notification-container', "The contribution record has been saved.");
 
+   $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
    // verify if Membership is created
-   $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
 
    //click through to the Membership view screen
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
+   $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
 
    $expected = array(
      'Financial Type' => 'Donation',
@@ -458,11 +464,7 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
      'Contribution Status' => $status,
    );
    $this->webtestVerifyTabularData($expected);
-   $this->clickLink("_qf_ContributionView_cancel-top");
-   // Because it tends to cause problems, all uses of sleep() must be justified in comments
-   // Sleep should never be used for wait for anything to load from the server
-   // Justification for this instance: FIXME
-   sleep(4);
+   $this->click("_qf_ContributionView_cancel-bottom");
  }
 }
 
index 230ecea557d013dc50d67a554b7650de738a1661..dcde571a60c7464d313568375f3f9cf086fbd5d0 100644 (file)
@@ -137,7 +137,7 @@ class WebTest_Member_ContactContextAddTest extends CiviSeleniumTestCase {
     $this->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}");
 
     $this->waitForElementPresent("xpath=//form[@id='Membership']/div[2]/div[2]//table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]");
-    $this->click("xpath=//form[@id='Membership']/div[2]/div[2]//table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]/span/a[text()='clear']");
+    $this->click("xpath=//form[@id='Membership']/div[2]/div[2]//table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]/a[@title='Clear']");
 
     $this->click("_qf_Membership_upload-bottom");
     $this->waitForPageToLoad($this->getTimeoutMsec());
@@ -230,7 +230,7 @@ class WebTest_Member_ContactContextAddTest extends CiviSeleniumTestCase {
     );
     $this->webtestVerifyTabularData($verifyData);
     $this->click("_qf_MembershipView_cancel-bottom");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->waitForElementPresent("mainTabContainer");
   }
 }
 
index 028367b010a009aac5db37e9363e42b79ec4b0b6..5e84b63ac500285c74b555482896e52ac7d1dd44 100755 (executable)
@@ -159,7 +159,7 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase
     elseif ($usedFor == 'Membership') {
       $this->click('extends[3]');
       $this->waitForElementPresent( 'financial_type_id' );
-      $this->select("css=select.form-select", "label={$contributionType}");
+      $this->select("css=select.crm-form-select", "label={$contributionType}");
     }
 
     $this->type('help_pre', $setHelp);
@@ -184,17 +184,17 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase
     elseif (!$defaultPriceSet) {
       $memTypeParams1 = $this->webtestAddMembershipType();
       $memTypeTitle1  = $memTypeParams1['membership_type'];
-      $memTypeId1     = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href"));
+      $memTypeId1     = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[1]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href"));
       $memTypeId1     = $memTypeId1[1];
 
       $memTypeParams2 = $this->webtestAddMembershipType();
       $memTypeTitle2  = $memTypeParams2['membership_type'];
-      $memTypeId2     = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[12]/span/a[3]@href"));
+      $memTypeId2     = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[1]/table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[12]/span/a[3]@href"));
       $memTypeId2     = $memTypeId2[1];
 
       $memTypeParams3 = $this->webtestAddMembershipType();
       $memTypeTitle3  = $memTypeParams3['membership_type'];
-      $memTypeId3     = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle3}']/../td[12]/span/a[3]@href"));
+      $memTypeId3     = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[1]/table/tbody//tr/td[text()='{$memTypeTitle3}']/../td[12]/span/a[3]@href"));
       $memTypeId3     = $memTypeId3[1];
     }