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
Valued Contributor.
Valued Contributor.
435 views

changing y property and iteration for each row

Jump to solution

Hi Everyone,

I need to run my Action for each row in LocalData however for each row property "y" changes. First row it is 24 then it is 48, 72 etc. "X" property is fixed for each object. I want to multiply "y" for each row when UFT finish all lines and goes to next row but Iterations does not work as it goes in a loop of the same data. Code looks like this:

Dim oDesc
Set oDesc = Description.Create
For i = 1 To 10
oDesc("y").value = 24*i
oDesc("x").value = 19
JavaWindow("Oracle Applications").JavaInternalFrame("Bank Statement Lines").JavaEdit(oDesc).Set DataTable("LINE", dtLocalSheet)

Next

But it does not work as it loops same line for ten times rather than change value of "y" when one line of data in local data set is finished.

 

Any advice would be much appreciated.

 

Krystian

0 Likes
1 Solution

Accepted Solutions
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

Hello,

Are you sure the property y is not set to 0? I've tried on our own Java application here and all JavaEdits have the property y set to 0. It really depends on the structure of the application.

I have tested this piece of code on our Java application and it works just fine though I would never do it this way:

Dim oDesc
Set oDesc = Description.Create
For i = 0 To 3

oDesc("abs_y").value = 523 + 30*i
oDesc("abs_x").value = 1068
JavaWindow("title:=.*XXX.*").JavaEdit(oDesc).Set i


Next

View solution in original post

0 Likes
9 Replies
Highlighted
Micro Focus Contributor
Micro Focus Contributor

Krystian,

          Thanks for reaching out to us, As you described you are having some issues setting "y" property for running test on different columns. 

Set oDesc = Description.Create
For i = 1 To 10
oDesc("y").value

 

Related to "for" structure please find example below:

For i90 To 95 Step 1
      'MsgBox i      'Launching Flight Application
     SystemUtil.Run
"C:\ProgramFiles\HP\UnifiedFunctionalTesting\samples\flight\app\flight4a.exe"
 
     'Inputbox will ask user to enter the username at runtime
      UserName
=InputBox("Enter UserName")
     'Enter Agent name, Password and click on button
     Dialog
("Login").WinEdit("Agent Name:").Set UserName
     Dialog
("Login").WinEdit("Password:").Set "mercury"
     Dialog
("Login").WinButton("OK").Click        ''validating Flight Agent Login
        If Window
("Flight Reservation").Exist(4Then
            Reporter.ReportEvent micPass,
"Agent login","Agent Login Pass"
       Else
           Reporter.ReportEvent micFail,
"Agent Login","Agent Login Fail"
      EndIf
   Window
("Flight Reservation").Close
Next
 

I would suggest you to see at: https://stackoverflow.com/questions/26400139/looping-values-from-excel-sheet-in-uft

 And also: http://creativeqtp.blogspot.com/p/for-loop-in-qtp.html

for some examples on how to use iterator "for" on multiple scenarios.

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Hi Fabian,

Thank you for your feedback. However this does not really solve my problem.

I am aware of how "for" function should be structured and I do not really need to import my data from excel.

What I really need to achieve here is to design my code that for every global data iteration, "y" property is different.

Hope to hear from you.

0 Likes
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

Hello,

Are you sure the property y is not set to 0? I've tried on our own Java application here and all JavaEdits have the property y set to 0. It really depends on the structure of the application.

I have tested this piece of code on our Java application and it works just fine though I would never do it this way:

Dim oDesc
Set oDesc = Description.Create
For i = 0 To 3

oDesc("abs_y").value = 523 + 30*i
oDesc("abs_x").value = 1068
JavaWindow("title:=.*XXX.*").JavaEdit(oDesc).Set i


Next

View solution in original post

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Hi mu21,

Thank you for your ongoing support.

For i = 0 To 3

oDesc("abs_y").value = 523 + 30*i

is what I needed. However when I want to see value by MsgBox it is three times 523 + 30*3

Do you know why?

0 Likes
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

I'm not sure I understand what you mean. Are you trying to display the value of abs_y with MsgBox or something else? How are you doing it?

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Hi,

You can disregard this problem. I had a bug in my code when I was testing it. Thank you for your help!

0 Likes
Highlighted
Micro Focus Contributor
Micro Focus Contributor

@Krystian Wojewski , thanks for letting us know. @mu21 I appreciate your attentiveness in this technical issue. @Krystian Wojewski, as this seems so be a frequented post by customers who might be facing the same issue, it would be useful if you can post the error you faced, which might be helpful for others to have this issue solved too. Thanks for contacting us,

 

Regards

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

@Fabian Crawford I meant it was just my mistake in code rather than bug in the tool. However I am still not sure how data in globalsheet affects "FOR" function in actions which base on localsheet data. But I guess this is for separate topic. Cheers!

0 Likes
Highlighted
Micro Focus Contributor
Micro Focus Contributor

@Krystian Wojewski  Thanks for the clarification, and feel free to raise a new post to be attended on this other query.

Regards,

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.