我正在尝试使用QTP中的多个标签,但当我尝试在新标签中打开网站时,我不断收到“常规运行时错误”。
这是一个重现的脚本:
'Open a new Browser
SystemUtil.Run "iexplore.exe", "http://www.google.com"
'Browser Sync
Browser("CreationTime:=0").Sync
'Find total number of tabs in the browser window
iTabs = Browser("CreationTime:=0").GetROProperty("number of tabs")
msgbox iTabs 'Displays the value 1
'Open a new tab within the same browser
Browser("CreationTime:=0").OpenNewTab()
'Sync for new tab
Browser("CreationTime:=1").Sync
'Load some web page in the new tab
Browser("CreationTime:=1").Navigate "http://www.yahoo.com" 'General Run Time error for this line.
'Find total number of tabs in the browser window
iTabs = Browser("CreationTime:=0").GetROProperty("number of tabs")
msgbox iTabs 'Displays the value 2
'Close all the tabs in the browser window
Browser("CreationTime:=0").CloseAllTabs()
'OR -> Browser("CreationTime:=1").CloseAllTabs()
答案 0 :(得分:0)
Browser.Navigate仅用于更改当前浏览器的URL。 由于到目前为止尚未创建具有CreationTime:= 1的浏览器,因此会引发运行时错误。