Selenium Interview Questions Part 7

61) What is Junit?

Junit is a unit testing framework introduced by Apache. Junit is based on Java.

62) What are the Junit annotations?

There are following Junit annotations.

  • @Test : This annotations indicates the system that method annotated with @Test is a test method and there can be multiple test methods in a single script.
  • @Before : This indicates the system that method annotated with @Before will always be executed first before executing any test method annotated with @Test.
  • @After : This indicates the system that method annotated with @After will always be executed each time after executing any test method annotated with @Test.
  • @BeforeClass :  Method annotated as @BeforeClass indicates the system that this method shall be executed once before any of the test method.
  • @AfterClass : Method annotated as @AfterClass indicates the system that this method shall be executed once after executing all test method.
  • @Ignore: Method annotated as @Ignore indicates the system that this method shall not be executed.

63) How to change user agent in Firefox by selenium webdriver.

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference(“general.useragent.override”, “some UA string”);
Web Driver driver = new FirefoxDriver(profile);
driver.get(“http:\\google.com”);

64) Suppose developers changed the existing image with a new image with same xpath. In that condition, test case will pass or fail?

It will be passed because selenium identify on the basis of xpath which is not changed.

65) If elements are dynamic in web application , What is other alternative to handle such elements if not using xpath?

We can use CSSSelectors or ClassName.

66) What is object repository?

It is collection of object names their properties, attributes and their values .It may be
excel file, XML,property file or text file.

67) How do you create the object repository to store the elements used in web applications?

This answer may vary according to different experience of projects. One answer could be that we use properties file to store the elements.

68) How do you work with dynamic web tables?

You can click here for answer in details.

69) Which error do we get when selenium is unable to find the element on web page?

org.openqa.selenium.NoSuchElementException: Unable to locate element

70) How to handle network latency using selenium?

Using driver.manage.pageLoadingtime for network latency

Avatar photo

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...