51Testing软件测试论坛

标题: if 判断有问题, 如何解释? [打印本页]

作者: 小李美刀    时间: 2006-8-24 17:48
标题: if 判断有问题, 如何解释?
这是WR自带的FLIGHT 例子, 我录制了脚本, 但在报告里显示的是"The Flights button was successfully enabled", 实际上 Insert Order 按钮是灰色的,处于不可用状态, 所以 if(value=0) 的判断结果应该是真, 这样else就不应该执行才对, 请问怎么解释呢?

set_window ("Flight Reservation");
obj_type("MSMaskWndClass","120106");

#Type in a value in the Fly From: box
list_select_item ("Fly From:", "Portland");
#Type in a value in the Fly To: box
list_select_item ("Fly To:", "Denver");
#Check that the Flights button is enabled

button_get_state ("Insert Order", value);

if (value = 0)
report_msg ("Flights button was not enabled. Check that values for Fly From and Fly To are valid");

else

report_msg ("The Flights button was successfully enabled");

[ 本帖最后由 小李美刀 于 2006-8-24 18:04 编辑 ]
作者: merry    时间: 2006-8-24 17:59
1: Insert Order 按钮是灰色的
2:那么value的状态值应该是非真
3:非真即假,假即非零
4:所以i应该走else分支
作者: 小李美刀    时间: 2006-8-24 18:02
楼上的姐姐, 我设的 value = 0, 即灰色的按钮状态应该是真,  所以应该走第一条语句才对吧
作者: 快乐逍遥    时间: 2006-8-24 18:15
是不是判断语句不对呀? if (value = 0)
试一下 if (value == 0)
作者: 小李美刀    时间: 2006-8-24 18:30
可以写成:  value==0 吗 ???

那怎么解释呢,  好想偶有点晕
作者: 快乐逍遥    时间: 2006-8-25 10:50
楼上的兄弟,判断中的等于是使用恒等号"==" 的呀
作者: 生如火花    时间: 2006-8-25 10:53
=是赋值,==是条件
作者: 小李美刀    时间: 2006-8-25 13:24
标题: 还是不正确
各位哥哥姐姐,还是不正确,下面的code中,Insert Order 按扭是可用状态的,但执行的仍是 If  语句的第一个分支,那判断还是错误的呀,该怎么解释吗?
set_window ("Flight Reservation");
obj_type("MSMaskWndClass","120106");

#Type in a value in the Fly From: box
list_select_item ("Fly From:", "Portland");
#Type in a value in the Fly To: box
list_select_item ("Fly To:", "Denver");
#Check that the Flights button is enabled
obj_mouse_click ("FLIGHT", 38, 30, LEFT);
set_window("Flights Table");
list_select_item("Flight","#3");
button_press("OK");
set_window("Flight Reservation");
obj_type("Name:","lihai");
wait(2);

button_get_state ("Insert Order", value);
if (value == 0)
{
report_msg ("Flights button was not enabled. Check that values for Fly From and Fly To are valid");
button_press("Insert Order");
}
else

report_msg ("The Flights button was successfully enabled");

[ 本帖最后由 小李美刀 于 2006-8-25 13:26 编辑 ]
作者: 生如火花    时间: 2006-8-25 15:07
0是E_OK,也就是真,如果按钮是灰的,那就执行else
作者: 小李美刀    时间: 2006-8-25 17:06
标题: 还是不正确
斑竹,但现在下面的程序中按扭是灰色的,但却没有执行 else 语句,它执行的是第一条语句:report_msg ("The Flights button was successfully enabled"); 我还是不明白.

set_window ("Flight Reservation");
obj_type("MSMaskWndClass","120106");

#Type in a value in the Fly From: box
list_select_item ("Fly From:", "Portland");
#Type in a value in the Fly To: box
list_select_item ("Fly To:", "Denver");
#Check that the Flights button is enabled

button_get_state ("Insert Order", value);

if (value ==E_OK)
report_msg ("The Flights button was successfully enabled");


else

report_msg ("Flights button was not enabled. Check that values for Fly From and Fly To are valid");

[ 本帖最后由 小李美刀 于 2006-8-25 17:09 编辑 ]
作者: laylowmay    时间: 2006-8-26 19:58
gui spy显示 置灰的按钮enabled=0 不置灰的enabled=1
再试试




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2