Selenium interview questions

1) What is Selenium Webdriver?
Selenium is an open source automated testing suite for web applications across different browsers and platforms. It is quite similar to HP Quick Test Professional (QTP) only that Selenium focuses on automating web-based applications.

Selenium is not just a single tool but a suite of software's, each catering to different testing needs of an organization. 

The webdriver proves itself to be better than both Selenium IDE and Selenium RC in many aspects. It implements a more modern and stable approach in automating the browser's actions. Webdriver, unlike Selenium RC, does not rely on JavaScript for automation. It controls the browser by directly communicating to it.

2) What are Selenium supported browsers?
Selenium WebDriver API has a many different drivers to test your web application in different browsers. List of Webdriver browser drivers are as bellow.
  • Internet Explorer
  • Firefox
  • Google Chrome
  • Opera
  • HTMLUnit

3) Which Programming Languages are supported by selenium WebDriver?
Selenium WebDriver Is very wast API and It support many different languages to write test cases for your software web application. List of WebDriver supported languages are as follow.
  • Java
  • C#
  • PHP
  • Python
  • Perl
  • Ruby
4) Which Different Element Locators Supported By Selenium WebDriver?
Selenium WebDriver supports following element locators
  • XPath Locator
  • CSSSelector Locator
  • ClassName Locator
  • ID Locator
  • Name Locator
  • LinkText Locator
  • PartialLinkText Locator
  • TagName Locator
5) What is the syntax to launch Firefox, Chrome and IE browser in WebDriver?
We can open new Firefox, Chrome and IE browser instance using following syntax.

//Initiating firefox driver
System.setProperty("webdriver.gecko.driver","../MyProject/drivers/geckodriver.exe");
WebDriver driver = new FirefoxDriver();

//Initiating chrome driver
System.setProperty("webdriver.chrome.driver", "../MyProject/drivers/chromedriver.exe");
WebDriver driver = new ChromeDriver();

//Initiating IE driver
System.setProperty("webdriver.ie.driver", "../MyProject/drivers/IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();

6) How To Handle Dynamic Changing IDs In XPath?

  • Identify element by starting Text:
      //button[starts-with(@id, 'continue-')]  

  • Identify element by containing Text:

      //input[contains(@class, 'suggest')]

  • Identify element by Index:

      driver.findElements(By.xpath(“//*submit”)).get(0).click();

7) How to press ENTER key button on text box in selenium webdriver?
driver.findElement(By.id("input")).sendKeys(Keys.ENTER);

8) What are the types of synchronization techniques in selenium WebDriver?
There are two types of synchronization techniques available in selenium WebDriver.
  1. Implicit Wait
  2. Explicit Wait
9) What Is Implicit Wait in Selenium WebDriver?
Sometimes, Elements are taking time to be appear on software web application. Using Implicit wait in webdriver, We can poll the DOM for certain amount of time when some element or elements are not available immediately on webpage.

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

10) What Is Explicit Wait In Selenium WebDriver?
Using explicit wait, we can define to wait for a certain condition to occur before proceeding further test code execution.

WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.elementToBeClickable(By.id("userdetails")));

Above code will wait for 30 seconds for targeted element to be displayed and enabled or clickable.


<-- Previous || Next -->

6 comments:

  1. Selenium is not just a single tool but a suite of softwares. Can you please explain this in detail?

    ReplyDelete
    Replies
    1. Look at the explanation in seleniumhq.org site for more details

      Delete
  2. Nice set of question with proper explanation. Thanks for sharing.

    ReplyDelete
  3. I need small help to write the automation can any one help

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. Website is really very helpful for everyone.

    ReplyDelete