• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Selenium 2 Best Practice

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1- Is it acceptable to use JUnit to write Selenium 2 tests with Web Driver? We are using Jenkins + Maven to execute the unit tests.

2- We have noticed fairly often, that when a test is executed locally it passes, but as soon as the test is pointed at the development environment it fails. It looks like the tests execute so quickly (esp in Firefox) that tests often time out before a page loads. Are there any tricks to avoid this? Is this a common occurrence?

I can't find a lot of documentation on Selenium 2 yet, so any tips would be appreciated.

Thanks!
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They had a similar pratice in my job. But the problem that it was to hard to create the test. The maintenance was hard also. They kind abandoned it and sticky with only JUnit test. =/
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

1- Is it acceptable to use JUnit to write Selenium 2 tests with Web Driver? We are using Jenkins + Maven to execute the unit tests.



Yes, but some selenium command are not supported in WebDriver mean doesn't create a code for you in Selenium IDE when you can change the format in Junit Webdriver,
and show you the output something like this.


but there is code practice to handle such type of commands-and-operation. One advantage using a webdriver test run independently means does not require the standalone Selenium RC server to be run.

2- We have noticed fairly often, that when a test is executed locally it passes, but as soon as the test is pointed at the development environment it fails. It looks like the tests execute so quickly (esp in Firefox) that tests often time out before a page loads. Are there any tricks to avoid this? Is this a common occurrence?



there is many commands provided in selenium-IDE when follow the test, mostly tester know which pages takes a bit more time load or render an element on page.
The most common command we use "WaitForElementPresent" to inforce my test to don't move further until you have dependent element for the next step.

Hope its helps.
 
Tobi McFarland
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I'll give it a try! There is something similar in the WebDriver API. I've been putting in manual timeouts periodically like:

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tobi McFarland wrote:1- Is it acceptable to use JUnit to write Selenium 2 tests with Web Driver? We are using Jenkins + Maven to execute the unit tests.



Not sure if I have the authority to determine if it is "acceptable", but I have written JUnit tests using selenium webdriver and had a lot of success with it. I may be mis-remembering as I have not worked with it in a while, but I think the client tests of the prior release (Selenium RC) were just extentions of JUnit, you just had to have a selenium server running which handled the browser work. I actually had a lot of RC tests which I migrated to web driver without a lot of issues with the control itself (parsing the pages was a different matter, but the architecture swap itself and navigation updates were pretty easy)


Tobi McFarland wrote:2- We have noticed fairly often, that when a test is executed locally it passes, but as soon as the test is pointed at the development environment it fails. It looks like the tests execute so quickly (esp in Firefox) that tests often time out before a page loads. Are there any tricks to avoid this? Is this a common occurrence?



I have run into this. Approach automated tests like you would for any programming solution and consider how to 'design' the code to help you out. I tend to have a base class with common variables and things like URLs (which can be overridden with -D) to allow easy swaps between environments, etc. Specific to this issue, I have helper methods in my base class to do the webdriver "get" followed by a "wait" method call which just does a Thread.sleep wrapped in a try/catch and the waittime as an input parm to the wait.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic