protractor - 作为 E/启动器出现错误 - 错误:TypeError:无法读取未定义的属性“0”
问题描述
执行此代码时出现以下错误-
E/启动器 - 错误:TypeError:无法读取未定义的属性“0”
需要您的帮助来解决 Protractor 版本 5.4.3 中的此问题
let objectLocator = function(){
var webElement = null;
//find locator using provided locator type and locator value
this.findLocator = function (locator, value) {
var locatorType = locator[0];
var locatorValue = locator[1];
if (typeof locatorType !== 'undefined') {
if (locatorValue.includes('#REPLACE#')) {
locatorValue = locatorValue.replace('#REPLACE#', value);
}
if (locatorType == 'id') {
if (locatorValue !== 'undefined') {
this.webElement = element(by.id(locatorValue));
}
} else if (locatorType == 'name') {
if (locatorValue !== 'undefined') {
this.webElement = element(by.name(locatorValue));
}
} else if (locatorType == 'xpath') {
if (locatorValue !== 'undefined') {
this.webElement = element(by.xpath(locatorValue));
}
} else if (locatorType == 'css') {
if (locatorValue !== 'undefined') {
this.webElement = element(by.css(locatorValue));
}
}
}
return this.webElement;
};
};
module.exports = new objectLocator();
解决方案
推荐阅读
- c# - 如何更改 ListView 中的选定项属性
- java - Variable seems to change its type in one line without reason. AnyLogic SelectOutput not working correctly types not working correctly
- algorithm - 计数排序的下限为 O(n)
- c - 从 uint16_t 转换为 int32_t 需要中间转换为 int16_t
- java - Android Studio Java 位图工厂返回 null
- c# - 无法从实现它的子类中读取接口属性?
- java - 每次按下(单击)Jbutton 时如何在现有按钮组中创建一个新的 JButton 实例
- java - 当 @Around 用于 Spring AOP 时,不会检索数据
- python - 仅当代码在 Python 3.8 中使用 Selenium 在页面上找到某个单词时,如何才能启动代码序列?
- r - 当需要在主中进行对数转换时绘制辅助 Y 轴