1 Reply Latest reply: Oct 31, 2012 10:23 AM by Jamie_Lockhart RSS

    OpenScript: How do you test for object/text existance programmatically?

    user735170-Oracle
      Hi, All;

      I hope someone can help me; kind of new to OATS. I can’t figure out how to test for object/text existence and return results back to the script. There are methods for verifying text and objects; i.e.

      Web.verifyText
      Web.assertText

      These methods just report pass or fail to the test. I need to get the data back programmatically so I can use it logically. I know you can do this pretty easily in Selenium and QTP so there must be a way in OATS.

      Thanks,
      Eric
        • 1. Re: OpenScript: How do you test for object/text existance programmatically?
          Jamie_Lockhart
          Hi Eric,

          You can use the Object Explorer to find the xpath of the object you are interested and check for its existence, and then grab some attribute of that object for use elsewhere.

          if (web.element(6,"/web:window[@index='0' or @title='Software and Services - SCL']/web:document[@index='0']/web:span[@text='Services' or @index='14']")
                                   .exists()){
                    System.out.println("OBJECT EXISTS");
          // get an attribute of object here ,e.g
          String myval = web.element(41,"/web:window[@index='0' or @title='Software and Services - SCL']/web:document[@index='0']/web::span[@text='Services' or @index='14'].getAttribute("innerText");
          // use myval elsewhere
                         }
          Hope it helps.

          Jamie