Index: modules/syslog/syslog.test =================================================================== RCS file: /cvs/drupal/drupal/modules/syslog/syslog.test,v retrieving revision 1.3 diff -u -r1.3 syslog.test --- modules/syslog/syslog.test 2 Aug 2008 05:07:58 -0000 1.3 +++ modules/syslog/syslog.test 21 Aug 2008 00:08:28 -0000 @@ -40,7 +40,7 @@ $this->drupalGet('admin/settings/logging/syslog'); if ($this->parse()) { - $field = $this->elements->xpath('//option[@value="' . $edit['syslog_facility'] . '"]'); // Should be one field. + $field = $this->xpath('//option[@value="' . $edit['syslog_facility'] . '"]'); // Should be one field. $this->assertTrue($field[0]['selected'] == 'selected', t('Facility value saved.')); } } Index: modules/system/system.test =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.test,v retrieving revision 1.9 diff -u -r1.9 system.test --- modules/system/system.test 23 Jul 2008 07:37:06 -0000 1.9 +++ modules/system/system.test 21 Aug 2008 00:08:28 -0000 @@ -283,7 +283,7 @@ if ($this->parse()) { $found = 0; $extra = 0; - $divs = $this->elements->xpath("//div[@class='admin-panel']"); + $divs = $this->xpath("//div[@class='admin-panel']"); foreach ($divs as $panel) { if (in_array(trim($panel->h3), $panels)) { $found++; Index: modules/simpletest/simpletest.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.test,v retrieving revision 1.5 diff -u -r1.5 simpletest.test --- modules/simpletest/simpletest.test 13 Aug 2008 06:42:04 -0000 1.5 +++ modules/simpletest/simpletest.test 21 Aug 2008 00:08:28 -0000 @@ -190,7 +190,7 @@ * @return fieldset containing the results for group this test is in. */ function getResultFieldSet() { - $fieldsets = $this->elements->xpath('//fieldset'); + $fieldsets = $this->xpath('//fieldset'); $info = $this->getInfo(); foreach ($fieldsets as $fieldset) { if ($fieldset->legend == $info['group']) { Index: modules/simpletest/drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.30 diff -u -r1.30 drupal_web_test_case.php --- modules/simpletest/drupal_web_test_case.php 18 Aug 2008 19:25:52 -0000 1.30 +++ modules/simpletest/drupal_web_test_case.php 21 Aug 2008 00:08:28 -0000 @@ -860,7 +860,7 @@ if ($this->parse()) { $edit_save = $edit; // Let's iterate over all the forms. - $forms = $this->elements->xpath('//form'); + $forms = $this->xpath('//form'); foreach ($forms as $form) { // We try to set the fields of this form as specified in $edit. $edit = $edit_save; @@ -1052,6 +1052,24 @@ } /** + * Peform an xpath search on the contents of the internal browser. The search + * is relative to the root element (HTML tag normally) of the page. + * + * @param $xpath + * The xpath string to use in the search. + * @return + * The return value of the xpath search. For details on the xpath string + * format and return values see the SimpleXML documentation. + * http://us.php.net/manual/function.simplexml-element-xpath.php + */ + public function xpath($xpath) { + if ($this->parse()) { + return $this->elements->xpath($xpath); + } + return FALSE; + } + + /** * Get all option elements, including nested options, in a select. * * @param $element @@ -1092,15 +1110,13 @@ function clickLink($label, $index = 0) { $url_before = $this->getUrl(); $ret = FALSE; - if ($this->parse()) { - $urls = $this->elements->xpath('//a[text()="' . $label . '"]'); - if (isset($urls[$index])) { - $url_target = $this->getAbsoluteUrl($urls[$index]['href']); - $curl_options = array(CURLOPT_URL => $url_target); - $ret = $this->curlExec($curl_options); - } - $this->assertTrue($ret, t('Clicked link !label (!url_target) from !url_before', array('!label' => $label, '!url_target' => $url_target, '!url_before' => $url_before)), t('Browser')); + $urls = $this->xpath('//a[text()="' . $label . '"]'); + if (isset($urls[$index])) { + $url_target = $this->getAbsoluteUrl($urls[$index]['href']); + $curl_options = array(CURLOPT_URL => $url_target); + $ret = $this->curlExec($curl_options); } + $this->assertTrue($ret, t('Clicked link !label (!url_target) from !url_before', array('!label' => $label, '!url_target' => $url_target, '!url_before' => $url_before)), t('Browser')); return $ret; } @@ -1306,7 +1322,7 @@ * TRUE on pass, FALSE on fail. */ function assertTitle($title, $message, $group = 'Other') { - return $this->_assert($this->parse() && $this->elements->xpath('//title[text()="' . $title . '"]'), $message, $group); + return $this->_assert($this->xpath('//title[text()="' . $title . '"]') !== FALSE, $message, $group); } /** @@ -1324,18 +1340,17 @@ * TRUE on pass, FALSE on fail. */ function assertFieldByXPath($xpath, $value, $message, $group = 'Other') { - $fields = array(); - if ($this->parse()) { - $fields = $this->elements->xpath($xpath); - } + $fields = $this->xpath($xpath); // If value specified then check array for match. $found = TRUE; if ($value) { $found = FALSE; - foreach ($fields as $field) { - if ($field['value'] == $value) { - $found = TRUE; + if ($fields) { + foreach ($fields as $field) { + if ($field['value'] == $value) { + $found = TRUE; + } } } } @@ -1357,18 +1372,17 @@ * TRUE on pass, FALSE on fail. */ function assertNoFieldByXPath($xpath, $value, $message, $group = 'Other') { - $fields = array(); - if ($this->parse()) { - $fields = $this->elements->xpath($xpath); - } + $fields = $this->xpath($xpath); // If value specified then check array for match. $found = TRUE; if ($value) { $found = FALSE; - foreach ($fields as $field) { - if ($field['value'] == $value) { - $found = TRUE; + if ($fields) { + foreach ($fields as $field) { + if ($field['value'] == $value) { + $found = TRUE; + } } } }