Search code examples
vbavbscripthp-uft

Exspected End of Statement vb UFT


I am not new to automation but am new to vb scripting and HP UFT. I keep getting errors in UFT saying (Expected end of statement) and (Expected identifier). My code is below. can you please help me?

Dim browserHome
Dim pageHome
Dim txtAnnualSalary
Dim txtCon401k

Set browserHome = Description.Create
browserHome("micclass").value = "Browser"
browserHome("name").value = "401K Calculator | How" //issue here


Set pageHome =Description.Create       //issue here
pageHome("micclass").value = "Page"   //issue here
pageHome("title").value = "401K Calculator | How" //issue here


Set txtAnnualSalary = Description.Create       //issue here
txtAnnualSalary("micclass").value = "WebEdit"   //issue here
txtAnnualSalary("name").value = "AnnualSalary"

Set txtCon401k = Description.Create
txtCon401k("micclass").value = "WebEdit"
txtCon401k("name").value = "Con401k"

Dim txtCon401k
Set txtCon401k = Description.Create
txtEmpMatch("micclass").value = "WebEdit"
txtEmpMatch("name").value = "EmpMatch"

SystemUtil.Run "iexplore.exe","http://www.401kcalculator.org/"
Browser(browserHome).Page(pageHome).WebEdit(txtAnnualSalary).Set "10000"
Browser(browserHome).Page(pageHome).WebEdit(txtCon401k).Set "30"
Browser(browserHome).Page(pageHome).WebEdit(txtEmpMatch).Set "30"

Solution

  • code Seems ok.But please check Whether Browser has a property called "name" using Object Spy.If not you can't use that.

    If Yes Then:

    Also Can you try putting one Backspace the following line .

    Instead of :

    browserHome("name").value = "401K Calculator | How"
    

    Try :

    browserHome("name").value = "401K Calculator \| How"