Refactor webtestNewDialogContact and other webtest cleanup
[civicrm-core.git] / tests / phpunit / WebTest / Pledge / StandaloneAddTest.php
index 24a8883dc60a734e0117e0187c206a16fb8bb98f..68bad2f335ba30d80d53f78ce04036b75f29fe18 100644 (file)
 */
 
 require_once 'CiviTest/CiviSeleniumTestCase.php';
+
+/**
+ * Class WebTest_Pledge_StandaloneAddTest
+ */
 class WebTest_Pledge_StandaloneAddTest extends CiviSeleniumTestCase {
 
   protected function setUp() {
@@ -37,9 +41,7 @@ class WebTest_Pledge_StandaloneAddTest extends CiviSeleniumTestCase {
     $this->openCiviPage('pledge/add', 'reset=1&context=standalone', '_qf_Pledge_upload');
 
     // create new contact using dialog
-    $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
-    $lastName = 'An' . substr(sha1(rand()), 0, 7);
-    $this->webtestNewDialogContact($firstName, $lastName, $firstName . '@example.com');
+    $contact = $this->createDialogContact();
 
     $this->type('amount', '100');
     $this->type('installments', '10');
@@ -71,7 +73,7 @@ class WebTest_Pledge_StandaloneAddTest extends CiviSeleniumTestCase {
     $pledgeDate = date('F jS, Y', strtotime('now'));
 
     $this->webtestVerifyTabularData(array(
-        'Pledge By' => $firstName . ' ' . $lastName,
+        'Pledge By' => $contact['display_name'],
         'Total Pledge Amount' => '$ 100.00',
         'To be paid in' => '10 installments of $ 10.00 every 1 week(s)',
         'Payments are due on the' => '2 day of the period',
@@ -83,9 +85,12 @@ class WebTest_Pledge_StandaloneAddTest extends CiviSeleniumTestCase {
         'Send additional reminders' => '4 days after the last one sent',
       )
     );
-    $this->clickLink('_qf_PledgeView_next-bottom', "xpath=//div[@class='view-content']//table//tbody/tr[1]/td[10]/span/a[text()='View']", FALSE);
+    $this->clickLink('_qf_PledgeView_next-bottom', "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a", FALSE);
+    $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a");
+    $this->waitForAjaxContent();
     $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span/a");
-    $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[2]/td[2]/table/tbody/tr[2]/td[8]/a[text()='Record Payment (Check, Cash, EFT ...)']");
+    $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[1]/span[2]/a");
+    $this->waitForElementPresent("xpath=//div[@class='view-content']//table//tbody/tr[2]/td[2]/table/tbody/tr[2]/td[8]/a[text()='Record Payment']");
   }
 }