Mer*_*erc 12 javascript selenium google-chrome chromium chrome-web-driver
在官方W3c webdirver文档中,明确指出位置策略是:
State Keyword
CSS selector "css selector"
Link text selector "link text"
Partial link text selector "partial link text"
Tag name "tag name"
XPath selector "xpath"
Run Code Online (Sandbox Code Playgroud)
但是,Selenium的电线协议允许:
class name
css selector
id
name
link text
partial link text
tag name
xpath
Run Code Online (Sandbox Code Playgroud)
在理论中,Selenium的文档已经过时,"真实"的故事在新的规范文档中.然而...
我在最新的Chrome自己的Webdriver上运行了一些测试,我可以确认这一点,name并且class name两者都有效; 但是,它们不符合规格.
我记得在Chromium问题上阅读他们只会实现官方的Webdriver规范.
现在:我知道通用答案,其中"规格并不总是100%遵循"等.但是,我想知道的是:
Deb*_*anB 14
是的,你看对了.
按照目前WebDriver - W3C Candidate Recommendation的Locator Strategies士兵如下:
"css selector" :CSS选择器"link text" :链接文本选择器"partial link text" :部分链接文本选择器"tag name" : 标签名称"xpath" :XPath选择器快照:
但是,JsonWireProtocol曾经用于支持下面列出的定位策略,但目前文档明确指出它的状态为已过时:
class name:返回其类名包含搜索值的元素; 不允许使用复合类名.css selector :返回与CSS选择器匹配的元素.id :返回ID属性与搜索值匹配的元素.name :返回其NAME属性与搜索值匹配的元素.link text :返回其可见文本与搜索值匹配的锚元素.partial link text :返回一个锚元素,其可见文本与搜索值部分匹配.tag name :返回其标记名称与搜索值匹配的元素.xpath:返回与XPath表达式匹配的元素.提供的XPath表达式必须"按原样"应用于服务器; 如果表达式不是相对于元素根,则服务器不应修改它.因此,XPath查询可能会返回未包含在根元素的子树中的元素.快照:
更改通过相应的客户端特定绑定传播.对于Selenium-Java这里的客户端是客户端代码,我们有为用户工作的switchcase:
switch (using) {
case "class name":
toReturn.put("using", "css selector");
toReturn.put("value", "." + cssEscape(value));
break;
case "id":
toReturn.put("using", "css selector");
toReturn.put("value", "#" + cssEscape(value));
break;
case "link text":
// Do nothing
break;
case "name":
toReturn.put("using", "css selector");
toReturn.put("value", "*[name='" + value + "']");
break;
case "partial link text":
// Do nothing
break;
case "tag name":
toReturn.put("using", "css selector");
toReturn.put("value", cssEscape(value));
break;
case "xpath":
// Do nothing
break;
}
return toReturn;Run Code Online (Sandbox Code Playgroud)
快照:
现在,你的问题必定是为什么这个改变W3C Specs了clients.根据#1042,来自WebDriver贡献者的回答非常简单:
This keeps the specification simple as these can be implemented using the CSS selector, which maps down to querySelector/querySelectorAll.
| 归档时间: |
|
| 查看次数: |
5128 次 |
| 最近记录: |