During the course of execution, I encountered an issue with linking locators using the @ symbol from elements.
An error occurred: Could not find element: "@queryInput" using: xpath
Here is the code snippet:
import * as config from 'config';
import { NightWatchClient, PageObject } from 'nightwatch';
const pageConfig = config.get<IPageConfig>('pages.google');
const page: PageObject = {
url: pageConfig.url,
elements: {
queryInput: {
selector: '//input[@name="q"]',
locateStrategy: 'xpath'
}
},
commands: [
{
enterQuery: (client: NightWatchClient, query: string) => {
return client
.waitForElementVisible('//input[@name="q"]', 5000)
//.setValue('//input[@name="q"]', [query, client.Keys.ENTER])
.setValue('@queryInput', [query, client.Keys.ENTER])
.waitForElementVisible('//*[@id="res"]', 5000);
},
},
]
};
export = page;
For the complete code, you can visit this link
If you are interested in checking out the specific file, you can click on this link