What i want to achieve is to target element inside google maps iframe
Here is my code
'Demo Frames' : function (client) {
client.url(url)
.waitForElementVisible("#mapFrame",60000)
.frame('mapFrame')
.pause(2000)
.click('.navigate-link')
.pause(9000)
.end();
Here is the output
Running: Maps
√ Element <#mapFrame> was visible after 62 milliseconds.
*Error while running .switchToFrame() protocol action: data did not match any variant of untagged enum FrameId at line 1 column 17*
Error while running .locateSingleElement() protocol action: Unable to locate element: .navigate-link
OK. 1 assertions passed. (15.171s)
Here is my package.json :
{
"name": "Maps",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"chromedriver": "^2.46.0",
"geckodriver": "^1.14.1",
"nightwatch": "^1.0.19"
}
}
My nightwatch.json :
{
"src_folders" : ["tests"],
"webdriver": {
"start_process":true,
"server_path": "./node_modules/geckodriver/geckodriver.exe",
"cli_args": [
"--log", "debug" ],
"port": 4444
},
"test_settings" : {
"default" : {
"desiredCapabilities": {
"browserName" : "firefox",
"acceptInsecureCerts": true
}
}
}
}
PS : I don't encounter this issue when using chromedriver.
My problem is similar with you, but i use ie driver
having the same issue with geckodriver and here's my workaround using web element id:
client.element(
'css selector',
`[id="${iframeId}"]`,
(result) => {
const frameWebElementId = result.value;
client.frame(frameWebElementId);
console.log(`Switched into frame ${iframeId}`);
}
);
This issue fix the problem https://github.com/nightwatchjs/nightwatch/pull/2040.
Simply change your package.json to point to the git+https to master until the version 1.11.X is out on npm.
This issue has been automatically marked as stale because it has not had any recent activity.
If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.
still, I'm facing the same issue while using firefox
For me using await this worked:
await browser.waitForElementVisible(".iframe")
const frame = await browser.element("css selector", ".iframe")
await browser.frame(frame.value)
I have to wait for the iframe to be visible and after that switch to it because it was dynamically added to the page
Most helpful comment
having the same issue with geckodriver and here's my workaround using web element id: