selenium 中PageFactory [CacheLookup]属性

 selenium 中有个现成的框架 就是pagefactory 。我们可以实现页面元素和行为的分离。

在定义元素中如下啊 

 

[FindsBy(How = How.XPath, Using = "//table[@class='Tab01']/tbody/tr/td[3]")]
[CacheLookup]
private IList<IWebElement> prodNamePrice;

 

我们可以看到 是用。xpath 的查找方式

但是第二个【cachelookup】 是个什么东西了 来看原文啊 

CacheLookup

One last thing that remains with PageFactory is the CacheLookupAttribute. This is important because it can be used to instruct the InitElements method to cache the element once its located. In other words, any attribute marked[CacheLookup] will not be searched over and over again – this is especially useful for elements that are always going to be there (not always true for AJAX apps). So, we can search once and cache. All elements used in this article can be defined by this declarative tag as they are static and are always present. 

 

简单说来 就是元素的缓冲 在用  PageFactory.InitElements(MyWebDriver.driver,pageclass); 时会用到 (我想的啊 )。你要确保这些有这些属性的页面元素是保持不变的 。原因就是上面说的饿,可能在ajax中 这个元素是变化的 ,可是用的时候用的是缓存 ,没有拿到最新的元素,所以 不能使用在ajax元素中

 这是今天的收获吧 。下班了 。锻炼身体去先。

转载于:https://www.cnblogs.com/windcrazy/p/3223342.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值