NightWatch - 找不到具有xpath定位器的元素,其值为

NightWatch - 找不到具有xpath定位器的元素,其值为

问题描述:

随着守夜,我有问题在我的页面上查找元素,XPATH很好,因为我已经使用FirePath找到了它。NightWatch - 找不到具有xpath定位器的元素,其值为

我的页面代码:

<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毫秒内可见时超时。 - expec 特德“可见”但得到:“不可见”

你有没有同样的问题?

+1

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

+0

元素在页面中较低。 –

我有几个问题要问 1 waitForElementVisible代码

  1. 当你给firepath

  2. 中的XPath多少元素返回的元素在页面上可见或需要滚动?

开始=>
+0

你好,其实1个元素出现。但我似乎在滚动.. –

@ Ratnadip,

它通过XPATH返回1个元件。 但我认为你有权就滚动,因为我的元素是在页面下部..

我尝试了一些这样想:

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

,但它不工作。

谢谢