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

Clicking element inside iFrame does not give any response #684

Closed
haquezameer opened this issue Sep 5, 2017 · 11 comments · Fixed by #971
Closed

Clicking element inside iFrame does not give any response #684

haquezameer opened this issue Sep 5, 2017 · 11 comments · Fixed by #971
Assignees
Labels

Comments

@haquezameer
Copy link

haquezameer commented Sep 5, 2017

I am clicking an element inside an iframe which should give me a different frame/view, that is move into the view represented by that element. If i click the element manually,the url does not change. So, I guess only the frame is changed. The element is being clicked properly since there are no errors for that. However nothing happens when it is clicked and returns error when I do page.waitForNavigation().
Here is the debug log listening for mouse and keyboard clicks.
puppteer
Also made sure proper element is clicked referring to #618. Here is portion of code that handles clicking the element inside iframe :

var frames = await page.frames();
var myframe = frames.find(f => f.name() === 'mygurukuliframe_submenu'); 
const attselector = '#imgid_12';
const attel = await myframe.$(attselector);
const outerHTML = await attel.evaluate(e => e.parentNode.outerHTML);
console.log('the outerhtml: ', outerHTML);
await attel.click({button:'middle'});
await page.waitForNavigation();
await page.screenshot({path : 'example.png'});
browser.close();

Please mention if any further info is needed and help if it can be resolved.

@JoelEinbinder JoelEinbinder self-assigned this Sep 5, 2017
@aslushnikov aslushnikov added the bug label Sep 5, 2017
@aslushnikov
Copy link
Contributor

@zamhaq thanks for reporting this, that's a bug.

@SMJ93
Copy link

SMJ93 commented Sep 13, 2017

@zamhaq @aslushnikov any update on this issue?

@haquezameer
Copy link
Author

@JoelEinbinder Is this being worked upon?

@okbel
Copy link

okbel commented Sep 27, 2017

Any update?

My temporary workaround is to go to the url of the iframe:

const page = await browser.newPage();
await page.goto(url, {waitUntil: 'networkidle'});

// Getting iFrame
const iFrame = await getIframeByName(page.mainFrame(), 'iFrameName');
    
// Go to iFrame url 
await page.goto(iFrame.url(), {waitUntil: 'networkidle'});

// [...] testing

@jonlinper
Copy link

In my case, clicking element inside iFrame does the click, but in a wrong coordinates.
In detail, it doesn't calculate the offset position of the iframe in the main frame.

@jonlinper
Copy link

ElementHandle.js: "_visibleCenter": Changing "getBoundingClientRect" for "boundingBox" fix the issue.
"boundingBox" from https://github.com/GoogleChrome/puppeteer/pull/445/files

@HulaTime
Copy link

HulaTime commented Oct 5, 2017

The best workaround for trying to directly click an element inside an iframe that i've found is to simply select the frame containing the element and then use the frame methods to navigate/select elements inside the frame.
e.g.

const selector = '#elementId';
const Frame = await page.frames()[1]; // quick and dirty selection of the frame i'm after, serves for example though...
await Frame.$eval(selector, el => el.click());

@jonlinper
Copy link

Other workarounds:

  1. Navigate to the url of the iframe (no iframe, no bug).
  2. Move the iframe (with Css) to the top-left of the screen.

@veb
Copy link

veb commented Oct 5, 2017

@MaxProvin when I try your code I get this in the console:

(node:10904) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: SSL Certificate error: ERR_CERT_WEAK_SIGNATURE_ALGORITHM

Does anyone know why that's happening?

@fran0254
Copy link

Good morning, you could know if this bug will solve ??

@xPomaHx
Copy link

xPomaHx commented Dec 18, 2017

The solution for me
$(<style>
html, body {
width: 999px!important;
height: 999px!important;
overflow: hidden!important;
}
iframe {
position: fixed!important;
top: 0!important;
left: 0!important;
z-index: 9999!important;
}
< /style>).appendTo("head");

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

Successfully merging a pull request may close this issue.

10 participants