CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Unit Testing (Moderator: Michał Mach) »
  • help with Selenium tests
Pages: [1]

Author Topic: help with Selenium tests  (Read 2052 times)

fen

  • I post frequently
  • ***
  • Posts: 216
  • Karma: 13
    • CivicActions
  • CiviCRM version: 3.3-4.3
  • CMS version: Drupal 6/7
  • MySQL version: 5.1/5.5
  • PHP version: 5.3/5.4
help with Selenium tests
October 26, 2010, 06:32:53 pm
When running WebTest_Member_StandaloneAddTest I get ERROR: Element contact not found.  This fixes it:

Code: [Select]
Index: tests/phpunit/CiviTest/CiviSeleniumTestCase.php
===================================================================
--- tests/phpunit/CiviTest/CiviSeleniumTestCase.php (revision 30356)
+++ tests/phpunit/CiviTest/CiviSeleniumTestCase.php (working copy)
@@ -112,7 +112,7 @@
       $this->typeKeys("contact_1", $sortName);
       $this->waitForElementPresent("css=div.ac_results-inner li");
       $this->click("css=div.ac_results-inner li");
-      $this->assertContains($sortName, $this->getValue("contact"), "autocomplete expected $sortName but didn’t find it in " . $this->getValue("contact"));
+      $this->assertContains($sortName, $this->getValue("contact_1"), "autocomplete expected $sortName but didn’t find it in " . $this->getValue("contact_1"));
    }
 
    /*
But then I get ERROR: Element xpath=//table//tr/td[text()="Membership Type"]/../td[2] not found. which points to a faulty xpath in webtestVerifyTabularData().  I'm not too good with xpath - can anyone help me here?  The code in question is:
Code: [Select]
   function webtestVerifyTabularData($expected,  $xpathPrefix = null, $tableId = null )
    {
        $tableLocator = "";
        if ( $tableId ) {
            $tableLocator = "[@id='$tableId']";
        }
        foreach ($expected as $label => $value) {
            $this->verifyText("xpath={$xpathPrefix}//table{$tableLocator}//tr/td[text()=\"$label\"]/../td[2]", preg_quote($value));
        }
    }
Which is checking a page like /civicrm/contact/view/membership?action=view&reset=1&cid=101&id=1&context=membership&selectedChild=member
« Last Edit: October 26, 2010, 07:22:42 pm by fen »

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: help with Selenium tests
October 27, 2010, 08:23:42 am
Hey Fen,

Both problems has been fixed and commited, although I'm having some additional problems with this particular test and working on it at the moment. Right now we are in the point after many merges and quite a few tests are failing, we're gradually eliminating problems.

As for xpath, my recommendation is using XPath Checker (https://addons.mozilla.org/en-US/firefox/addon/1095/) - very useful tool!

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: help with Selenium tests
October 27, 2010, 08:50:38 am
Hey,

Final fix checked in. As usually, the problem was that the test wasn't waiting enough for proper elements to show up, that's always a problem, when testing heavily "jQueried" application. It should work fine now.

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Unit Testing (Moderator: Michał Mach) »
  • help with Selenium tests

This forum was archived on 2017-11-26.