Yu Zhang
Yu Zhang

Reputation: 2149

The specified object is not indexable

From the example given on smartbear's official website,

# The following routine checks the width and height attributes of
# IMG elements located on a web page.

def Test():
    # Obtains the page object
    url = "****";
    Browsers.Item[btChrome].Run(url);
    page = Sys.Browser("*").Page("*");

    # Obtains the page's images
    images = page.contentDocument.images;
    Log.Message(images.length)

    for img in images:    # <<<<<<<This is the error
        # other calculating stuff

When I executed this code snippet in testcomplete, I got an error,

Log.Message(images.length) gives me a result of 9, which is expected.

I also attempted to get the type, Log.Message(type(images)) gives me a blank output.

Any suggestions?

Upvotes: 1

Views: 1069

Answers (1)

Dmitry Nikolaev
Dmitry Nikolaev

Reputation: 3918

Working with this images array as with an indexable collection is not supported at the moment. The sample you refer on the official website has different code:

for i in range (0, images.length-1):

Upvotes: 2

Related Questions