Forum Discussion

Capricornus's avatar
Capricornus
Contributor
3 years ago
Solved

Error log despite try... catch operation

Hi everybody,

maybe somebody can help me with my issue: Despite of using a try... catch... operation I get an error logged when the try operation fails:

    try {
      adobeReader.dlgPrint.cmbPrinter.ClickItem("Microsoft Print To PDF"); 
    } catch (ex) {
      adobeReader.dlgPrint.cmbPrinter.ClickItem("Amyuni PDF Suite"); 
    }

The item "Microsoft Print To PDF" does not exist and so TC should select "Amyuni PDF Suite". It has worked previously; one thing I remember I have changed was to add an event handler for log warnings (not errors). Could it depend on this?

 

Thanks in advance 🙂

 


  • mattb wrote:

    Hi,

    Myself personally I like to use if else statements to look if a object is visible on screen or not, and then continue. 

    If object is invisible refresh the browser code:

     

    function IfObjectInvisible()
    {
    if(!Project.Variables.PageObject.VisibleOnScreen){
    Aliases.browser.Refresh() rapidfs account

    }
    else{
    return true;
    }
    }

    If Object is visible, continue, else refresh the browser

     

    function IfObjectVisible()
    {
    if(Project.Variables.PageObject.VisibleOnScreen){
    return true;
    }
    else{
    Aliases.browser.Refresh()

    }
    }





    I dont know if its a great idea to add an event for ignoring errors. If you were going to, I would recommend adding that within the logic itself, not an event for every error. 


    Thanks for the update. I'll be sure to keep an eye on this thread.

4 Replies

  • Hi,

    Myself personally I like to use if else statements to look if a object is visible on screen or not, and then continue. 

    If object is invisible refresh the browser code:

     

    function IfObjectInvisible()
    {
    if(!Project.Variables.PageObject.VisibleOnScreen){
    Aliases.browser.Refresh()
    }
    else{
    return true;
    }
    }

    If Object is visible, continue, else refresh the browser

     

    function IfObjectVisible()
    {
    if(Project.Variables.PageObject.VisibleOnScreen){
    return true;
    }
    else{
    Aliases.browser.Refresh()

    }
    }





    I dont know if its a great idea to add an event for ignoring errors. If you were going to, I would recommend adding that within the logic itself, not an event for every error. 

      • Capricornus's avatar
        Capricornus
        Contributor

        Hi Sonya,

        that's a workaround that I can use but the problem itself is not solved this way: If an error handler for warnings is defined, try --- catch does not work as it should.

    • Carl9577's avatar
      Carl9577
      Occasional Visitor

      mattb wrote:

      Hi,

      Myself personally I like to use if else statements to look if a object is visible on screen or not, and then continue. 

      If object is invisible refresh the browser code:

       

      function IfObjectInvisible()
      {
      if(!Project.Variables.PageObject.VisibleOnScreen){
      Aliases.browser.Refresh() rapidfs account

      }
      else{
      return true;
      }
      }

      If Object is visible, continue, else refresh the browser

       

      function IfObjectVisible()
      {
      if(Project.Variables.PageObject.VisibleOnScreen){
      return true;
      }
      else{
      Aliases.browser.Refresh()

      }
      }





      I dont know if its a great idea to add an event for ignoring errors. If you were going to, I would recommend adding that within the logic itself, not an event for every error. 


      Thanks for the update. I'll be sure to keep an eye on this thread.