Vbscript UFT自动化中的动态链接?
我想在UFT 12.02中为我的web自动化编写一个动态VBScript。我想传递一个动态值作为链接的一部分。以下是我的示例行代码:Vbscript UFT自动化中的动态链接?,vbscript,automation,hp-uft,Vbscript,Automation,Hp Uft,我想在UFT 12.02中为我的web自动化编写一个动态VBScript。我想传递一个动态值作为链接的一部分。以下是我的示例行代码: set ObjExcel = CreateObject("Excel.application") ObjExcel.workbooks.open "F:\Automation\Web\Business\WebTestData.xls" For Curr= 1 To 20 USD = ObjExcel.sheets(1).cells(Curr,1).Val
set ObjExcel = CreateObject("Excel.application")
ObjExcel.workbooks.open "F:\Automation\Web\Business\WebTestData.xls"
For Curr= 1 To 20
USD = ObjExcel.sheets(1).cells(Curr,1).Value
If Browser("...").Page("...").Exist Then
Browser("...").Page("...").WebElement("WebElement").Click
'Attempt to click on Drop Down Link
Browser("...").Page("...").Link("USD").Click
End If
Next
“USD”
将不断变化,即我将从Excel中选择它
预期结果:
生成一个脚本,尝试单击不同的链接,如下所示:
Browser("...").Page("...").Link("EURO").Click
Browser("...").Page("...").Link("BP").Click
Browser("...").Page("...").Link("AED").Click
Browser("...").Page("...").Link("KSH").Click
Browser("...").Page("...").Link("IR").Click
我没有使用UFT的经验,但是不应该使用变量
USD
而不是字符串“USD”
来做你想做的事吗
电流=1至20时的
美元=实物外汇。表(1)。单元格(货币,1)。值
如果浏览器(“…”)页(“…”)存在,则
浏览器(“…”)。页面(“…”)。WebElement(“WebElement”)。单击
'尝试单击下拉链接
浏览器(“…”)。页面(“…”)。链接(美元)。单击
如果结束
下一个
我对UFT没有任何经验,但不应该使用变量USD
而不是字符串“USD”
来做你想做的事
电流=1至20时的
美元=实物外汇。表(1)。单元格(货币,1)。值
如果浏览器(“…”)页(“…”)存在,则
浏览器(“…”)。页面(“…”)。WebElement(“WebElement”)。单击
'尝试单击下拉链接
浏览器(“…”)。页面(“…”)。链接(美元)。单击
如果结束
下一个
我对UFT没有任何经验,但不应该使用变量USD
而不是字符串“USD”
来做你想做的事
电流=1至20时的
美元=实物外汇。表(1)。单元格(货币,1)。值
如果浏览器(“…”)页(“…”)存在,则
浏览器(“…”)。页面(“…”)。WebElement(“WebElement”)。单击
'尝试单击下拉链接
浏览器(“…”)。页面(“…”)。链接(美元)。单击
如果结束
下一个
我对UFT没有任何经验,但不应该使用变量USD
而不是字符串“USD”
来做你想做的事
电流=1至20时的
美元=实物外汇。表(1)。单元格(货币,1)。值
如果浏览器(“…”)页(“…”)存在,则
浏览器(“…”)。页面(“…”)。WebElement(“WebElement”)。单击
'尝试单击下拉链接
浏览器(“…”)。页面(“…”)。链接(美元)。单击
如果结束
下一个
是的,您应该使用美元,不带双引号
Dim currType, ObjExcel
set ObjExcel = CreateObject("Excel.application")
ObjExcel.workbooks.open "F:\Automation\Web\Business\WebTestData.xls"
For Curr= 1 To 20
currType = ObjExcel.sheets(1).cells(Curr,1).Value
If Browser("...").Page("...").Exist Then
Browser("...").Page("...").WebElement("WebElement").Click
'Attempt to click on Drop Down Link
Browser("...").Page("...").Link(currType).Click
End If
Next
set ObjExcel = Nothing
注意:我用currType更改了USD。是的,您应该使用USD而不使用双引号
Dim currType, ObjExcel
set ObjExcel = CreateObject("Excel.application")
ObjExcel.workbooks.open "F:\Automation\Web\Business\WebTestData.xls"
For Curr= 1 To 20
currType = ObjExcel.sheets(1).cells(Curr,1).Value
If Browser("...").Page("...").Exist Then
Browser("...").Page("...").WebElement("WebElement").Click
'Attempt to click on Drop Down Link
Browser("...").Page("...").Link(currType).Click
End If
Next
set ObjExcel = Nothing
注意:我用currType更改了USD。是的,您应该使用USD而不使用双引号
Dim currType, ObjExcel
set ObjExcel = CreateObject("Excel.application")
ObjExcel.workbooks.open "F:\Automation\Web\Business\WebTestData.xls"
For Curr= 1 To 20
currType = ObjExcel.sheets(1).cells(Curr,1).Value
If Browser("...").Page("...").Exist Then
Browser("...").Page("...").WebElement("WebElement").Click
'Attempt to click on Drop Down Link
Browser("...").Page("...").Link(currType).Click
End If
Next
set ObjExcel = Nothing
注意:我用currType更改了USD。是的,您应该使用USD而不使用双引号
Dim currType, ObjExcel
set ObjExcel = CreateObject("Excel.application")
ObjExcel.workbooks.open "F:\Automation\Web\Business\WebTestData.xls"
For Curr= 1 To 20
currType = ObjExcel.sheets(1).cells(Curr,1).Value
If Browser("...").Page("...").Exist Then
Browser("...").Page("...").WebElement("WebElement").Click
'Attempt to click on Drop Down Link
Browser("...").Page("...").Link(currType).Click
End If
Next
set ObjExcel = Nothing
注意:我用currType更改了USD