Monday, March 13, 2017

[Demo] Selenium 3 using Java on Ubuntu Linux

Selenium 3 doesn't launch Firefox just by creating instance of firefoxDriver() to WebDriver object. Instead now there is a new Gecko driver for firefox like the Chrome driver.

What is Gecko Driver? Find out more here

Download geckodriver and chromedriver for Ubuntu and Linux.

Set system property to specify the the Geckodriver path

System.setProperty("webdriver.gecko.driver", "/lib/geckodriver");

Download the complete code from GitHub

Java questions for Selenium automation testing position

Saturday, January 28, 2017

[TIPS] Selenium Implicit Wait - Turn ON and OFF

While automating web application Selenium Webdriver Implicit wait is applied to all findElement and findElements keyword till the element is visible. But in some case we need to check if fields visibility immediately on performing some actions. So why to wait for default implicit wait of 15 or 30 seconds.

Here is the simple tip to override Implicit default wait time by Turning OFF the implicit wait while performing action and validating field visibility. Below Java code snippet will be helpful -

 public void turnOFFImplicitWait(Webdriver driver)  {  
   driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);  

After verifying the step turn ON default implicit wait as below -
 public void turnONImplicitWait(Webdriver driver)  {  
   driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);  

Sunday, January 22, 2017

JAVA Interview questions for Selenium Position

Below Java questions I faced during my QA Automation Testing interview. Most of the answers I searched from Google, Java blogs and tutorials, so I pasted out the link against each question for your easy reference.

1. What is checked exception?
Exception checked during compile time (IOException, FileNotfound Exception)

2. What is unchecked exception?
Exception checked during runtime (Indexoutofbound, ArithmeticException, NullPointerException)

3. Can we make Array dynamic?

4. What is the Difference between array and collection?

5. What is collection?

6. What is HashMap in collection?

7. Difference between HashMap and Hash Table

8. Difference between SetMap and Queue map

9. What is HashSet?

10. Does Set has null value?

11. Polymorphism

12. Overriding (Overriding behavior of parent class and implementing new behavior)

13.   Overloading (Different parameter and different written type with same method name)

14.   Inheritance: Single, multilevel, hybrid

15.   How to achieve multiple inheritance in Java

16.   What is interface and abstract class. Difference?

17.   Can we extends abstract class?
Abstract classes cannot be instantiated, but they can be subclassed. When anabstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class. However, if it does not, then the subclass must also be declared abstract (source)

18.   Can we instantiate abstract class?
As above

19.   Can we change value of final variable in java? Why?

20.   Can a final variable be blank or empty? Why?

21.   What is constructor?

22.   Data encapsulation example in your project?

23.   What is the need of static variable in Java? Why it was need? What limitation did it overcome?

24.   What is inner class?

25.   Why is variable declaration of int, boolean, long start with small letter while String starts with Caps?

26.   Why String class doesn’t have constructor. Why dont we use 'new' keyword to create String object?

27.   Does static method can have static variable? – No
In Java, static means that it's a variable or function of a class and belongs to the complete class but not to one of its certain objects/methods. This means that static keyword can be used only in a 'class scope'

public static int javaMethod() {
    static int javaVariable = 24;             // not valid
    return ++javaVariable;

28.   Does non static method can have static variable? – Yes

29.   What is virtual method?

30. Is static constructor available in Java?