Geeks With Blogs

News Please visit me at my new blog!!

profile for Aligned at Stack Overflow, Q&A for professional and enthusiast programmers
"free in Christ Jesus from the law of sin and death." Romans 8:2 (ESV) Check out the Falling Plates video on YouTube.
more about the Gospel
And then listen to Francis Chan speaking at LifeLight in SD.

Programming and Learning from SD

We've found that some of the timing gets off for running our Selenium tests on our Vms during our builds. This has lead to inconsistent results and failures and a lot of consternation and frustration. It passed 5 times in a row on my local machine, but failed 1 out of 3 in the build!!


Disabling animations for the test run has helped us (along with being better at waiting for our Knockout elements to load, which is a future article I’m working on) and I wanted to share it with you. Just run this after launching the browser, before running your test.

It’s written in C# and uses jQuery and RequireJs.

public static void DisableAnimations()
    // This script should turn off 99% of the animations and transitions in the site. Hopefully this helps settle down some animations
    const string script = "require(['jquery'], function($) {" +
                            "$(function(){" +
                                "$ = true;" +
                                "var styleEl = document.createElement('style');" +
                                "styleEl.textContent = '*{ transition: none !important; transition-property: none !important; }';" +
                                "document.head.appendChild(styleEl);" +
                            "});" +
    if (Driver.Capabilities.IsJavaScriptEnabled)
        catch (Exception)
            Debug.WriteLine("Could not disable animations");
Posted on Wednesday, May 27, 2015 4:24 PM | Back to top

Comments on this post: Disable Animations for Selenium Testing

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Aligned | Powered by: