1

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,

  • RuntimeError The specified object is not indexable.

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?

4
  • 1
    I think you should at least provide a complete traceback to get help. Commented Nov 27, 2017 at 3:38
  • @Sraw, testcomplete does not provide as much traceback, RuntimeError The specified object is not indexable is all of it. Commented Nov 27, 2017 at 3:58
  • 1
    @YuZhang maybe you can iterate over it with a list comprehension Commented Nov 27, 2017 at 4:05
  • @AluanHaddad, thanks will take a look Commented Nov 27, 2017 at 5:51

1 Answer 1

2

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):
Sign up to request clarification or add additional context in comments.

2 Comments

yeah, I tried this one, did not work either. I modified then posted my code. It is so strange that they claimed that it should work but unsupported in fact.
Hm. Support of this functionality never was claimed. I think you are confused with another script example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.