Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you target an Iframe that has an element covering it? #93

Open
gtwelve opened this issue Dec 17, 2017 · 0 comments
Open

How do you target an Iframe that has an element covering it? #93

gtwelve opened this issue Dec 17, 2017 · 0 comments

Comments

@gtwelve
Copy link

gtwelve commented Dec 17, 2017

Hi,

I've been playing around with browser automation using Chromy and have come across an issue where I cannot target an Iframe that has content above it (A modal for example would sit over an Iframe covering it).

The code below looks for the iframe node at a given location. This will resolve as a Div (or another element) when that element is covering the iframe. A new Document is then created referencing the current page not the Iframe.

chromy/src/document.js

Lines 64 to 86 in 2a84760

async iframe (selector, callback) {
const rect = await this.getBoundingClientRect(selector)
if (!rect) {
return Promise.resolve()
}
// to get the the node for location, a position of the node must be in a viewport.
const originalPageOffset = await this._getPageOffset()
let doc = null
try {
await this.scrollTo(0, rect.top)
const locationParams = {x: rect.left + 10, y: rect.top + 10}
const {nodeId: iframeNodeId} = await this.client.DOM.getNodeForLocation(locationParams)
if (!iframeNodeId) {
return Promise.resolve()
}
doc = new Document(this.chromy, this.client, iframeNodeId)
doc._activateOnDocumentUpdatedListener()
} finally {
// restore scroll potion.
await this.scrollTo(originalPageOffset.x, originalPageOffset.y)
}
return Promise.resolve(callback.apply(this, [doc]))
}

I imagine this is an uncommon issue but any help in implementing a workaround would be greatly apprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant