hero icon indicating copy to clipboard operation
hero copied to clipboard

How to interact with elements in iframe?

Open tsung-sc opened this issue 2 years ago • 7 comments

there is a element in iframe,and i can find it by this code : "const iframe = await hero.getFrameEnvironment(hero.document.querySelector('iframe')); const targetElement= iframe.document.querySelector('xxx');"

but i can't interact with the element.so plz tell me how to do that?

tsung-sc avatar Feb 28 '24 01:02 tsung-sc

Have you tried using a regular click/type on it? There are extension methods like $click and $contentDocument that make this somewhat easier too. (https://ulixee.org/docs/hero/basic-client/awaited-dom-extensions#content-document)

blakebyrnes avatar Feb 28 '24 20:02 blakebyrnes

i have try this way,but the cosole reported " Error: "Interaction.click" element isn't a click-able target.",i can click the target by use "iframe.document.querySelector('xxx').click()",but i can't use "iframe.document.querySelector('xxx').$click().Unluckily,the way i use "iframe.document.querySelector('xxx').click()" can't pass the robot check!

i have try this way,but the cosole reported " Error: "Interaction.click" element isn't a click-able target.",i can click the target by use "iframe.document.querySelector('xxx').click()",but i can't use "iframe.document.querySelector('xxx').$click().Unluckily,the way i use "iframe.document.querySelector('xxx').click()" can't pass the robot check!

tsung-sc avatar Feb 29 '24 02:02 tsung-sc

We have elements in iframes that have tests that work. There could be something about this particular page that's throwing something off. If it is in a scrollable div, hero doesn't know how to click on it yet, unfortunately. You can click on an x/y position on the page too, so if you can figure out what it should be, you could try to just click the coordinates.

blakebyrnes avatar Feb 29 '24 12:02 blakebyrnes

We have elements in iframes that have tests that work. There could be something about this particular page that's throwing something off. If it is in a scrollable div, hero doesn't know how to click on it yet, unfortunately. You can click on an x/y position on the page too, so if you can figure out what it should be, you could try to just click the coordinates.

yeah,i find the solution by click x/y position

tsung-sc avatar Mar 01 '24 01:03 tsung-sc

one more question:hero core seems won't close the browser when client call hero.close().I found that the memory usage of the Core keeps increasing with increasing usage and does not decrease.I deploy a Core docker image in k8s,and client will call hero.close() when task done.

tsung-sc avatar Mar 01 '24 01:03 tsung-sc

Good re:x/y. I introduced a bug in the last release that is fixed on the main-js branch but not in npm yet. There was just a comment on discord about working around it. Will try to get to npm soon.

blakebyrnes avatar Mar 01 '24 02:03 blakebyrnes

Good re:x/y. I introduced a bug in the last release that is fixed on the main-js branch but not in npm yet. There was just a comment on discord about working around it. Will try to get to npm soon.

tks a lot for this project,but plz fix this bug as soon as possible.now i have to restart my core image every day😂

tsung-sc avatar Mar 01 '24 02:03 tsung-sc