---
title: nightwatch test code
tags: v1
---
```javascript=
ck one product for the detail$/, () => {
const selector = '.artwork-card:first-child a';
/*
const dom = client
.findElement('.js-link', function (result) {
console.log('result', result);
})
.assert.elementPresent('.js-link')
.assert.elementPresent('a[class=".js-link"]:nth-child(1)');
dom.click(
'css selector',
'a[class=".js-link"]:nth-child(1)',
function (result) {
console.log('Click result', result);
}
);
*/
js-link
const dom = client
.waitForElementVisible('a[name="nav-link"]', 5000)
.findElements('.js-link', function (result) {
console.log('findElement 1 length', result.value.length);
console.log('findElement 1 value', result.value);
})
.assert.elementPresent('.js-link')
.assert.elementPresent('a[class="js-link"]')
.elements('css selector', 'a[class="js-link"]', function (result) {
console.log('findElement 2 length', result.value.length);
console.log('findElement 2 value', result.value);
})
.elements('css selector', 'a[class="nav-link"]', function (result) {
console.log('findElement nav length', result.value.length);
console.log('findElement nav value', result.value);
})
.elements('xpath', '//*[contains(@class, "js-link")])', function (result) {
console.log('findElement xpath length', result.value.length);
console.log('findElement xpath value', result.value);
})
.click('xpath', '//*[contains(@class, "js-link")])[1]', function (result) {
console.log('clicked', result.value);
})
.waitForElementVisible('a[name="xxxxx"]', 10000);
.assert.elementPresent('a[class="nav-link"]')
.assert.elementPresent('a[class="nav-link"]:nth-child(2)');
return dom;
return client
.findElement('.js-link', function (result) {
console.log('findElement 2', result);
})
.assert.elementPresent('.js-link')
.elements('css selector', 'a[class="js-link"]', function (result) {
console.log('x length', result.value.length);
console.log('x value', result.value);
});
const dom = client
.waitForElementVisible(selector, 5000)
.moveToElement(selector, 50, 50);
console.log('dom', dom.getLocation());
return dom.click(selector);
/*
return client.useCss().waitForElementVisible('.js-link', 5000).click({
selector: '.js-link',
index: 1,
suppressNotFoundErrors: true,
});
*/
});
Then(/^I can see the detail of the product$/, () => {
return client
.waitForElementVisible('.artwork-info-container', 10000)
.assert.visible('.intro-block');
});
```