自动化测试工具无法读取PB的sle.text,解决方案

来源:互联网 发布:重生之网络巨头txt下载 编辑:程序博客网 时间:2024/05/21 14:50

用WinRunner、Rational Rotot等自动化测试工具测试PB程序,会发现无法读取文本框的值,因为PB的控件不是标准的Windows控件。下文给出了一个解决方案


作者:J. Timothy Stewart

 

Apparently, PowerBuilder's StaticText boxes do not follow the MS standards for static text in that they do not update their text captions correctly. If you call a WinAPI GetWindowText funtion with the handle to 
a PB static text box, the API will return the text caption placed in that control at design time. It will NOT ever return the value of that field at runtime if it were to change after development (i.e. status 
bar). This creates a problem for automated testing tools such as SQA TeamTest and QA Partner which rely on the WinAPI to retreive these values from those controls.

 

Our final resolution to this problem is that we used StaticText controls to display the information (instead of SLEs) and we created a global function called F_SETTEXT() which is called whenever the text caption in a static control changes.

 

void function F_SETTEXT( staticbox control, string stext) 
control.text = stext 
SetWindowText(handle(control),sText) 
return

 

This will ensure that other applications can "read" the text in the caption as it uses the WinAPI call to set the text as well as the PB assignment method. This solution works for us.