getgauge / taiko

A node.js library for testing modern web applications
https://taiko.dev
MIT License
3.57k stars 453 forks source link

Facing issue while accessing elements within Iframe #2651

Open selvaganesan2005 opened 1 year ago

selvaganesan2005 commented 1 year ago

We are testing an UI app (Technology - Angular) which has "Iframe" elements. There is a #document(html ->body-.>div->input) structure inside the Iframe . We need to access the textbox elements inside the html structure within the Iframe. These elements are not located when we tried to access it using taiko (used different locators such as visible text, Id , relative & full xpath). Please help us resolving this issue. taiko version is 1.3.2.

marques-work commented 1 year ago

Have you tried the $ selector? You can pass it a function that uses the native DOM api.

What I would try is to pass in a function that uses document.querySelector("iframe").contentDocument.querySelector("input[type='text']") to get a handle on an element within an iframe and try manipulating that?

ghost commented 1 year ago

@selvaganesan2005 I was facing the same issue a while ago. I could just solve this issue by running the tests in headless mode in which I had no problems accessing elements inside an iframe. But we could not solve the issue to access the elements in headful mode.