私はNightwatch-cucumberとpageオブジェクトを使用しています。私はXpath経由で自分の要素を見つけるためにロケータを取得するのに苦労しています。NightwatchJS +キュウリはxPath経由で見つけることができません
<div class="portal-layout-section" style="width: 1215px; height: 730px; overflow: hidden;">
<div class="item bordered portal-hoverable" style="width: 243px; height: 365px; background-image: url(http://path/to/img/Ironman.jpeg;);"></div>
<div class="item bordered portal-hoverable" style="width: 243px; height: 365px; background-image: url(http://path/to/img/FriendsWithBenefits.jpeg);"></div>
<div class="item bordered portal-hoverable" style="width: 243px; height: 365px; background-image: url(http://path/to/img/Inception.jpeg);"></div></div>
</div>
私のステップは、このコードが含まれます:
要素は、次のようになります
var anonbrowse = this.page.anonbrowse();
anonbrowse
.waitForElementVisible('@cover_images_ironman',5000)
.click('@cover_images_ironman')
をとPageオブジェクトは、次のようになります
module.exports = {
elements: {
cover_images_ironman: {
selector : '//div[contains(@style,"http://path/to/img/Ironman.jpeg")]',
locateStrategy: "xpath"
},
}
}
私はタイムアウトエラーがない得続けますどのくらい私が待つままにしておきますか:
Timed out while waiting for element <//div[contains(@style,"http://path/to/img//Ironman.jpeg")]> to be present for 5000 milliseconds. - Expected "visible" but got: "not found"
at Object.<anonymous> (c:\nightwatxh\features\step_definitions\anonbrowse_steps.js:21:3)
at next (native)
at next (native)
誰でも私がここで間違っていることを知りましたか?このような
が//div[contains(@style,"Ironman.jpeg'にそれを簡素化してい '' または "" でどこかmisatkeを作ることができます) ] '何か違いはありますか?ありがとう。 – alecxe
ありがとう、ちょうどそれを試み、まだ運がない。私はクロムプラグイン 'xpathヘルパー'で使用しているxpathを試してきました。右の要素を強調表示していますので、xpathが正しいことが分かります。 – spidee76