8 Replies Latest reply: Aug 5, 2013 12:49 AM by Deepu Muraleedharan RSS

    How to add control statments in openscript and with condition

    Ashish_Inda_99


      We want that script should take data from excel and then run next script and again take data from excel; till excel data ends.

      Ashish

        • 1. Re: How to add control statments in openscript and with condition
          Deepu Muraleedharan

          If you want to use csv, you can use DataBank or Table.

           

          If you want to use excel, use datatable or you have to use some packages like apache 'poi'

           

          Using Datatable:

           

           

          
          datatable.importExcel("C:/Book1.xls", true);
                
                  for(int i=0; i< datatable.getRowCount(); i++){
                  info("Line "+i);  
                  info(    datatable.getValue(i, "asd").toString());
                  info(    datatable.getValue(i, "aaa").toString());
                  }
          
          

           

          AB
          1asdaaa
          2a1b1
          3a2b2
          4a3b3
          5a4b4
          6a5b5

           

          Cheers,

          Deepu M

          • 2. Re: How to add control statments in openscript and with condition
            Deepu Muraleedharan

            Code you want to iterate must be given inside for() loop which mentioned above

            • 3. Re: How to add control statments in openscript and with condition
              Ashish_Inda_99

              hi deepu,

              thanks for your reply .But what i am doing is customizing standard scripts...for eg take the script for item creation...its creating a single item and if we parameterize the item name from csv file...what ats is doing its creating one item then logging out n then again creating the next item....the itteration is not happening at that particular window ...its undergoing a full loop.....

              • 4. Re: How to add control statments in openscript and with condition
                Deepu Muraleedharan

                you have move common sections to initialize() and finish()  sections, ie.

                 

                Move login and navigations( upto item creations) to initialize()  section

                give iteration codes in run()

                In finish section mention logout and closing application

                • 5. Re: How to add control statments in openscript and with condition
                  Ashish_Inda_99

                  deepu,

                  we have made a login script. the values which you are passing are the values in the excel sheet . But do we need to pass the values , because the values shoud be picked from the excel sheet only.

                  our code is:

                   

                  void run() throws Exception {


                  "C:\Users\AI5009353\Desktop\Test.xls", true); 



                  for(int i=0; i< datatable.getRowCount(); i++){ 


                  "Line "+i);   


                  "KD34209").toString()); 


                  "123").toString()); 

                  }


                  • 7. Re: How to add control statments in openscript and with condition
                    Ashish_Inda_99

                    Look we are making simple script of login to EBS and log out as per logic u hv given.

                    So the script is in Initialize: We Launch Browser in Run: We want script to work as per your logic that first it will take user name 1 and password 1 and do login then as per script it will logout. Then it will take second value from excel name 2 and password 2 and login agn run next script and logout so on till excel data. So how the script will be for that then.

                    • 8. Re: How to add control statments in openscript and with condition
                      Deepu Muraleedharan
                      public void initialize()
                      {
                      borwser.launch();
                      }
                      public void run()
                      {
                      
                      getDatabank("dbAlias").getNextDatabankRecord();
                      for(int iteration = 0; iteration<getDatabank("dbAlias").getDatabankRecordCount(); iteration++){
                      
                      {
                      
                        beginStep("[1] Login);
                        {
                      
                        web  .textBox(
                        "/web:window[@index='0' or @title='Login']/web:document[@index='0']/web:form[@id='DefaultFormName' or @name='DefaultFormName' or @index='0']/web:input_text[@id='usernameField' or @name='usernameField']")
                        .setText("{{db.dbAlias.ColumnUserName}}");
                        {
                        think(0.187);
                        }
                        web  .textBox(
                        "/web:window[@index='0' or @title='Login']/web:document[@index='0']/web:form[@id='DefaultFormName' or @name='DefaultFormName' or @index='0']/web:input_password[@id='passwordField' or @name='passwordField']")
                        .setPassword("{{db.dbAlias.ColumnPasswordName}}");
                        {
                        think(0.171);
                        }
                        web  .button(
                        "/web:window[@index='0' or @title='Login']/web:document[@index='0']/web:form[@id='DefaultFormName' or @name='DefaultFormName' or @index='0']/web:button[@id='SubmitButton' or @value='Login']")
                        .click();
                        {
                        think(0.171);
                        }
                        web  .window("/web:window[@index='0' or @title='Oracle Applications Home Page']")
                        .waitForPage(null);
                        {
                        think(5.593);
                        }
                      
                      
                      Thread.sleep(3000);
                      
                      
                      web  .link(
                        "/web:window[@index='0' or @title='Notifications']/web:document[@index='0']/web:a[@text='Logout']")
                        .click();
                        }
                        endStep();
                        beginStep("[2] Login);
                        {
                        web.window( "/web:window[@index='0' or @title='Login']")
                        .waitForPage(null);
                        {
                        think(2.312);
                        }
                        }
                        endStep();
                      
                      }
                      
                      }
                      
                      public void finish()
                      
                      {
                      browser.close();
                      }
                      
                      
                      
                      

                       

                      You can also use iteration functionality provided in Openscript

                       

                      Cheers,

                      Deepu M