环境:Win7+IE9+QPT11
问题描述:
WebList选择值,选择的类别自动在table中显示。尝试如下:
一、使用 FireEvent "onchange" 方法(经验证此方法在本环境下无效,如要使用将QTP升级到11.5即可),代码如下:
Browser("Browser").Page("Page").WebList("WebList").Select "val0"
Browser("Browser").Page("Page").WebList("WebList").FireEvent "onchange"
附:FireEvent可用事件有: onchange, onclick, ondblclick, onblur, onfocus, onmousedown,onmouseup, onmouseover, onmouseout, onsubmit, onreset, onpropertychange.
二、使用SendKeys方法,代码如下
1.最小化QTP
Set QTP= CreateObject("QuickTest.Application")
QTP.WindowState = "Minimized"
2.控件获得焦点,发送按键
Set ks=CreateObject("WScript.Shell")
Browser("Browser").Page("Page").WebList("WebList").Object.focus
ks.SendKeys "{UP}
附:
1.程序窗口显示状态介绍:
object.WindowState [= value]
value可取如下值
- Maximized--UFT is displayed at full screen size.
- Minimized--UFT is open, but minimized.
- Normal--UFT is displayed at the size it was prior to the last minimize or maximize operation.
官方示例:
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start UFT
qtApp.ActivateView "ExpertView" ' Display the Editor
qtApp.Options.DisplayKeywordView = False ' Hide the Keyword View
qtApp.ShowPaneScreen "ActiveScreen", True ' Display the Active Screen pane
qtApp.ShowPaneScreen "DataTable", False ' Hide the Data Table Explorer pane
qtApp.ShowPaneScreen "DebugViewer", True ' Display the Debug Watch pane
qtApp.WindowState = "Maximized" ' Maximize the UFT window
qtApp.Visible = True ' Make the UFT window visible
Set qtApp = Nothing ' Release the Application object
2.按键对应描述:
按键 | 参数 |
---|---|
BACKSPACE | {BACKSPACE}, {BS}, or {BKSP} |
BREAK | {BREAK} |
CAPS LOCK | {CAPSLOCK} |
DEL or DELETE | {DELETE} or {DEL} |
DOWN ARROW | {DOWN} |
END | {END} |
ENTER | {ENTER} or ~ |
ESC | {ESC} |
HELP | {HELP} |
HOME | {HOME} |
INS or INSERT | {INSERT} or {INS} |
LEFT ARROW | {LEFT} |
NUM LOCK | {NUMLOCK} |
PAGE DOWN | {PGDN} |
PAGE UP | {PGUP} |
PRINT SCREEN | {PRTSC} |
RIGHT ARROW | {RIGHT} |
SCROLL LOCK | {SCROLLLOCK} |
TAB | {TAB} |
UP ARROW | {UP} |
F1 | {F1} |
F2 | {F2} |
F3 | {F3} |
F4 | {F4} |
F5 | {F5} |
F6 | {F6} |
F7 | {F7} |
F8 | {F8} |
F9 | {F9} |
F10 | {F10} |
F11 | {F11} |
F12 | {F12} |
F13 | {F13} |
F14 | {F14} |
F15 | {F15} |
F16 | {F16} |