【发布时间】:2011-09-06 07:59:46
【问题描述】:
我有一个 html 文件,它存储假设存储的 absoluteUrl,其内容是这样的:
<html>
<head><title>Root URL variable</title></head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Root URL variable</td></tr>
</thead><tbody>
<tr>
<td>store</td>
<td>javascript{window.location;}</td>
<td>rootUrl</td>
</tr>
</tbody></table>
</body>
</html>
当我尝试用var loc = window.location; 替换window.location 时出现问题,我收到此错误
命令执行失败。请在论坛http://clearspace.openqa.org 中搜索日志窗口中的错误详细信息。错误信息是:eval(match1) is undefined
这是第一个问题。第二个问题是我想使用 javascript 获取绝对路径并尝试存储为 rootUrl 变量。任何解决方案建议都会很方便(如果第一个问题得到解决,我计划尝试类似于 Neville Bonavia 的here 的解决方案,即
function getAbsolutePath() {
var loc = window.location;
var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);
return loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));
}
【问题讨论】:
标签: javascript html selenium selenium-rc selenium-ide