Open Pavan90 opened 2 years ago
Could you share the HTML with us or a site which has this element? Is it a PDF by any chance?
this is the project that i am working on which i cannot share the code. Basically, playwright is not recognizing
You can try this: I created a sample project in stackblitz with object tag. https://stackblitz.com/edit/angular-ivy-evxcng?file=src/app/app.component.html Please do let me know if you can able to access object element and perform any actions.
@mxschmitt I think this applies to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/embed elements as well
@mxschmitt looks like you have merged your PR for object support. Appreciate your efforts to add this element to playwright framelocators. Could you please let me know in which release version does this code will be added ?
@mxschmitt I have tried installing alpha version 1.24.0-alpha-jun-23-2022 but I guess your PR isn't included in that release.
I did not merge the PR, it was a proposal and we decided for now to hold it off and wait more users to run into that request. Thats why I marked it as p3 which is a feature-request.
@mxschmitt great thanks for making this quick change I was excited that #15030 is going to be merged to one of the release. Looking at the playwright features and trends, I wanted to propose using playwright over cypress. With some workarounds in cypress we are at least able to work on object elements. Thought Cypress is still not a perfect solution for our app automation.
We have to leave with object elements in our application because it does take data property which holds important values to pass it to child apps. Moving to iFrames is not feasible in our application.
Hence only hope is to looking forward for "object" element support in our automation tools
.
It would be great if you could help us by merging this to one of the nearest release branch.
Upvote the issue at the top and then we'll most likely considering adding it!
@mxschmitt I have done my part of 👍 I'm sure you would also be equally eager to get it merged, especially when you know that it helps community. Looking forward to hear positive news at the earliest otherwise anyway community would seek help at some other tool or community.
@mxschmitt I believe we got more than enough votes to add this feature to upcoming release and i really appreciate everyone for upvoting this request :)
hello, any updates on this one ? @mxschmitt
@mxschmitt any updates on this feature request or any tentative dates for release? I'm wondering when the fix is ready and people have expressed interest, what is holding from merging to master branch or releasing it?
I was wondering why people are not adopting playwright fast, over Cypress. Looks like I'm getting some answer now looking at this open issue for more than a month 👎
@mxschmitt I was wondering if we can we have any hope of having it any release 🤔
We usually don't provide any eta's on feature requests, based on upvotes we make decisions which features we put in the upcoming release.
Hello @mxschmitt, Just wondering if there are any latest updates on this request ?
Hi, I have the same problem with the embed elements. Are there any updates on this request?
I am very much looking forward to the support of "embed" elements, too.
I need a way to access embed elements too.
Since this issue seems to be pending community need I wanted to add my use case: I simply want to write tests for a legacy application that still uses <object>
instead of <iframe>
. I believe this is because the app was written before SPAs were mainstream.
Anyways, here's the patch-package I made based on @mxschmitt 's PR
playwright-core+1.38.1.patch
index cf2aaf5..b17d7b8 100644
--- a/node_modules/playwright-core/lib/server/dom.js
+++ b/node_modules/playwright-core/lib/server/dom.js
@@ -159,7 +159,7 @@ class ElementHandle extends js.JSHandle {
return null;
}
async isIframeElement() {
- return this.evaluateInUtility(([injected, node]) => node && (node.nodeName === 'IFRAME' || node.nodeName === 'FRAME'), {});
+ return this.evaluateInUtility(([injected, node]) => node && (node.nodeName === 'IFRAME' || node.nodeName === 'FRAME' || node.nodeName === 'OBJECT'), {});
}
async contentFrame() {
const isFrameElement = throwRetargetableDOMError(await this.isIframeElement());
diff --git a/node_modules/playwright-core/lib/server/frameSelectors.js b/node_modules/playwright-core/lib/server/frameSelectors.js
index b4bc820..d7996c3 100644
--- a/node_modules/playwright-core/lib/server/frameSelectors.js
+++ b/node_modules/playwright-core/lib/server/frameSelectors.js
@@ -126,7 +126,8 @@ class FrameSelectors {
selectorString
}) => {
const element = injected.querySelector(info.parsed, scope || document, info.strict);
- if (element && element.nodeName !== 'IFRAME' && element.nodeName !== 'FRAME') throw injected.createStacklessError(`Selector "${selectorString}" resolved to ${injected.previewNode(element)}, <iframe> was expected`);
+ console.log({NODENAME: element.nodeName});
+ if (element && element.nodeName !== 'IFRAME' && element.nodeName !== 'FRAME' && element.nodeName !== 'OBJECT') throw injected.createStacklessError(`Selector "${selectorString}" resolved to ${injected.previewNode(element)}, <iframe> was expected instead of ${element.nodeName}`);
return element;
}, {
info,
these changes work for me and I am able to navigate the object's html tree as I would expect.
Hi @mxschmitt, Any update on embed tag testing using playwright? I am facing one issue related to embed tag. Actually, I have suggested my team to use playwright instead of cypress. but we are facing one issue with current embed tag testing. Playwright does not support embed testing. here are the error details. Error: locator.click: Error: Selector "embed" resolved to <embed width="100%" height="100%" src="https://my.share…/>,
please let me know if embed tag testing is possible with playwright tool? Thanks.
Hello @mxschmitt
We have also been evaluating Playwright and their is a huge barrier we are facing currently to adopt Playwright as a primary tool for automation since Playwright is not able to identify embed tags in the SUT . ( captured here : https://github.com/microsoft/playwright/issues/28926 )
As a result internally there are allready proposals to evaluate other automation tools ( other than Playwright ) which support inherent identification of embed tags , since there is no clear visibility when this feature will be available in Playwright .
I beleive having the support for embed tags added in Playwright right away , can help boost popularity & hence community of Playwright & avoid users switching to other Automation tools ( able to identify embed tags ) without even spending time raising issues here & hence cannot be tracked .
Thus to sum it up : It can be very helpful for the present & potential Playwright community members to have this feature of identification of embed tags , made available asap in next release of Playwright , while holding this feature back will only create a disadvantage for Playwright & lose out on early adopters of Playwright to other competing automation tools ****
Thanks & Best Regards
Wanted to say, this is also a blocker for my team as this issue hasn't had activity in a while. Would be great to see the fix go in!
With the glorious help of Copilot
I was able to find a hacky workaround:
const embed = await page.$('embed');
await embed?.evaluate((node) => {
const iframe = document.createElement('iframe');
iframe.src = node.src;
iframe.width = node.width;
iframe.height = node.height;
iframe.name = node.name;
node.parentNode?.replaceChild(iframe, node);
});
await page.frameLocator('iframe').getByRole('button').filter({ hasText: 'My button within the embed' }).click();
I hope it can help as a workaround for you while we wait for this issue to be resolved.
@workeidon Hello , Thanks for sharing this workaround , Can you please provide some more details for this work around implemantation , like is using this workaround , is your playwright implementation now able to identify embed tags , does it need some other tweaking or libraries as well and what sort of Playwright implementation you have , is it local or on server . Any details that you can please share can be helpful , so we can replicate this workaround to identify embeded tags . You can also share the details on my email id if ok - abhiam1@gmail.com . Thanks
@workeidon Hello , Thanks for sharing this workaround , Can you please provide some more details for this work around implemantation , like is using this workaround , is your playwright implementation now able to identify embed tags , does it need some other tweaking or libraries as well and what sort of Playwright implementation you have , is it local or on server . Any details that you can please share can be helpful , so we can replicate this workaround to identify embeded tags . You can also share the details on my email id if ok - abhiam1@gmail.com . Thanks
I used this workaround to do the following:
iframe
-elementsrc
, width
, height
and name
) the embed hasiframe
-elementThat way one can now detect locators within the embed
(because playwright handles that like a iframe
then).
It also "works" when you have playwright tests that are generated via npx playwright codegen
. You just need to replace every page.frameLocator('embed')…
with page.frameLocator('iframe')…
afterwards.
I tested it on local (so not within a CI-pipeline or similar) against a server. I will send you the full example.
Tested it against a test system on a live server ( SUT ) , needed some updates , working good with this code now
const embed = await page.$('embed');
await embed?.evaluate((node) => { const iframe = document.createElement('iframe'); iframe.src = node.getAttribute('src'); iframe.width = node.getAttribute('width'); iframe.height = node.getAttribute('height'); iframe.name = node.getAttribute('name'); node.parentNode?.replaceChild(iframe, node); });
Hello, I am using html object element (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/object) and trying to access it using page.frameLocators but receiving the below errors.
My assumption is that frameLocator only works for html element "iframe" but Is there anyway I can able to find a workaround to access