Forum Discussion

SS01's avatar
SS01
Occasional Contributor
2 years ago

TestComplete verify existence of some html tag on a webpage

Is there an inbuilt method to verify if a particular html tag exists on a page and its count using java script, example code would help.

7 Replies

  • SS01's avatar
    SS01
    Occasional Contributor
    I want to check if alt tag is visible on the page, what method should be used?
    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Hi,

       

      I want to check if alt tag is visible on the page

      Unfortunately, there is no uniform way to do this and the answer is completely specific to your tested application.

      The case is that there are a lot of tricks that can be used to make web element to be invisible on web page. For example, element can be set as hidden, or with width or/and height set to zero, or overlapped by some other element. In addition, web element can be hidden by its parent element (i.e. while all properties of web element tell that the element should be visible, element is effectively invisible because some of its parents is set to be hidden). And vise versa - all parent elements can be invisible but the element itself can be explicitly made visible. CSS styling and transformations.

      To add on top of the above, modern web applications with as little attention paid to their design as possible, can combine all those techniques within one page. I.e. one element can be no visible because of width set to zero, while another element on the same page can be hidden because its parent is not visible.

       

      So the answer to your question would be: investigate your tested application using Object Browser, talk to your developers and find out the verification approach that will work in your given case.

       

      • SS01's avatar
        SS01
        Occasional Contributor

        Thanks AlexKaras for a well thought response. I checked with the developers, there are no hidden elements on the page. All images load successfully in a happy path scenario and all have alt tags. If you can suggest something along these lines or otherwise it would be very helpful. Thanks