6 Replies Latest reply: Aug 14, 2013 4:18 AM by Deepu Muraleedharan RSS

    Capturing various standard errors using openscript

    999711

      Hi , we have automized a scenario using openscript where in the steps are like starting from creating requistion --> Req approval --> PO creation and approval --> Receipt Creation --> Invoice Creation and then quick payment.

       

      when we playback the script it works fine with valid data inputs from databank. But we want to capture all the standard errors if any occurs in between when script playback. For eg : if Invoice batch name entered already exists in system it throws a warning like name already exists. At this step scripts fails but it capturing some error which end user wont understand. By anyway we can capture all the standard errors that can occur during functional testing. I mean we cannot write custom exception for each situation and may not what kind of errors we may face. So is there any way we can capture all the standard errors during functional testing using openscript/OTM. The platform we are using is Oracle Applicaitions ERP R12, open script 12.2

        • 1. Re: Capturing various standard errors using openscript
          Deepu Muraleedharan

          Enter your codes in try and mention code like following in catch


          
          try{ }
          catch(Exception e ) {
          
          String pageindex = web.getFocusedWindow().getAttribute("index");
                      
                      if(web.element("/web:window[@index='"+pageindex+"']/web:document[@index='"+pageindex+"']/web:div[@text='Error']").exists()){
                      fail(web.element("/web:window[@index='"+pageindex+"']/web:document[@index='"+pageindex+"']/web:div[@text='Error' ]").getParent().getAttribute("text"));
                  
                  
                  }
                      
                      
                      else if(web.element("/web:window[@title='Oracle Applications R12']").exists()){
                      
                          forms.captureScreenshot();
                          {
                              think(2.169);
                          }
                          
                                  
                      String statusBarMessage = "";
                      if(! forms.getStatusBarMessage().equalsIgnoreCase("")){
                          statusBarMessage =""+forms.getStatusBarMessage().toString();
                          
                          }
                      if (forms.choiceBox("//forms:choiceBox").exists()) {
                          
                          fail(" Unexpected choicebox found:- "+forms.choiceBox("//forms:choiceBox").getAlertMessage()+ (!statusBarMessage.trim().equals("") ? (".... \t Statusbar message: "+statusBarMessage) : ""));
                      } else if (forms.alertDialog("//forms:alertDialog").exists()) {
                          
                          fail(" Unexpected alertbox found:- "+forms.alertDialog("//forms:alertDialog").getAlertMessage()+ (!statusBarMessage.trim().equals("") ? (".... \t Statusbar message: "+statusBarMessage) : ""));
                      } else {
                          
                          fail(" Failed during script playback : " + e.getMessage()+(!statusBarMessage.trim().equals("") ? (".... \t Statusbar message: "+statusBarMessage) : ""));
                      }
                  }
                  else {
                      
                      fail("   Failed during script playback : " + e.getMessage());
                  }
          }
          

           

          Cheers,

          Deepu M

          deepu.murali45@yahoo.co.in

          • 2. Re: Capturing various standard errors using openscript
            Deepu Muraleedharan

            Create a function and place this code inside it.

            So you can call that function in all scripts

            Say example- create a function named catchFunction(Exception e)

             

            try{

            }

            catch(Exception e){

             

            catchFunction(e);

             

            }

            • 3. Re: Capturing various standard errors using openscript
              999711

              This is fine for where we can capture errors. but for negative testing its not working. for example the expected result is "The script is will create some invoce with name AAAA and in its first run its created AAAA and script passed. In second run it should give the error message like AAAA already exists but final result of the test case should be in "Pass" status. please suggest. I tried verifyText instead of AssertText but still script is going to be failed mode

              • 4. Re: Capturing various standard errors using openscript
                Deepu Muraleedharan

                My understand is:

                you have a web page and you want do a negative testing...

                after transaction web page will show a error message - Error: AAAA already exists

                 

                Then try with following:

                 

                if (web.element(

                            "/web:window[@index='0']/web:document[@index='0']/web:div[@text='"Error"']").exists() == false)

                 

                        {

                            reportFailure("No error message found" );

                            if (web.element(

                                "/web:window[@index='0']/web:document[@index='0']/web:div[@text='Confirmation']").exists()) {

                                reportFailure(web.element(

                                    "/web:window[@index='0']/web:document[@index='0']/web:div[@text='Confirmation']").getParent().getAttribute(

                                    "text"));

                               

                            }

                        } else {

                 

                           

                            info("Error message found");

                            info(web.element(

                                "/web:window[@index='0']/web:document[@index='0']/web:div[@text='Error']").getParent().getAttribute(

                                "text").toString());

                        }

                 

                 

                Cheers,

                Deepu M

                deepu.murali45@yahoo.co.in

                • 5. Re: Capturing various standard errors using openscript
                  999711

                  No Deepu,

                  In our case "Error: AAAA already exists" we should be able to capture this error message and as well we want to show final status of the test script as Passed.

                  with the above first options above works for capturing all the errors and script will be in failed mode. that is correct. but for this negative tests the expected result is we should show error  so final status of error should be passed. we tried code provided by you, still it shows final status of test case as failed.

                  • 6. Re: Capturing various standard errors using openscript
                    Deepu Muraleedharan

                    paste your failure message here