自动化测试中对不能输入的框体的处理

文本框input标签有些被强制的不允许输入,对于不能输入的方法有三种。如下:

方法1: οnfοcus=this.blur()

 <input type="text" name="input1" value="景安" οnfοcus=this.blur()>

 方法2:readonly
     <input type="text" name="input1" value="景安" readonly> 
    <input type="text" name="input1" value="景安" readonly="true"> 
  方法3: disabled
     <input type="text" name="input1" value="景安" disabled="true">

    浏览器运行效果:

    给大家举个完整的例子:
 
    <input name="ja_na" type="text" tabindex="2" onMouseOver="this.className='input_1'" onMouseOut="this.className='input_2'" value="5567689" disabled="true" readOnly="true" />
 
    说明:

    disabled="true" 此时文字会变成灰色,不可编辑。
 
    readOnly="true" 文字不会变色,也是不可编辑的
    

 以上内容:来源:景安网络 作者:明辰 

 

 

 

 

 

 在自动化测试中。如果我们想强制性的输入该如何解决。例如一个日期框。或者是一个文件上传的框(声明下,不一定处理后上传就可以使用)

下面是一个处理日期窗口无法填写的问题。

 

JavascriptExecutor removeAttribute =(JavascriptExecutor)driver;

removeAttribute.executeScript("var setDate=document.getElementById(\"startDateCreate\");setDate.removeAttribute(ture);"); 

 

这样就可以把不能输入的日期选择,变成可以输入的。然后输入日期,进行剩下的操作就可以了。

 

转载于:https://www.cnblogs.com/ywhyme/p/6094266.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值