自动化测试 - selenium Q&A

最近在用selenium给项目添加自动化测试模块,遇到以下问题以及解决办法,backup,也许以后还会用到。

 

Q1 :  Some elements id is generated automatically ext-gen in JS code, when the script run in the second times, the id recorded in the first time could not be found.

 

A1 : There are two solutions here,

  1. Add fixed id for the elements you are going to test in source code instead of being generated automatically.
  2. Use the parent node to identify a location and then using tag as road map to index to where you want. For example,

Target = ext-gen112

Can be changed into,

Target = //div[@id='testJsonsMenu']/ul/li[3]/a/span

 

We use a fix id testJsonsMenu to identify one location, then go down to find the element in the tree.

 

 

Q2 : Because of network slowness or application performance issue, sometimes, page response was not so quick that popup menu has not come out. So when selenium to run the next step, some element might not be found, missing error occur.

 

A2 : Tow solutions,

  1. Let selenium know the application was not that fast-run. If you are in selenium IDE, you could just drag slider from fast to slow in the main page.
  2. If you are in the programming code, you could set wait() or speed. I like the second one, for example, in java,

selenium .setSpeed( "1000" ); time unit is millisecond,

 

This means every step in your code will be run behind 1 second after the previous step is simulated.

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值