From 44a0d8ead878ba88dec7429ff5b38759a1241a18 Mon Sep 17 00:00:00 2001 From: Atif Shaikh Date: Mon, 5 May 2014 20:17:18 +0530 Subject: [PATCH] WebTestFix --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 25 +++++-------------- .../WebTest/Event/AdditionalPaymentTest.php | 18 +++++++------ .../WebTest/Generic/CheckDashboardTest.php | 4 +-- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 44cda181bf..2993dd9048 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -1275,25 +1275,12 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->select("other_activity", "label=Meeting"); $this->waitForElementPresent("_qf_Activity_upload-bottom"); + $this->waitForElementPresent("s2id_target_contact_id"); $this->assertTrue($this->isTextPresent("Anderson, " . $firstName2), "Contact not found in line " . __LINE__); // Typing contact's name into the field (using typeKeys(), not type()!)... - $this->click("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id"); - $this->type("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id", $firstName1); - $this->typeKeys("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id", $firstName1); - - // ...waiting for drop down with results to show up... - $this->waitForElementPresent("css=div.token-input-dropdown-facebook"); - $this->waitForElementPresent("css=li.token-input-input-token-facebook"); - - //.need to use mouseDown on first result (which is a li element), click does not work - // Note that if you are using firebug this appears at the bottom of the html source, before the closing tag, not where the
  • referred to above is, which is a different
  • . - $this->waitForElementPresent("css=div.token-input-dropdown-facebook li"); - $this->mouseDown("css=div.token-input-dropdown-facebook li"); - - // ...again, waiting for the box with contact name to show up... - $this->waitForElementPresent("css=tr.crm-activity-form-block-assignee_contact_id td ul li span.token-input-delete-token-facebook"); + $this->select2("assignee_contact_id", $firstName1, TRUE); // ...and verifying if the page contains properly formatted display name for chosen contact. $this->assertTrue($this->isTextPresent("Summerson, " . $firstName1), "Contact not found in line " . __LINE__); @@ -1326,15 +1313,15 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { // Clicking save. $this->click("_qf_Activity_upload-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("xpath=//div[@id='crm-notification-container']"); // Is status message correct? - $this->assertTrue($this->isTextPresent("Activity '$subject' has been saved."), "Status message didn't show up after saving!"); + $this->waitForText('crm-notification-container', "Activity '$subject' has been saved."); - $this->waitForElementPresent("xpath=//div[@id='Activities']//table/tbody/tr[2]/td[8]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='contact-activity-selector-activity_wrapper']//table/tbody/tr[2]/td[8]/span/a[text()='View']"); // click through to the Activity view screen - $this->click("xpath=//div[@id='Activities']//table/tbody/tr[2]/td[8]/span/a[text()='View']"); + $this->click("xpath=//div[@id='contact-activity-selector-activity_wrapper']//table/tbody/tr[2]/td[8]/span/a[text()='View']"); $this->waitForElementPresent('_qf_Activity_cancel-bottom'); // parse URL to grab the activity id diff --git a/tests/phpunit/WebTest/Event/AdditionalPaymentTest.php b/tests/phpunit/WebTest/Event/AdditionalPaymentTest.php index b028676b15..efaf0d854b 100644 --- a/tests/phpunit/WebTest/Event/AdditionalPaymentTest.php +++ b/tests/phpunit/WebTest/Event/AdditionalPaymentTest.php @@ -49,7 +49,8 @@ class WebTest_Event_AdditionalPaymentTest extends CiviSeleniumTestCase { $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament"); // Select role - $this->click('role_id[2]'); + //$this->click('role_id[2]'); + $this->select('role_id', "value=2"); // Choose Registration Date. // Using helper webtestFillDate function. @@ -114,7 +115,7 @@ class WebTest_Event_AdditionalPaymentTest extends CiviSeleniumTestCase { $this->webtestVerifyTabularData( array( 'Event' => 'Rain-forest Cup Youth Soccer Tournament', - 'Participant Role' => 'Attendee', + 'Participant Role' => 'Volunteer', 'Status' => 'Partially paid', 'Event Source' => 'Event Partially Paid Webtest', ) @@ -145,11 +146,12 @@ class WebTest_Event_AdditionalPaymentTest extends CiviSeleniumTestCase { $this->assertElementPresent("xpath=id('Search')/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span[2]/ul/li[2]/a[text()='Record Payment']"); $this->click("xpath=id('Search')/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']"); $this->waitForElementPresent("xpath=id('ParticipantView')"); + //$this->assertElementPresent("xpath=id('ParticipantView')//td[@id='payment-info']//a/span[contains(text(), 'Record Payment')]"); $this->assertElementPresent("xpath=id('ParticipantView')//td[@id='payment-info']/a/span[contains(text(), 'Record Payment')]"); $this->click("xpath=id('ParticipantView')//div[@class='action-link']/div/a/span[contains(text(), 'Edit')]"); $this->waitForElementPresent("xpath=id('Participant')"); - $this->assertElementPresent("xpath=id('Participant')//td[@id='payment-info']/a/span[contains(text(), 'Record Payment')]"); + $this->assertElementPresent("xpath=id('Participant')//td[@id='payment-info']//a/span[contains(text(), 'Record Payment')]"); $location = $this->getAttribute("xpath=id('Participant')//td[@id='payment-info']/a/span[contains(text(), 'Record Payment')]/../@href"); $this->open($location); @@ -157,9 +159,9 @@ class WebTest_Event_AdditionalPaymentTest extends CiviSeleniumTestCase { $this->assertElementContainsText("xpath=id('AdditionalPayment')/h3", 'New Event Payment'); // input data - $this->select('financial_type_id', 'label=Donation'); + //$this->select('financial_type_id', 'label=Donation'); // verify balance - $text = $this->getText("xpath=id('AdditionalPayment')/div[2]/table/tbody/tr[4]/td[2]"); + $text = $this->getText("xpath=id('AdditionalPayment')/div[2]//table/tbody/tr[3]/td[2]"); $this->assertTrue((bool)preg_match("/{$balance}/", $text)); // check form rule error @@ -179,7 +181,7 @@ class WebTest_Event_AdditionalPaymentTest extends CiviSeleniumTestCase { $this->webtestVerifyTabularData( array( 'Event' => 'Rain-forest Cup Youth Soccer Tournament', - 'Participant Role' => 'Attendee', + 'Participant Role' => 'Volunteer', 'Status' => 'Registered', 'Event Source' => 'Event Partially Paid Webtest', ) @@ -188,7 +190,7 @@ class WebTest_Event_AdditionalPaymentTest extends CiviSeleniumTestCase { $this->_checkPaymentInfoTable(800.00, 800.00); // check for not apprence of record payment button - $this->assertFalse($this->isElementPresent("xpath=id('ParticipantView')//td[@id='payment-info']/a/span[contains(text(), 'Record Payment')]")); + $this->assertFalse($this->isElementPresent("xpath=id('ParticipantView')//td[@id='payment-info']//a/span[contains(text(), 'Record Payment')]")); $this->click("xpath=id('ParticipantView')/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']"); $this->waitForElementPresent('_qf_ContributionView_cancel-bottom'); @@ -217,4 +219,4 @@ class WebTest_Event_AdditionalPaymentTest extends CiviSeleniumTestCase { $this->assertElementContainsText("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td", "$ {$feeAmt}", 'Missing text: appropriate fee amount'); $this->assertElementContainsText("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td[2]", "$ {$amtPaid}", 'Missing text: appropriate fee amount'); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Generic/CheckDashboardTest.php b/tests/phpunit/WebTest/Generic/CheckDashboardTest.php index a5fc470086..0da9ce9ad7 100644 --- a/tests/phpunit/WebTest/Generic/CheckDashboardTest.php +++ b/tests/phpunit/WebTest/Generic/CheckDashboardTest.php @@ -80,12 +80,12 @@ class WebTest_Generic_CheckDashboardTest extends CiviSeleniumTestCase { $this->waitForElementPresent("css=li#widget-2 a.fullscreen-icon"); $this->click("css=li#widget-2 a.fullscreen-icon"); $this->waitForElementPresent("ui-id-1"); - $this->assertTrue($this->isTextPresent($widgetTitle)); + $this->waitForTextPresent("$widgetTitle"); // 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(5); - $this->click("link=close"); + $this->click("xpath=//*[@class='ui-button-text'][contains(text(), 'close')]"); } function _testRemoveDashboardElement($widgetConfigureID, $widgetEnabledSelector) { -- 2.25.1