Micro Focus QTP (UFT) Forums
Script gives syntax error in Flight reservation Application - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Script gives syntax error in Flight reservation Application (/Thread-Script-gives-syntax-error-in-Flight-reservation-Application)



Script gives syntax error in Flight reservation Application - pnp19 - 11-17-2009

Please see below script that i run in QTP 9.2 version. I want to parameterize and pass the value for "username" and password through my driver script.
Code:
SystemUtil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\HP\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").WinEdit("Agent Name:").Set  Datatable Value("username")
Dialog("Login").WinEdit("Agent Name:").Type  micTab
Dialog("Login").WinEdit("Password:").SetSecure Datatable Value("password")
Dialog("Login").WinButton("OK").Click
Window("Flight Reservation").Activate

while executing it gives me below error.

Error :

The test run cannot continue due to a syntax error.

Expected end of statement

Code:
Line (1): "Dialog("Login").WinEdit("Agent Name:").Set  Data table Value ("username")".
[/b]

Please help me out for this.

Thanks,
pnp


RE: Script gives syntax error in Flight reservation Application - Ram2009 - 11-17-2009

I think the error may be becz of extra line in the script
"Window("Flight Reservation").Activate".
Can you check it by removing this?
Regards,
Ram


RE: Script gives syntax error in Flight reservation Application - Saket - 11-17-2009

the correct syntax for retrieving data from datatable is Datatable(ParamID,Sheet) or Datatable.Value(ParamID,Sheet)
so you should use
Code:
Dialog("Login").WinEdit("Agent Name:").Set Datatable("username",dtLocalSheet)

if the Parameter 'username' is in your local sheet.


RE: Script gives syntax error in Flight reservation Application - pnp19 - 11-18-2009

tried with the saket solution but still get same error. I want to attach my script on fourm..Do I allow to do this ?
Script name: FR_demo-> which contains ( Login, Flight reservation, Open order and Logout scripts) . I will also attach my driver script. ( Test case 1).


RE: Script gives syntax error in Flight reservation Application - Saket - 11-18-2009

can you paste your modified code?
I dont think you need to attach all your QTP scripts here, only a piece of your statements should work or else a snapshot.


RE: Script gives syntax error in Flight reservation Application - Tarik Sheth - 11-18-2009

Hi,

You are missing .[dot] in datatable.value

Try the following and let us know.

Code:
"Dialog("Login").WinEdit("Agent Name:").Set Data table. Value ("username")".



RE: Script gives syntax error in Flight reservation Application - sreekanth chilam - 11-18-2009

Hi ,

As Tarik Suggested, you have missed .[dot]
ans also make sure that no blankspace given in word "Datatable"(ex: Data table is not allowed)

Try as given below.
Code:
Dialog("Login").WinEdit("Agent Name:").Set Datatable.Value("username",dtGlobalSheet)
Dialog("Login").WinEdit("Password:").Set Datatable.Value("password"dtGlobalSheet)

You can also use the below way too.

Code:
Dialog("Login").WinEdit("Agent Name:").Set Datatable.Value("username")
Dialog("Login").WinEdit("Password:").Set Datatable.Value("password")

Note: If we wont give 'sheetname' parameter then bydefault, QTP takes sheet as Globalsheet


RE: Script gives syntax error in Flight reservation Application - pnp19 - 11-18-2009

I tried with code givenby Tarik,

Code:
Dialog("Login").WinEdit("Agent Name:").Set Datatable.Value("username",dtGlobalSheet)
Dialog("Login").WinEdit("Password:").Set Datatable.Value("password"dtGlobalSheet)

Still another code without dtGlobalsheet give me error. but problem is resolved with above code.

Thanks to everyone for kind support.

Respect/Regards

Piyush


RE: Script gives syntax error in Flight reservation Application - Saket - 11-19-2009

Thats great, if you have sort out the issue, but again I can see a wrong statement there in the second line
',' is missing
Code:
Dialog("Login").WinEdit("Password:").Set Datatable.Value("password"dtGlobalSheet)
it should be
Dialog("Login").WinEdit("Password:").Set Datatable.Value("password",dtGlobalSheet)