Handle Iframe
- 5 years ago
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?
-