-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Selecting context menu options #1575
Comments
Indeed. This is similar to #1306. Context menus live outside the browser, at the OS level. AFAIK, there's no way to interact with context menus from a page, other than the |
Chrome Extensions support adding and removing items to and from the context menu so it seems that the browser has some hooks. |
Is there a recommended way to do this for now? The context menu opens on right click but, at least on MacOS, |
Right, all of those interactions are at the OS level. Meaning they live outside the browser/puppeteer space. There's no workaround AFAIK. Do other automation frameworks support similar features? |
No and yes. Not in any first-class way. You probably know better than I do. With Selenium it's possible to navigate the opened context menu with the arrow keys (most common from what I see) or to type to effectively "find" by text (less brittle in my opinion). (I'm more or less trying to port code I wrote in Python with Selenium to Node with Puppeteer, but right now it seems I will have to use Node with Selenium.) But those that come to mind are third-party tools supporting multiple browsers (and multiple programming languages...), not an official tool living in a repo of one browser. If supporting automated testing of Extensions is a goal then it seems natural to provide a bit more context menu support. |
Headless chrome does not support extensions #1215 (comment) |
Closing this since it seems there's not much interest in context menus. We can always revisit this later. |
Hey @bittlingmayer were you able to make this work? |
@VikramTiwari No, I dropped Puppeteer and just used Selenium, and did what I needed to do with flags to Chrome. |
I'm developing an extension that uses context menus extensively. I would like puppeteer to support context menu testing. |
was this ever solved? having the same problem selecting from context menus on mac |
Reopen this please. |
@avalanche1 what is the extension's name? did u finish that extension? I really need a best approach instead of using only arrow keys to navigate through options |
@IgnacioYanjari I'm not sure what you're asking. DM me on instagram @mister.kat.il.magnifico, I'll try to help |
Can it? I'm trying to implement "open in new tab" on macOS by doing just that await page.click('a', { button: "right" }); // right click the first <a></a> element
await page.waitForTimeout(1000);
await page.keyboard.press('ArrowDown'); // move to the first item in the context menu
await page.waitForTimeout(1000);
await page.keyboard.press('Enter'); // open the first item
await page.waitForTimeout(1000); but it has same effect as left-clicking the link. It opens the link in the current tab instead of a new tab. I suspect |
It seems that context menu is a native element and outside of the document, and thus belongs in
Page
, similar to screenshot functionality and so on.It can be hacked with keydown events and keyboard events or maybe even selectors, and that's how it is in Selenium, but that's not ideal.
The text was updated successfully, but these errors were encountered: