2013-08-07 107 views
1

我打开这个网页http://www.ebay.com/itm/Apple-iPhone-5-16GB-White-Silver-Factory-Unlocked-/151097083750?pt=Cell_Phones&hash=item232e168766硒ISVISIBLE方法无法正常运行

,并检查是否为图像enter image description here

这里所提到的蓝丝带是可见的是我的测试

<tr> 
    <td>open</td> 
    <td>/itm/Apple-iPhone-5-16GB-White-Silver-Factory-Unlocked-/151097083750?pt=Cell_Phones&amp;hash=item232e168766</td> 
    <td></td> 
</tr> 
<tr> 
    <td>isVisible</td> 
    <td>//div[@class='vi-notify-msg']</td> 
    <td></td> 
</tr> 

并期待它失败,但令人惊讶的是它每次都会通过......我在这里错过了什么?

编辑:

我期待测试失败,因为色带需要时间的页面加载后出现之前色带visible..so应该失败正确执行的命令isVisible

+0

我不知道你为什么期望它失败。当我进入该页面时,我看到一个弹出窗口显示“每天有25个人访问此页面”,并且您的选择器正在选择它。 –

+0

@MrTi我编辑了这个问题.. – javanoob

回答

4

如果您查看HTML,那么在页面加载时,元素就在那里。这只是风格的淡入网页加载完成后,但是从HTML的角度来看,它是“看得见”的整个时间的页面加载:由于页面加载

<div id="vi_notification" class="vi-notify-cmp" style="top:25%;"> 
    <div class="vi-notify-container vi-notify-shadow"> 
     <div class="vi-notify-icon vi-notify-icon-img"></div> 
     <div class="vi-notify-msg">28 people are viewing this item per hour.</div> 
     <div class="vi-notify-close"> 
      <button id="vi_notification_cls_btn" class="vi-notify- close-btn">x</button> 
     </div> 
    </div> 
</div> 

只有在它淡出确实的造型变化显示:无

<div id="vi_notification" class="vi-notify-cmp" style="top: 25%; left: 10px; display: none;"> 
    <div class="vi-notify-container vi-notify-shadow"> 
     <div class="vi-notify-icon vi-notify-icon-img"></div> 
    <div class="vi-notify-msg">28 people are viewing this item per hour.</div> 
    <div class="vi-notify-close"> 
      <button id="vi_notification_cls_btn" class="vi-notify-close-btn">x</button> 
     </div> 
    </div> 
</div> 

如果你看看元素,因为它加载使用Chrome开发者工具栏,你会看到它是“看得见”,但造型ü pdates慢慢地淡入,所以我们的人眼可以看到它。

这意味着当页面加载/加载时,元素将按显示返回。在淡出之后,我希望显示返回false,因为父div上的样式已更改为display:none。

+0

感谢您的答案,但有什么方法来测试它会在一段时间后消失吗? – javanoob

+0

您可以延迟,然后重新测试元素的可见性。所以在页面加载之后,再等5秒钟,然后重新测试可见性,这应该返回为false。 – PocketDews