【发布时间】:2013-12-05 17:11:33
【问题描述】:
如何在 Intern 功能测试中存储一个元素的值以用于查找其他元素?
比如我有如下测试sn-p:
var mainItem = "Menu 1";
var subItem = "Sub Menu 1";
var mainItemId = "";
return this.remote
.elementByXPath("//*[contains(text(),'" + mainItem + "')]/ancestor::*[@dojoattachpoint='focusNode']")
.getAttribute("id")
.then(function(id){ mainItemId = id; })
.clickElement()
.end()
.wait(500)
.then(function(){ console.log(mainItemId); })
.elementByXPath("//*[contains(text(),'" + subItem + "')][ancestor::*[@dijitpopupparent='" + mainItemId + "']]")
.clickElement()
.end()
基本上,当我运行测试时,mainItemId 值将正确记录,但第二个 elementByXPath 将找不到。如果我用相同的值初始化mainItemId,xpath 就可以工作。根据我所看到的,好像mainItemId 只会将值存储在.then() 上下文中。
谢谢。
【问题讨论】:
标签: intern