【发布时间】:2017-07-18 15:28:43
【问题描述】:
我正在尝试通过以下方式单击一个元素,但收到错误消息:
Failed: Cannot read property 'click' of undefined
代码:
'use strict;'
var PresentPage = function(){
let PresentPageTitle = element(by.xpath("//*[@id='planAndDev']/div/div/div/div/matanot/form/div[2]/h4"));
let UserPhone = element(by.id("tel"));
let Email = element(by.id("email"));
var AresForPresents = element(by.xpath("//*[@id='verticalRadioGrp']/div/select")).all(by.tagName("option")).then(function(options)
{
return options;
});
this.SelectAreaToGetPresent = function()
{
AresForPresents[3].click();
};
};
module.exports = new PresentPage();
编辑: 在函数中使用它时可以正常工作。
this.SelectAreaToGetPresent = function()
{
element(by.xpath("//*[@id='verticalRadioGrp']/div/select")).all(by.tagName("option")).then(function(options)
{
options[3].click();
});
【问题讨论】:
-
可能是您有错字并正在寻找
AreasForPresents[3](即缺少a)? -
你能发布这个运行的文档(html)吗?
-
@Garr Godfrey 很遗憾不是,因为它是一个公共组织。
标签: javascript selenium protractor