I am using Nightwatch-cucumber and page objects and I am struggling to get the locators to find my element via Xpath.
element looks like this:
<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>
My step contains this code:
var anonbrowse = this.page.anonbrowse();
anonbrowse
.waitForElementVisible('@cover_images_ironman',5000)
.click('@cover_images_ironman')
And the Pageobject looks like this:
module.exports = {
elements: {
cover_images_ironman: {
selector : '//div[contains(@style,"http://path/to/img/Ironman.jpeg")]',
locateStrategy: "xpath"
},
}
}
I keep getting a timeout error not matter how long I leave the wait:
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)
Anyone got any ideas what I am doing wrong here?
try locator like this:
i could make misatke somewhere with "" or ''