Forum Discussion

Mr_Bro's avatar
Mr_Bro
Champion Level 0
4 years ago
Solved

JavaScript Custom function for finding objects within the iframe

Hi Team, 

 

i am trying to find element objects within an ifram object, but im not able to do a object spy on those, so i had tried launching the browser by disabling the web securites and noticed that the time taken to find objects after i disable web securites is too long, hence trying to write a javascript code which will be working similar to javascript executor in selenium, as so this will be used to find elements using xpath for even objects within the iframe object.

 

please help me how to implement the same in testcomplete,

waiting for valuable replies, thanks in advance.

 

Thanks and Regards,

Sathish Kumar K

  • i found the solution by launching the chrome using Command-line arguments 

    and find the iframe object as a parent and after that try finding all the required child objects using parent.findchild() or parent.FindElement() methods.

    below is the sample code to launch the chrome using Command-line arguments:

    def launchBrowser():
      if Sys.WaitBrowser("chrome").Exists:
        #code to close the browser
        closeBrowser()
      strChromeProfilePath = aqEnvironment.GetEnvironmentVariable("USERPROFILE") + '\\Documents\\TempChromeProfile\\'
      Browsers.Item["chrome"].RunOptions = '--disable-web-security --user-data-dir='+strChromeProfilePath+' --disable-site-isolation-trials'
      Browsers.Item["chrome"].Run
      Browsers.Item["chrome"].Navigate('https://www.abcdefg.com');
      Sys.Browser("chrome").BrowserWindow(0).Maximize()
      page = Sys.Browser("chrome").Page('https://www.abcdefg.com')
      page.Wait()

     

    Thanks and Regards,

    Sathish Kumar K

     

3 Replies

    • Mr_Bro's avatar
      Mr_Bro
      Champion Level 0

      My requirement Is also the same situation were im also looking to find objects within the Iframe object,

      but nothing helped me in the same article, so just wanted to know how to achieve the same.

      please let me know the alternative method for "switchToFrame();", so that this would help me a lot.

       

      Thank you

      • Mr_Bro's avatar
        Mr_Bro
        Champion Level 0

        i found the solution by launching the chrome using Command-line arguments 

        and find the iframe object as a parent and after that try finding all the required child objects using parent.findchild() or parent.FindElement() methods.

        below is the sample code to launch the chrome using Command-line arguments:

        def launchBrowser():
          if Sys.WaitBrowser("chrome").Exists:
            #code to close the browser
            closeBrowser()
          strChromeProfilePath = aqEnvironment.GetEnvironmentVariable("USERPROFILE") + '\\Documents\\TempChromeProfile\\'
          Browsers.Item["chrome"].RunOptions = '--disable-web-security --user-data-dir='+strChromeProfilePath+' --disable-site-isolation-trials'
          Browsers.Item["chrome"].Run
          Browsers.Item["chrome"].Navigate('https://www.abcdefg.com');
          Sys.Browser("chrome").BrowserWindow(0).Maximize()
          page = Sys.Browser("chrome").Page('https://www.abcdefg.com')
          page.Wait()

         

        Thanks and Regards,

        Sathish Kumar K