Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By gimbal2

Thread: why do we use the Webdriver declaration while intializing the FirefoxDriver

  1. #1
    jonathan.vaz is offline Member
    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Default why do we use the Webdriver declaration while intializing the FirefoxDriver

    Can anyone tell me why do we use the Webdriver declaration while intializing the FirefoxDriver.

    Thanks in Advance.

    Java Code:
    WebDriver driver = new FirefoxDriver();
    
    driver.get("http:\\www.google.com");
    		
    WebElement ele = driver.findElement(By.className("gbqfif"));
    ele.sendKeys("Selenium Test");
    when we can use to do the same action:

    Java Code:
    FirefoxDriver driver = new FirefoxDriver();
    driver.get("http:\\www.google.com");
    
    WebElement ele = driver.findElement(By.className("gbqfif"));
    ele.sendKeys("Selenium Test");

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,900
    Rep Power
    5

    Default Re: why do we use the Webdriver declaration while intializing the FirefoxDriver

    No real reason other than that if is a good practice to program against the interface in stead of the implementation class. Other than the point where you instantiate the driver, your code shouldn't really care what it specifically is.
    jonathan.vaz likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    jonathan.vaz is offline Member
    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Default Re: why do we use the Webdriver declaration while intializing the FirefoxDriver

    Well so there isn'nt any specific technical reason why I would define WebDriver before driver.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,900
    Rep Power
    5

    Default Re: why do we use the Webdriver declaration while intializing the FirefoxDriver

    Nope, you're free as a bird to do whatever your knowledge, understanding and experience tells you to do.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    jonathan.vaz is offline Member
    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Default Re: why do we use the Webdriver declaration while intializing the FirefoxDriver

    thanks :)

Similar Threads

  1. declaration of arrays
    By noobplus in forum New To Java
    Replies: 15
    Last Post: 03-17-2012, 02:27 AM
  2. Database declaration
    By simontkk2005 in forum JDBC
    Replies: 4
    Last Post: 12-08-2009, 04:40 PM
  3. class Declaration
    By mahtab in forum New To Java
    Replies: 1
    Last Post: 11-01-2009, 06:49 AM
  4. Declaration
    By asifahmed in forum New To Java
    Replies: 1
    Last Post: 04-05-2008, 05:38 AM
  5. JSP Declaration Directive
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-10-2007, 05:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •