How to Fixed iFrame Problem

Hi guys,

I want to ask u about iFrame problem. First, let me tell you about my case
- I tried to make automation for the web. The web has some data in hyperlink form, and when I click on it, it will open new window contains data’s detail
- The problem is, I can’t get the detail when executing the test case (in this case, I tried to getText from the detail). The console give me error ‘WebElementNotFoundException’ because of the iFrame not found on that detail’s page
- After the error, I tried to add method Switch to iFrame to that iFrame, but the result just give me same error about ‘Unable to verify image . . . cause WebElementNotFoundException . . .’ cause the iFrame itslef was not detected
- So, I tried to give an inspection with spy object. I go to the detail page and capture the object on the iFrame. I successfully get the object, also the iFrame. But, when I try to verify and highlights both of them, it give me a message that the object not found (even with spy object the object already not found, so automatically the execution will be failed too)
- I also check the object insiode the iFrame, and choose setting have parent object to the iFrame, but also still didn’t work

Can you give me some hint to solved this? Any suggestion will be great for me. Thanks :slight_smile:

hello, are you using object defined in OR? or you generate them on fly?

@Andrej Podhajský
hi Andrej, thanks for your response.
I tried both of it. Here is the condition
- First, I generate the object on fly. the execution worked fine, but only for that data (for example, I choose data A and it worked well, but when i chnage with data B, it give me an error like I said before related to the iFrame
- when I tried to get the object again using spy object, it also didn’t work with same error like I explained before

any suggestion to solve it?

when i used object on iframe i used settings on those objects in their definition that basically did switchframe for each of them. i know what description of that fn() said, i’m just curious for how long it switches context …

@Andrej Podhajský
I did definition for the object by choosing the parent iFrame, and like i said only worked for 1 data. if u said that you were concern about how long it switches context, is there are no possible solution to handling it?

hard to tell without html
but is id of that iframe same as when you used data1 ?

here is the html

yes, I also try to inspect element to see if the id or xpath (absolute xpath) different or not. and the result is the id and xpath are the same for data1 and data2. so I just don’t get it how can it worked only for 1 data and not to the other one which is make me confused

html.png

Hi Willis

I’m not convinced you have an iframe. From your original description, it looks as though you have a new window, or perhaps a popup of some kind. The HTML image you attached above shows no sign of an iframe.

Paste the HTML of the element that you believe launches the popup window. Perhaps then we can see what you are truly dealing with.

Russ Thomas said:

Hi Willis

I’m not convinced you have an iframe. From your original description, it looks as though you have a new window, or perhaps a popup of some kind. The HTML image you attached above shows no sign of an iframe.

Paste the HTML of the element that you believe launches the popup window. Perhaps then we can see what you are truly dealing with.

@Russ Thomas
Hi Russ, thanks for your response, and sorry for my late reply. You’re right about that was a new window opened. and about the iFrame, the image I attached before just a part of whole html, but above of that there is an iFrame. Here is the iFrame

and here is the object which cause launches the pop up window

hopefully there will be solution for my problem. thanks before :slight_smile:

ask.png

ask2.png

That’s an ASP.NET application. The postback launches a popup window. So here’s my question:

Is the iframe inside the popup window?

2 Likes

@Russ Thomas
yes it’s an asp.net, and you’re also correct about the iFrame. the iFrame located inside the popup window, which caused the problem.

do you have any solution with this information?

I have never had to test this combination before (and I don’t have time to make a mockup to try it). However…

You should first switch to the new window (https://docs.katalon.com/display/KD/[WebUI]+Switch+To+Window+Index) and then try to target the Test Object that has the parent iframe setting defined on it.

When you are finished testing the popup window, make sure you revert back to the main window – switch back to index zero (0).

@Russ Thomas
I found what the problem is. It caused by the src value from the iFrame
object checked (which is including the id of the data). I just unchecked
that element and it works well for me.
ahh, thank you so much for helping me, it’s all my bad

really thanks for all of your suggestion