Is it possible to add a custom attribute to the upload widget iframe?
We are writing some QA e2e tests, interacting with the Cloudinary upload widget.
Is it possible to add a custom attribute to the iframe element?
Something like data-cy="upload-widget-iframe"
This would make it more robust to write a querySelector for targeting the upload widget.
-
Hi @Alex,
Can you provide details on the use case?
Since the upload widget is added to an html element, there is a query selector already available to get that element. But seems like you wish to insert this custom attribute to a particular element within the upload widget code. If you can provide more details, that would be helpful.
0 -
We don't add the widget to an HTML element - it's a page-wide pop-up in our angular application?
So the use-case is about automated testing here. We are using cypress to automate our testing, also uploading a small file to cloudinary (just to make sure everything works as expected). The first step of automating the process is to select the Cloudinary iframe. But the only issue is that there are multiple iframes in our application (for example intercom).
Thefore it would be nice to use a attribute selector, cypress documentation suggest something like this:
```
<iframe src="some-url" data-cy="the-frame"></iframe>
```
Because then we can write a robust selector in our test scripts, that targets:
.get('iframe[data-cy="the-frame"]')
I hope this makes more sense - and please ask if you need more details ☺️
0 -
Hi Alex,
Thank you for providing your use case.
It is not possible to add a custom attribute to the iframe, however, we have an attribute specifically for testing purposes: `data-test="uw-iframe"`.
Please let us know if this works for you,
Thanks
1 -
Thanks for the answer Michal - I guess that attribute is ok 👍
1 -
Great! Thanks for the update.
0
Post is closed for comments.
Comments
5 comments