【发布时间】:2014-03-21 00:45:11
【问题描述】:
场景: 我打开 www.google.com,输入一些关键字,然后单击搜索按钮。 现在我进入结果页面。我想获取这个结果页的当前url,包括查询参数。
我在这里phpunit-selenium on github 找到了一个方法getBrowserUrl()。 410号线
但是这个方法返回了我在setUp函数中设置的值。
public function setUp(){
$this->setBrowser(testConfig::$browserName);
$this->setBrowserUrl('http://www.google.com/');
}
public function testGoogleSearch(){
$this->url('');
//input some keywords
.......
//click search button
.......
//want to get the url of result page
$resultUrl= $this->getBrowserUrl();
echo $resultUrl;
}
我得到一个字符串 'http://www.google.com/' 而不是结果页面的整个 url。 请帮助我,谢谢!
【问题讨论】:
-
看起来你可以在驱动程序上调用
getLocation()as seen in source。 -
@rutter 这是一种 selenium RC 方法。我不能将它用于 Selenium2 Webdriver。但是,我试过了,有一个错误“BadMethodCallException:命令'getLocation'不存在或尚不支持”。谢谢