如何使用Selenium Perl API获取当前网址
问题描述:
我只是想获取当前网页的绝对网址。这里是代码片段如何使用Selenium Perl API获取当前网址
my $url_str = "BEFORE";
$sel->storeLocation("url_str");
$sel->comment(URL is $url);
Send command: storeLocation|url_str|
Got result : OK
Comment : URL is BEFORE
它似乎没有工作。我尝试使用$ url_str,\ $ url_str作为storeLocation的参数,但徒劳无益。请帮助我究竟在这里丢失了什么
答
Perl API使用更多的Perlish'get_'作为前缀而不是'store'的Selenium标准。此外,Perl API使用下划线而不是骆驼大小写。
# returns the current url
$sel->get_location()
另见:
- 的WWW::Selenium文档在CPAN上CPAN
- The official Selenium docs
抱歉打扰你们.. $ SEL-> get_location
要么作为回答发布并接受它,要么删除questi上 ;) – Konerak 2011-06-09 06:47:57