Guest User

Untitled

a guest
Apr 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. Why do we assign Firefox driver to WebDriver interface instance?--WebDriver driver = new FireFoxDriver();
  2.  
  3. WebDriver is an interface. If we create object with WebDriver instance, then it would be easy to change it other browser drivers like ChromeDriver etc.
  4.  
  5. We can also create object by using below statement.
  6. FireFoxDriver driver = new FireFoxDriver();
  7. But suppose, we need to change it chrome browser at any point in the program then we have to create object of chromedriver class and its not a good practice to create objects of several classes.
  8.  
  9. ChromeDriver driver = new ChromeDriver();
  10.  
  11. If we assigned it with WebDriver instance like below. Then WebDriver instance will be create only once and it will easy to change it another browser driver at any point in the program.
  12.  
  13. WebDriver driver; // it is created only one time in the program
  14.  
  15. driver = new FireFoxDriver();// any where in the program
  16.  
  17. driver = new CromeDriver(); // any where in the program
Add Comment
Please, Sign In to add comment