【问题标题】:NightWatch - unable to find element with xpath locator on an input with valueNightWatch - 无法在具有值的输入上找到带有 xpath 定位器的元素
【发布时间】:2018-04-01 10:26:56
【问题描述】:

使用 nightwatch,我在页面上查找元素时遇到问题,XPATH 很好,因为我使用 FirePath 找到了它。

我的页面代码:

<label class="switch " data-ng-repeat="item in values">
<input class="ng-pristine ng-untouched ng-invalid ng-invalid-required" 
name="obtentionPermisConduiteAccompagneeSwitcher" value="N" ng-
model="$parent.model" ng-required="!$parent.model" required="required" 
type="radio"/>

......

我的选择器:

input_conduiteAccompagnee: {
selector: './/input[@name="obtentionPermisConduiteAccompagneeSwitcher" and @value="N"]',
locateStrategy: 'xpath'
},

我的命令:

//conduite accompagnee
onglet_conducteur.waitForElementVisible('@input_conduiteAccompagnee', 
10000);
onglet_conducteur.click('@input_conduiteAccompagnee');
browser.pause(3000);

但我有消息:

× 等待元素可见 10000 毫秒时超时。 - 期待 ted“可见”但得到:“不可见”

你有没有同样的问题?

【问题讨论】:

  • 查看您的测试脚本代码可能会有所帮助。当您观看测试运行时,该项目是否真的可见?也许你需要先真正滚动到它(我偶尔会遇到需要强制滚动到元素的情况)
  • 元素在页面下方。

标签: node.js selenium xpath nightwatch.js


【解决方案1】:

@拉特纳迪普,

它通过 XPATH 返回 1 个元素。 但我认为你对滚动是正确的,因为我的元素在页面中较低..

我尝试了一些类似的想法:

onglet_conducteur.getLocationInView('@select_conduiteAccompagnee', 
function(result) {
this.execute('scrollTo(result.value.x, result.value.y)');
this.execute('scrollIntoView');
});

但它不起作用。

谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-05
    • 1970-01-01
    • 1970-01-01
    • 2019-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-16
    相关资源
    最近更新 更多