Powered By Blogger

Search Here!

Friday, February 22, 2013

WebDriver: Refresh IFrame on the Page

Refresh the IFrame not the whole page. Pass the IFrame name in the method.

        ///
        /// Refresh the current selected iframe.
        ///

        /// This is the name of the Iframe.
        /// Executes JavaScript in the context of the currently selected frame or window.
        /// The script fragment provided will be executed as the body of an anonymous function.

        /// Indicates that a driver can execute JavaScript, providing
        /// access to the mechanism to do so.

        protected void RefreshIFrameByJavaScriptExecutor(string iFrameName)
        {            ((IJavaScriptExecutor)WebDriver).ExecuteScript(string.Format("document.getElementById('{0}').src = " + "document.getElementById('{0}').src", iFrameName));
        } 

No comments:

Post a Comment