Forum Discussion

loginmm's avatar
loginmm
Contributor
13 years ago

Not able set a For loop to run the block of statements

Hi,



I added a For loop for my Keyword tests. I am able to add exactly start number, end number, variable and increment value, but not able to set the loop for a block of statments.



When I opened my Keyword test in the script I am able to see the below function




function Test1()


Test1()

{


var i;


i = "1";


for(i = 1; i <= 1; i = i + 1);


//Simulates one or several keypresses.


Aliases["CSMART"]["HwndSource_Window"]["Window"]["DockPanel"]["MainRegionItemsControl"]["RadDockHomeView"]["DockPanel"]["docking"]["RadSplitContainer"]["MainSplitContainer"]["DockingRadPaneGroup"]["Grid"]["Grid"]["ScrollViewer"]["RadCaseGridView"]["GridViewRow"]["GridViewCell"]["RadComboBox"]["Keys"]("[Down]");


 


}




I understand that for loop ended with the semicolon and not able to run my statment. How can I assign a block for collection of statements in keyword tests.



Please review the screenshot for the forloop in the keyword tests



If anyone have the videos for the forloop in keyword tests please share

9 Replies

  • Sorry in the above statments code I oberved as below




    function Test1()


    Test1()

    {


    var i;


    i = "1";


    for(i = 1; i <= 7; i = i + 1);


    //Simulates one or several keypresses.


    Aliases["CSMART"]["HwndSource_Window"]["Window"]["DockPanel"]["MainRegionItemsControl"]["RadDockHomeView"]["DockPanel"]["docking"]["RadSplitContainer"]["MainSplitContainer"]["DockingRadPaneGroup"]["Grid"]["Grid"]["ScrollViewer"]["RadCaseGridView"]["GridViewRow"]["GridViewCell"]["RadComboBox"]["Keys"]("[Down]");


     


    }





  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Highlight the CSMART line in your Keyword test by clicking on it once.  At the top of the keyword test there is then a green arrow pointing to the right.  Clicking on that once will indent the CSMART operation to be under the for loop.  See Screenshot


  • Hi,



    Now I am able to add for loop, but while execution I am seeing the Exception message please review my script below

     

    function Test1()


    Test1()

    {


    var i;


    i = "1";


    for(i = 1; i <= 7; i = i + 1)


    {

    Aliases
    ["CSMART"]["HwndSource_Window"]["Window"]["DockPanel"]["MainRegionItemsControl"]["RadDockHomeView"]["DockPanel"]["docking"]["RadSplitContainer"]["MainSplitContainer"]["DockingRadPaneGroup"]["Grid"]["Grid"]["ScrollViewer"]["RadCaseGridView"]["GridViewRow"]["GridViewCell"]["RadComboBox"]["Keys"]("[Down]");


     }



    May I know the reason for the exception, what are changes have to made to run the script successfully.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Please post the text and/or a screenshot of the exception message.
  • Hi,



    Thank you for the reply. Execution has to do exactly at ["Keys"]("[Down]". How can I make the loop for this part.



    Aliases["CSMART"]["HwndSource_Window"]["Window"]["DockPanel"]["MainRegionItemsControl"]["RadDockHomeView"]["DockPanel"]["docking"]["RadSplitContainer"]["MainSplitContainer"]["DockingRadPaneGroup"]["Grid"]["Grid"]["ScrollViewer"]["RadCaseGridView"]["GridViewRow"]["GridViewCell"]["RadComboBox"]["Keys"]("[Down]");


  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    I'm not sure I understand the question.  You mentioned above that there's an exception you're getting.  What is the exception text?



    As for looping the Keys command, you're already doing that according to the code you posted.  What are you looking for that is different than what is is in that code?


  • Hi,



    Now I found the solution, I metioned the data type as string. Now I changed to Integer and for loop working as expected.