CodeceptJS
CodeceptJS copied to clipboard
Nested locator with first()
What are you trying to achieve?
Get first element with attr tid="device" inside block with attr tid="requesting-devices-list", using following selector: locate("[tid=requesting-devices-list] [tid=device]").first()
- (also i tried to use: locate({tid: 'device'}).inside({tid: 'requesting-devices-list'}).first() , cause i have custom selector "tid=..." in config)
What do you get instead?
Error:
XPath with round brackets is not possible here! May be a nested locator with at() last() or first() causes this error.
locate("[tid=requesting-devices-list] [tid=device]").first()
Details
- CodeceptJS version: 2.3.6.
- NodeJS Version: 12.1.0
- Operating System: Windows
- puppeteer 2.0.0
- Configuration file:
exports.config = {
tests: './testing/tests/*_test.js',
output: './testing/output',
helpers: {
Puppeteer: {
url: 'https://localhost:4204',
show: true,
restart: false,
waitForNavigation: ["domcontentloaded", "networkidle2"]
},
MockRequest: {},
},
include: {
I: './testing/steps_file.js',
deviceManagerPage: './testing/pages/DeviceManagerPagePo.js',
},
bootstrap: function (done) {
codeceptjs.locator.addFilter((providedLocator, locatorObj) => {
if (providedLocator.tid) {
locatorObj.type = 'css';
locatorObj.value = `*[tid="${providedLocator.tid}"]`;
}
});
done();
},
mocha: {},
name: 'TestApp',
translation: 'ru-RU'
};
This would be really useful to support nested locators
agreed. I try go generate .//tr[position()=1]/td/button[class="button"] and got this error
Closed for now! Feel free to reopen if you still encounter the issue with latest version and would be nice to provide a sample code to reproduce the issue.