cancel
Showing results for 
Search instead for 
Did you mean: 

Handle Iframe

SOLVED
Highlighted
Regular Contributor

Handle Iframe

Facing problem with iFrames

I have Iframe id but Not able to find path for internal element of an Iframe where I need to perform click event. How can can i do the same.

while performing inspect on browser I can see tthe path for internal element.

 

is it right to create object for that Iframe by using Name mapping and then use findchildXpath method on that object and provide xpath for all webelement that need to perform ?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Manager

Re: Handle Iframe

Hi @kaiiii,

There are some things you should be aware of when accessing objects inside iframe. They are listed in the Considerations for Web Testing help article. Let me quote them here:

 

  • With the default security settings Chrome follows the same-origin policy and does not allow cross-origin interaction. Because of this, TestComplete cannot access the contents of cross-origin framesets (when a host of an HTML frame differs from the host of the parent page). To test the contents of such framesets, you need to open the contained frame as a separate web page or launch the Chrome application with the following command-line switches:

    --disable-web-security (for all Chrome versions)

    --user-data-dir=<ProfilePath> (for all Chrome versions)

    --disable-site-isolation-trials (for Chrome version 70 and later)

    The same-origin policy also applies to framesets displaying local files. By default, the local files are considered to belong to different origins and not allowed to access one from another. To solve the latter issue, you can launch the Chrome application with the --allow-file-access-from-files command-line switch.

    The --disable-web-security, --disable-site-isolation-trials and --allow-file-access-from-files command-line switches impair the browser security. We do not recommend using these switches unless required by your testing needs.
  • To execute the JavaScript eval function on a web page frame in Chrome, you need to use a specific syntax that includes the frame ID. See Executing JavaScript in Frames in Google Chrome.


Does it help?

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

4 REPLIES 4
Highlighted
Contributor

Re: Handle Iframe

Hi,

I dont use namemapping so I might not be of help there but I figured out a way to identify iframe objects with this 

function LaunchBrowser()

{

    Browsers.Item(bName).RunOptions = "--disable-web-security --disable-site-isolation-trials --user-data-dir"

    Browsers.Item(bName).Run(YourUrl);

   

}

Highlighted
Regular Contributor

Re: Handle Iframe

Hi @Reshail 

Thanks for reply.

I had do the same and it's not working . still facing same problem.

 

like

Set IframeId = Aliases.browser.frameid ..(frame object as per namemapping)

and below are few buttons that need to click.

 

authorized 

not authorized

attemps

 

but I am not able to perform object spy on that particular button not able to get path for that particular button

How can I do the same.

I had also try

IframeId.FindChildByXpath(".....................authorized path here..........")

but it's not working.

Highlighted
Contributor

Re: Handle Iframe

Which browser are you using? Have you tried it with Firefox?

Highlighted
Community Manager

Re: Handle Iframe

Hi @kaiiii,

There are some things you should be aware of when accessing objects inside iframe. They are listed in the Considerations for Web Testing help article. Let me quote them here:

 

  • With the default security settings Chrome follows the same-origin policy and does not allow cross-origin interaction. Because of this, TestComplete cannot access the contents of cross-origin framesets (when a host of an HTML frame differs from the host of the parent page). To test the contents of such framesets, you need to open the contained frame as a separate web page or launch the Chrome application with the following command-line switches:

    --disable-web-security (for all Chrome versions)

    --user-data-dir=<ProfilePath> (for all Chrome versions)

    --disable-site-isolation-trials (for Chrome version 70 and later)

    The same-origin policy also applies to framesets displaying local files. By default, the local files are considered to belong to different origins and not allowed to access one from another. To solve the latter issue, you can launch the Chrome application with the --allow-file-access-from-files command-line switch.

    The --disable-web-security, --disable-site-isolation-trials and --allow-file-access-from-files command-line switches impair the browser security. We do not recommend using these switches unless required by your testing needs.
  • To execute the JavaScript eval function on a web page frame in Chrome, you need to use a specific syntax that includes the frame ID. See Executing JavaScript in Frames in Google Chrome.


Does it help?

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
A new challenge is here!

Create a function to drag one element to another for the TechCorner tag!

Will you dare to take the challenge?


Scripts created in July:
- Passing custom command-line arguments as a test parameter
Top Kudoed Authors