NOTICE: Significant community changes coming soon
The header menu and the home page on our community will be changing soon. Get more information HERE.
Highlighted
Regular Contributor.
Regular Contributor.
1336 views

Unable to cast object of type 'system.int16' to type 'system.string'

Hi All,

I am quite new to UFT and seeking help for running the follwoing script.

For orderNum = 1 To 5 Step 1
SystemUtil.Run "C:\Program Files (x86)\HPE\Unified Functional Testing\samples\Flights Application\FlightsGUI.exe"
WpfWindow("HPE MyFlight Sample Applicatio").WpfEdit("agentName").Set "john"
WpfWindow("HPE MyFlight Sample Applicatio").WpfEdit("password").SetSecure "59b811e5bb4f8b6e332f"
WpfWindow("HPE MyFlight Sample Applicatio").WpfButton("OK").Click
WpfWindow("HPE MyFlight Sample Applicatio").WpfTabStrip("WpfTabStrip").Select "SEARCH ORDER"
WpfWindow("HPE MyFlight Sample Applicatio").WpfRadioButton("byNumberRadio").Set
WpfWindow("HPE MyFlight Sample Applicatio").WpfEdit("byNumberWatermark").Set orderNum
WpfWindow("HPE MyFlight Sample Applicatio").WpfButton("SEARCH").Click
WpfWindow("HPE MyFlight Sample Applicatio").Close
Next

I recorded the FlightGUI application to search an order number and now while trying to parameterize the script using For..Next loop, during run-time it displays the following error message:

Unable to cast object of type 'System.Int16' to type 'System.String'.

Line(8): "WpfWindow("HPE MyFlight Sample Applicatio").WpfEdit("byNumberWatermark").Set orderNum"

 

Please let me know what must I include in the script.

 

Regards,

RK

0 Likes
4 Replies
Highlighted
Super Contributor.
Super Contributor.

Hi,

Did you try the following:

WpfWindow("HPE MyFlight Sample Applicatio").WpfEdit("byNumberWatermark").Set cstr(orderNum)

?

If this does not work, please try the following (ugly but should work as well):

orederNum = OrderNum + ""

WpfWindow("HPE MyFlight Sample Applicatio").WpfEdit("byNumberWatermark").Set orderNum

 

Good Luck!

Highlighted
Regular Contributor.
Regular Contributor.

Hi,

The first option worked i.e. converting integer type to string type (cstr).

However I tried the second option, but got "Type Mismatch: String" error.

 

Anyways thank you very much for your help.

 

Thanks.

RK

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Hi,

Happy to hear the first option worked.

For the second, if didn't, please try this:

orederNum = OrderNum ""

WpfWindow("HPE MyFlight Sample Applicatio").WpfEdit("byNumberWatermark").Set orderNum

 

Good luck!

0 Likes
Highlighted
New Member.

Hi RK,

You can try this. 

.Set CStr (orderNum)

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.