!!

Welcome to Selenium Webdriver Forum

As a web user you can read and search through forum content. Once you have registered and signed you can post topics, post replies, set up watch lists, modify forum settings, and use private messaging.

Author Topic: Design patterns in automation framework?  (Read 2680 times)

fmtjatt

  • Web User
Design patterns in automation framework?
« on: July 26, 2012, 03:49:57 PM »
Does anyone uses design patterns in their automation framework? If yes, could you share some examples?

Rajkumar_Rajangam

  • Web User
Re: Design patterns in automation framework?
« Reply #1 on: July 26, 2012, 03:50:14 PM »
Here's an interesting post.

http://www.sqaforums.com/showflat.php?Cat=0&Number=705657&an=0&page=0

--------------------
Rajkumar

dlai

  • Web User
Re: Design patterns in automation framework?
« Reply #2 on: July 26, 2012, 03:50:29 PM »
Since I wrote that. Another pattern I found very useful is the composite pattern.

The website I'm working on is composed of many widgets and plugins. Instead of writing separate page object implementations for all these classes, I can use Java's proxy class to create composite objects that inherit all the methods and behavior of the different parts.

http://docs.oracle.com/javase/6/docs/api/java/lang/reflect/Proxy.html

--------------------
David Lai
Sr. QA / Test Lead
www.carsdirect.com

Selenium Webdriver

Re: Design patterns in automation framework?
« Reply #2 on: July 26, 2012, 03:50:29 PM »

AnshooArora

  • Web User
Re: Design patterns in automation framework?
« Reply #3 on: July 26, 2012, 03:50:41 PM »
See here: http://www.dofactory.com/Patterns/Patterns.aspx

For automation frameworks, I would recommend reading the following: Abstract Factory, Singleton, Factory, Iterator and Template.

--------------------
Regards,
 
Anshoo Arora
[AdvancedQTP] [LinkedIn] [Relevant Codes]

rolandormrod82

  • Web User
Re: Design patterns in automation framework?
« Reply #4 on: July 26, 2012, 03:50:53 PM »
In response to the singleton and the fact we are in the Webdriver/Selenium section, its important to know that any singleton tied to a webdriver object or web element needs to be disposed when the browser closes down else you are holding onto dead browser references that cause chaos.

I'm just putting it here because we spent a month trying to track down "No response from server/ul" problems and it was all down to singletons.

--------------------
Read my Advanced Selenium Webdriver Automation Blog
 
Roland Ormrod

dlai

  • Web User
Re: Design patterns in automation framework?
« Reply #5 on: July 26, 2012, 03:51:07 PM »
What I do in the shared SeleniumDriver is add a shutdown hook,

Code:

Runtime.getRuntime().addShutdownHook(shutDownHook);
class ShutdownHook extends Thread {

   public void run() {
      // If webdriver is running quit.
      WebDriver driver = SharedWebDriverManager.getInstance().getWebDriver();
      if (driver != null) {
         try {
            System.out
                  .println("CDCWebDriverFactory is being garbage collected."
                        + "Quitting webdriver.");
            driver.quit();
         } catch (Throwable e) {
            // Ignoring driver tear down errors. This is only called when
            // the
            // global instance is destroyed.
         }
      }
      driver = null;
   }




Another alternative is to override the finalize() method in your shared selenium object manager instance. But one problem I find with that is finalize() tends to get skipped if I run it in the debugger then exit after hitting a breakpoint.

--------------------
David Lai
Sr. QA / Test Lead
www.carsdirect.com

Edited by dlai (06/22/12 11:02 AM)

 

Related Topics

  Subject / Started by Replies Last post
2 Replies
690 Views
Last post February 21, 2012, 02:33:53 PM
by Marc Guillemot
2 Replies
639 Views
Last post February 23, 2012, 07:25:23 PM
by Moises Siles
10 Replies
1323 Views
Last post April 15, 2012, 05:33:03 PM
by Ross Patterson
HLD and LLD Design

Started by asrakhanna ISTQB Certification

0 Replies
312 Views
Last post May 07, 2012, 07:20:47 PM
by asrakhanna
0 Replies
229 Views
Last post May 08, 2012, 09:02:35 PM
by t.chuanqi
0 Replies
229 Views
Last post May 08, 2012, 09:35:07 PM
by gaojerryg
3 Replies
3049 Views
Last post July 04, 2012, 02:14:48 PM
by Phil