Watir如何定位Modal dialog

Watir1.8已经支持定位modal dialog.

ie.modal_dialog(:title,"***")

 

但是在中文操作系统下一直定位不到,看了下代码:

 title = "#{what} -- Web Page Dialog"

这个是原因,因为真正的网页标题是*** -- 网页对话框

因此可以有两种办法:

1.用纯title定位

modal_dialog.rb:

 #              title = "#{what} -- Web Page Dialog"

  title = what
 @hwnd, arr = FindWindowEx.call(0, 0, nil, title)

 

在调用时候,先获得窗口标题:

title1 = Watir::autoit.WinGetTitle("")

title1[/网页对话框/] = "/315/370/322/263/266/324/273/260/277/362"

modal = Zs.ie.modal_dialog(:title,title1.to_s())

 

2.用部分title定位:

 title = "#{what} -- /315/370/322/263/266/324/273/260/277/362"
  @hwnd, arr = FindWindowEx.call(0, 0, nil, title)

在调用时候,先获得--前面部分的窗口标题:

title1 = "Modal dialog"

modal = Zs.ie.modal_dialog(:title,title1.to_s())

 

你可能感兴趣的:(Web,dialog)