This discussion is archived
2 Replies Latest reply: May 15, 2012 10:52 PM by 910924 RSS

issue with web.element("").exist method

910924 Newbie
Currently Being Moderated
Hi,

whenever i use web.element().exist method ,if the element is present it will work and if the element is not present
the script stop execution and fails.

i have a situation where i need to check the element is not present andthe script should proceed with out fail

Can some one advice on this

Regards
Sridhar
  • 1. Re: issue with web.element("").exist method
    834498 Journeyer
    Currently Being Moderated
    Hello
    Different methods exist to solve your problem.

    1/ Use a try / catch java code
    for example:
              try {
                   if(forms.textField("//forms:textField[(@name='FOLDER_SHOW_BATCH_STATUS_0')]").getAttribute("text").equals("")== true){
                        return false;
                   }else{
                        forms.textField(228,
                             "//forms:textField[(@name='FOLDER_SHOW_BATCH_STATUS_"+x+"')]")
                             .setFocus();
                        {
    think(1.5);
    }
    /*
    *
    If you need to capture the value inside the textField then you could use something like the following and determine  steps from it.
    *
    */

    //forms.textField(228,
                             "//forms:textField[(@name='FOLDER_SHOW_BATCH_STATUS_"+x+"')]")
                             .getAttribute("text");
    {
    think(1.5);
    }
                        forms.button(229,
                        "//forms:button[(@name='CONTROL_REVIEW_HEADER_0')]")
                        .click();
                        return true;
                   }

              } catch (AbstractScriptException e) {
                   System.out.println("Problem selecting Journal");
                   e.printStackTrace();
              }
              return false;
         }


    2/ You can change the error recovery default action (in OpenScript -> View -> Preferences -> Playback -> Error Recovery)
    This is something you can do from the code just before the statement that should thraw an error an change it back to the previous value after.
    // something like that: change ERR_FILE_NOT_FOUND by the correct one
    setErrorRecovery(BasicErrorRecovery.ERR_FILE_NOT_FOUND, ErrorRecoveryAction.Ignore);


    JB
  • 2. Re: issue with web.element("").exist method
    910924 Newbie
    Currently Being Moderated
    Thanks a lot.I will check

    Regards
    Sridhar

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points