Unsure why Selenium methods are running fast in Main but slow in JUnit

21 views
Skip to first unread message

Tyler Ashcroft

unread,
Aug 23, 2016, 6:37:49 PM8/23/16
to Selenium Users

I am working on a suite of automated Selenium tests. I have a bit a code that handles checking search filter's for our website (checking their validity, what is selected, etc.). This bit of code is running a lot slower than I had expected. I am developing the suite using the Page Object pattern, and during development, I would debug various bits out of a main method, then implement the test methods using JUnit once the Page Objects were functioning properly.

I noticed a significant time discrepancy between the execution times of constructing the object in Main vs. in JUnit. In Main, the object construction takes about 15 seconds. When I run it in through JUnit, however, object construction takes about 16 minutes. This is obviously a large enough difference that I am concerned about it and want to know how I can get the JUnit execution time closer to what I was observing when it was run through main. I'd appreciate any ideas, or a better understanding of why the delay was being caused. Thanks!

Configuration: Java 8, Selenium 2.53.0, JUnit 4.12, Fiefox 48


Here are the lines of code in question:

// Run in main

// getFilters() returns new Filters(webDriver);
Filters filters = resultsPage.getFilters(); 

// Run with JUnit (through IntelliJ)
filters = resultsPage.getFilters();

Essentially the only differences are 1) the filters in the test class are static and set in my @BeforeClass method and 2) they are run through JUnit through IntelliJ rather than just being executed by IntelliJ, but I'm quite certain that it is the exact same bit of code that is running on both places (The Filters constructor) where the time difference is occurring.


(I've also posted this question on Stack Overflow, I just haven't found the solution. Here's the link, if you want to answer it there for the reputation, that would work as well.)

http://stackoverflow.com/questions/39105601/unsure-why-selenium-methods-are-running-fast-in-main-but-slow-in-junit

Reply all
Reply to author
Forward
0 new messages