Selenium webdriver Watir Webdriver,可以在chrome中单击元素,但不能在firefox中单击
我有下面的HTMLSelenium webdriver Watir Webdriver,可以在chrome中单击元素,但不能在firefox中单击,selenium-webdriver,watir,watir-webdriver,Selenium Webdriver,Watir,Watir Webdriver,我有下面的HTML <div class="brands brands-search-region"> <section class="module"> <div class="listing"> <article id="" class="node node-brand brand brand-item clickable multiple-item" about="/node/85531" typeof
<div class="brands brands-search-region">
<section class="module">
<div class="listing">
<article id="" class="node node-brand brand brand-item clickable multiple-item" about="/node/85531" typeof="sioc:Item foaf:Document">
<a href="/node/85531">
</a>
</article>
</div>
</section>
</div>
我知道我能做到:
browser.div(class: 'brands-search-region').article.a.click that works in both but why does the previous not work in firefox?
我将watir webdriver与最新版本的firefox、chromedriver和selenium webdriver一起使用。与chromedriver相比,不同的行为是由于FirefoxDriver实现元素点击的方式不同。根据我过去的观察:
- Chrome确定元素的中心,然后单击这些坐标处最深的元素
- Firefox确定元素的中心,然后单击元素的中心
<html>
<head>
<script>
function highlight(elem) {
alert(elem.nodeName);
}
</script>
</head>
<body>
<div class="brands brands-search-region">
<section class="module" onclick="highlight(this);">
<div class="listing" onclick="highlight(this);">
<article onclick="highlight(this);" style="border:1px solid red; text-align:center;">
<a href="" style="border:1px solid green;" onclick="highlight(this);">asdf</a>
</article>
</div>
</section>
</div>
</body>
</html>
在Firefox中,冒泡将是:
["A", "ARTICLE", "DIV", "SECTION"]
["ARTICLE", "DIV", "SECTION"]
Firefox已经在您让它单击的元素(即文章元素)上启动了单击事件。相比之下,Chrome的点击方式就像用户在特定坐标下的最深元素一样。您使用的是FF36?是否有错误消息?是的,firefox 36.0.4。没有错误,它只是转到下一行代码。感谢Justin的详细解释。谢谢。
["A", "ARTICLE", "DIV", "SECTION"]
["ARTICLE", "DIV", "SECTION"]