Changeset 2575
- Timestamp:
- 10/31/06 12:00:59 (2 years ago)
- Files:
-
- trunk/lib/util/sfBrowser.class.php (modified) (3 diffs)
- trunk/test/unit/util/sfBrowserTest.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/util/sfBrowser.class.php
r2569 r2575 241 241 $dom = $this->dom; 242 242 243 // link243 // text link 244 244 if ($link = $xpath->query(sprintf('//a[.="%s"]', $name))->item(0)) 245 245 { … … 247 247 } 248 248 249 // image link 250 if ($link = $xpath->query(sprintf('//a/img[@alt="%s"]/ancestor::a', $name))->item(0)) 251 { 252 return $this->get($link->getAttribute('href')); 253 } 254 249 255 // form 250 if (!$form = $xpath->query(sprintf('//input[( @type="submit" or @type="button") and @value="%s"]/ancestor::form', $name))->item(0))256 if (!$form = $xpath->query(sprintf('//input[((@type="submit" or @type="button") and @value="%s") or (@type="image" and @alt="%s")]/ancestor::form', $name, $name))->item(0)) 251 257 { 252 258 throw new sfException(sprintf('Cannot find the "%s" link or button.', $name)); … … 263 269 $elementName = $element->getAttribute('name'); 264 270 $value = null; 265 if ($element->nodeName == 'input' && (($element->getAttribute('type') != 'submit' && $element->getAttribute('type') != 'button') || $element->getAttribute('value') == $name)) 271 if ( 272 $element->nodeName == 'input' 273 && 274 (($element->getAttribute('type') != 'submit' && $element->getAttribute('type') != 'button') || $element->getAttribute('value') == $name) 275 && 276 ($element->getAttribute('type') != 'image' || $element->getAttribute('alt') == $name) 277 ) 266 278 { 267 279 $value = $element->getAttribute('value'); trunk/test/unit/util/sfBrowserTest.php
r2283 r2575 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(3 6, new lime_output_color());13 $t = new lime_test(38, new lime_output_color()); 14 14 15 15 // ->click() … … 36 36 <body> 37 37 <a href="/mylink">test link</a> 38 <a href="/myimagelink"><img src="myimage.gif" alt="image link" /></a> 38 39 <form action="/myform" method="post"> 39 40 <input type="text" name="text_default_value" value="default" /> … … 79 80 <div><span> 80 81 <input type="submit" name="submit" value="submit4" /> 82 <input type="image" src="myimage.png" alt="image submit" name="submit_image" value="image" /> 81 83 </span></div> 82 84 </form> … … 99 101 list($method, $uri, $parameters) = $b->click('test link'); 100 102 $t->is($uri, '/mylink', '->click() clicks on links'); 103 104 list($method, $uri, $parameters) = $b->click('image link'); 105 $t->is($uri, '/myimagelink', '->click() clicks on image links'); 101 106 102 107 list($method, $uri, $parameters) = $b->click('submit'); … … 132 137 list($method, $uri, $parameters) = $b->click('submit4'); 133 138 $t->is($uri, '/myform4?submit=submit4', '->click() can click on submit button anywhere in a form'); 139 140 list($method, $uri, $parameters) = $b->click('image submit'); 141 $t->is($uri, '/myform4?submit_image=image', '->click() can click on image button in forms'); 134 142 135 143 list($method, $uri, $parameters) = $b->click('submit', array(