问题:我们经常遇到有些编辑框不能直接赋值,比如日期输入框,所以在脚本编写时候需要编写一大操作脚本,参数化就更加麻烦,是否有一种方法可以快捷的进行操作。
问题分析:我们平时解决方法,往往是想各种办法去实现这个输入,其实编辑框无法输入是因为编辑框的readOnly=true,所以这次我们换个角度不是去想办法开锁,而是把锁撬掉。
解决方法:修改目标编辑框的属性为readOnly=false,然后再执行set操作。
QTP脚本实例:
Function common_set_readonlyedit(obj_input,mes_input) Set obj=obj_input.Object old_set=obj.readOnly if old_set=true then obj.readOnly=false obj_input.set mes_input obj.readOnly=old_set else obj_input.set mes_input end if End Function ruby脚本实例: def common_set_readonlyedit(obj,mes_input) old_set=obj.readOnly if old_set==true obj.readOnly=false obj.value=mes_input obj.readOnly=old_set else obj.value=mes_input end end |