FluentAutomation icon indicating copy to clipboard operation
FluentAutomation copied to clipboard

Existing jQuery overwritten

Open predeekc opened this issue 10 years ago • 2 comments

I'm testing an application that is running into problems when using the Selenium WebDriver. The specific problem is that once the JQuery script in FluentAutomation.Sizzle is loaded, window.jQuery and window.$ are no longer equivalent.

My solution was to update the Sizzle.Inject method to use the existing jQuery code if available and load the same as before if it's not. If this solution seems viable in other cases, I can submit a pull request.

public static void Inject(IJavaScriptExecutor executor)
{
    try
    {
        if ((bool)executor.ExecuteScript("return typeof fluentjQuery == 'undefined'"))
        {
            if ((bool)executor.ExecuteScript("return typeof window.jQuery == 'undefined'"))
            {
                executor.ExecuteScript(sizzleScriptInjection);
            }
            else
            {
                executor.ExecuteScript("window.fluentjQuery = window.jQuery");
            }                    
        }
    }
    catch { }
}

predeekc avatar Oct 28 '14 21:10 predeekc

:+1:

jbblanchet avatar Apr 02 '15 16:04 jbblanchet

Added a comment about another way to fix it in #164

olidyu avatar Mar 16 '16 06:03 olidyu