FluentAutomation
FluentAutomation copied to clipboard
Existing jQuery overwritten
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 { }
}
:+1:
Added a comment about another way to fix it in #164