指定的对象不可索引

时间:2017-11-27 02:48:53

标签: python testcomplete

从smartbear官方网站上的例子中可以看出

# 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

当我在testcomplete中执行此代码段时,出现错误,

  • RuntimeError 指定的对象不可索引。

Log.Message(images.length)给出了9的结果,这是预期的。

我也尝试获取类型,Log.Message(type(images))给我一个空白输出。

有什么建议吗?

1 个答案:

答案 0 :(得分:3)

目前不支持使用此图像数组和可索引集合。您在official website上引用的示例具有不同的代码:

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