nightwatch
nightwatch copied to clipboard
.getLocationInView() is returning 'unknown command: Cannot call non W3C standard command while in W3C mode'
Describe the bug
When calling getLocationInView()
in W3C mode it returns 'unknown command: Cannot call non W3C standard command while in W3C mode'
Sample test
Details in https://discord.com/channels/618399631038218240/935468415731253258/950846771926564905
Verbose output
debug.log
<!-- Include the verbose output, if possible (run nightwatch with `--verbose` argument) -->
Configuration
nightwatch.json
{
"your": { "config": "here" }
}
Your Environment
Executable | Version |
---|---|
nightwatch --version |
VERSION |
npm --version |
VERSION |
yarn --version |
VERSION |
node --version |
VERSION |
Browser driver | Version |
---|---|
NAME | VERSION |
OS | Version |
---|---|
NAME | VERSION |
await this.getLocationInView('@addButton');
Verbose Output:
→ Running command: getLocationInView ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement, abortOnFailure, suppressNotFoundErrors, timeout...}, [Function])
Request POST /session/c714f1d2e2856573017956a2a7a4fccd/elements
{ using: 'css selector', value: '[test-id="addButton"]' }
Response 200 POST /session/c714f1d2e2856573017956a2a7a4fccd/elements (10ms)
{
value: [
{
'element-6066-11e4-a52e-4f735466cecf': '902f2b33-df72-49e2-9eaa-3b3834b10afd'
}
]
}
Request GET /session/c714f1d2e2856573017956a2a7a4fccd/element/902f2b33-df72-49e2-9eaa-3b3834b10afd/location_in_view
Response 404 GET /session/c714f1d2e2856573017956a2a7a4fccd/element/902f2b33-df72-49e2-9eaa-3b3834b10afd/location_in_view (1ms)
{
value: {
error: 'unknown command',
message: 'unknown command: Cannot call non W3C standard command while in W3C mode',
stacktrace: ''
}
}
Configuration:
'chrome': {
desiredCapabilities : {
'browserName' : 'chrome',
'goog:chromeOptions' : {
w3c: true,
args: [
// '--no-sandbox',
// '--ignore-certificate-errors',
// '--allow-insecure-localhost',
// '--headless'
]
}
},
This is due to using a non-w3c command in w3c mode. getLocationInView
is marked as deprecated. Either we can set w3c:false
in config and use this command or instead try using getElementRect
.
Let's see about deprecating this. It's not coming up often and can be replaced with executeScript
or using getElementRect
Hello, we're using this command (in nightwatch 1.7) to ensure clicking on an anchor does lead to the right position, and getElementRect only returns absolute position within the page, not relative to current viewport.
I believe when you advise to use executeScript
, you mean something along the lines return document.querySelector(selector).getBoundingClientRect();
? How can I use it with a selector param from a page elements definition ?