Skip to main content

Important Selenium Interview Questions - #2


Complete Selenium Topics to be a Professional Selenium Tester 





Previous Post: Important Selenium Questions Set #1

1) Explain what is Datadriven framework and Keyword driven?

Datadriven framework:  
In this framework, the test data is separated and kept outside the Test Scripts, while test case logic resides in Test Scripts.  Test data is read from the external files ( Excel Files) and are loaded into the variables inside the Test Script.  Variables are used for both for input values and for verification values.

Keyworddriven framework: 
The keyword driven frameworks requires the development of data tables and keywords, independent of the test automation.  In a keyword driven test, the functionality of the application under test is documented in a table as well as step by step instructions for each test.

2) Explain how you can login into any site if it’s showing any authentication popup for password and username?

Pass the username and password with url

  • Syntax-http://username:password@url
  • ex- http://creyate:tom@www.gmail.com
3) Explain how to assert text of webpage using selenium 2.0 ?

WebElement el = driver.findElement(By.id(“ElementID”))
//get test from element and stored in text variable
String text = el.getText();
//assert text from expected
Assert.assertEquals(“Element Text”, text);


5) What is Object Repository ?

An object repository is an essential entity in any UI automations which allows a tester to store all object that will be used in the scripts in one or more centralized locations rather than scattered all over the test scripts.

Useful Resources: 


6) Explain how Selenium Grid works?

Selenium Grid sent the tests to the hub. These tests are redirected to Selenium Webdriver, which launch the browser and run the test.  With entire test suite, it allows for running tests in parallel.

7) Can we use Selenium grid for performance testing?

Yes. But not as effectively as a dedicated performance testing tool like Loadrunner.

8)  List the advantages of Webdriver over Selenium Server?


  • If you are using Selenium-WebDriver, you don’t need the Selenium Server as it is using totally different technology
  • Selenium Server provides Selenium RC functionality which is used for Selenium 1.0 backwards compatibility
  • Selenium Web driver makes direct calls to browser using each browsers native support for automation, while Selenium RC requires selenium server to inject Javascript into the browser

9)  Mention what are the capabilities of Selenium WebDriver or Selenium 2.0 ?


  • WebDriver should be used when requiring improvement support for
  • Handling multiple frames, pop ups , multiple browser windows and alerts
  • Page navigation and drag & drop
  • Ajax based UI elements
  • Multi browser testing including improved functionality for browser not well supported by Selenium 1.0
10)  While injecting capabilities in webdriver to perform tests on a browser which is not supported by a webdriver what is the limitation that one can come across?

Major limitation of injecting capabilities is that “findElement” command may not work as expected.

11)  Explain how you can find broken images in a page using Selenium Web driver ?

To find the broken images in a page using Selenium web driver is
Get Xpath and get all the links in the page using tag name
In the page click on each and every link
Look for 404/500 in the target page title

12)  Explain how you can handle colors in web driver?

To handle colors in web driver you can use
Use getCssValue(arg0) function to get the colors by sending ‘color’ string as an argument

13)  Using web driver how you can store a value which is text box?

You can use following command to store a value which is text box using web driver
driver.findElement(By.id(“your Textbox”)).sendKeys(“your keyword”);

14)  Explain how you can switch between frames?

To switch between frames webdrivers [ driver.switchTo().frame() ] method takes one of the three possible arguments

A number:  It selects the number by its (zero-based) index
A number or ID: Select a frame by its name or ID
Previously found WebElement: Using its previously located WebElement select a frame

15)  Mention 5 different exceptions you had in Selenium web driver?

The 5 different exceptions you had in Selenium web drivers are

  • WebDriverException
  • NoAlertPresentException
  • NoSuchWindowException
  • NoSuchElementException
  • TimeoutException
16)  Explain using Webdriver how you can perform double click ?

You can perform double click by using
Syntax- Actions act = new Actions (driver);
act.doubleClick(webelement);

17) How will you use  Selenium to upload a file ?

You can use “type”command to type in a file input box of upload file. Then, you have to use “Robot” class in JAVA to make file upload work.

18) Which web driver implementation is fastest?

HTMLUnit Driver implementation is fastest, HTMLUnitDriver does not execute tests on browser but plain http request, which is far quick than launching a browser and executing tests

19) Explain how you can handle frames using Selenium 2.0 ?

  • To bring control on HTML frame you can use “SwitchTo” frame method-
  • driver.switchTo().frame(“frameName”);
  • To specify a frame you can use index number
  • driver.switchTo().frame(“parentFrame.4.frameName”);
  • This would bring control on frame named- “frameName” of the 4th sub frame names “parentFrame”

20) What is the difference between getWindowhandles() and getwindowhandle() ?


  • getwindowhandles(): It is used to get the address of all the open browser and its return type is iterator<String>
  • getwindowhandle(): It is used to get the address of the current browser where the control is and return type is string

21) Explain how you can switch back from a frame?

To switch back from a frame use method defaultContent()
Syntax-driver.switchTo().defaultContent();

22) List out different types of locators?

Different types of locators are

  • By.id()
  • By.name()
  • By.tagName()
  • By.className()
  • By.linkText()
  • By.partialLinkText()
  • By.xpath
  • By.cssSelector()
23) What is the command that is used in order to display the values of a variable into the output console or log?

In order to display a constant string, command can be used is echo <constant string>
If order to display the value of a variable you can use command like echo ${variable name>>
Above is using PHP. If you are using Java, replace echo with System.out.println

24)   Explain how you can use recovery scenario with Selenium?

Recovery scenarios depends upon the programming language you use.  If you are using Java then you can use exception handling to overcome same.  By using “Try Catch Block” within your Selenium WebDriver Java tests

25) Explain how to iterate through options in test script?

To iterate through options in test script you can loop features of the programming language, for example to type different test data in a text box you can use “for” loop in Java
// test data collection in an array
String[ ] testData = { “test1” , “test2” , “test3” } ;
// iterate through each test data
For  (string s: test data) { selenium.type ( “elementLocator”, testData) ; }

26) How can you prepare customized html report using TestNG in hybrid framework ?

There are three ways

  • Junit: With the help of ANT
  • TestNG: Using inbuilt default.html to get the HTML report. Also XST reports from ANT, Selenium, TestNG combinations
  • Using our own customized reports using XSL jar for converting XML content to HTML
27) From your test script how you can create html test report?

To create html test report there are three ways

  • TestNG:  Using inbuilt default.html to get the HTML report. Also XLST reports from ANT, Selenium, TestNG combination
  • JUnit: With the help of ANT
  • Using our own customized reports using XSL jar for converting XML content to HTML
28)  Explain how you can insert a break point in Selenium IDE ?

In Selenium IDE to insert a break point
Select “Toggle break point” by right click on the command in Selenium IDE
Press “B” on the keyboard and select the command in Selenium IDE
Multiple break points can be set in Selenium IDE

29)  Explain in Selenium IDE how can you debug the tests?

Insert a break point from the location from where you want to execute test step by step

  • Run the test case
  • At the given break point execution will be paused
  • To continue with the next statement click on the blue button
  • Click on the “Run” button to continue executing all the commands at a time
30)  What is Selenese and what are the types of Selenese ?

Selenese is a selenium set of command which are used for running the test
There are three types of Selenese

  • Actions: It is used for performing the operations and interactions with the target elements
  • Assertions: It is used as a check points
  • Accessors: It is used for storing the values in a variable
31)  Explain what are the limitations of Selenium IDE?

The limitations of Selenium IDE

  • Exceptional handling is not present
  • Selenium IDE uses only HTML languages
  • External databases reading is not possible with IDE
  • Reading from the external files like .txt, .xls is not possible
  • Conditional or branching statements execution like if,else,  select statements is not possible
32)  What are the two modes of views in Selenium IDE ?

Either Selenium IDE can be opened as a pop up window or in side bar

33)  In selenium IDE what are the element locators that can be used to locate elements on web page?

In selenium there are mainly 4 locators that are used

  • X-path locators
  • Css locators
  • Html id
  • Html name
34)  In Selenium IDE how you can generate random numbers and dates for test data ?

In Selenium IDE you can generate random numbers by using Java Script
type
css=input#s
javascript{Math.random()}
And for
type
css=input#s
javascript{new Date()}

35)  How you can convert any Selenium IDE tests from Selenese to another language?

You can use the format option of Selenium IDE to convert tests into another programming language

Comments

Popular posts from this blog

Complete Selenium Topics to be a Professional Selenium Tester

Complete Topics in Selenium to be a Professional Tester Free PDF Below

SECTION 1: INTRODUCTION TO AUTOMATION TESTING
•        What is automation testing? •        When Automation Testing is needed? •        When Automation Testing is not needed? •        What is the use of automation testing? •        Different Automation Tools available in the Market. •        What is the difference between Selenium and QTP?
SECTION 2: INTRODUCTION TO SELENIUM
•        What is Selenium? •        Advantages of Selenium
SECTION 3: COMPONENTS IN SELENIUM
•        IDE Overview •        RC Overview •        Selenium-Grid •        Selenium Web Driver/Selenium 3.0
SECTION 4: SELENIUM IDE
•        Installing IDE •        IDE icons •        Recording your first test with IDE •        IDE Context Menu •        Assert •        Verify •        Adding IDE comments •        Synchronization commands •        Working on pages with AJAX •        Storing elements •        Creating test suites •        Tools  to identify elements/objects •        …

Good news for Software Testers

Here are some of the latest Testing and IT news from technical reporters –
IT managers consortium has agreed that software testers would no longer be blamed for a production defects. Though they are yet to find some one who they could put blame on (Johny the developer is said to be already suffering from ProductionDefectoPhobia)Consortium has also agreed on having salary of software testers on par with software developer at least by 2020. There was an unanimous decision on increasing management salary by 23% from immediate effectConsortium has barred developed from using phrase “It works locally”. Violation of this rule would attract 1 night out in office. Continuous violation would attract exponential salary deductionsComplete Topics to be a Professional Selenium TesterSelenium Concepts Speak and Automate—New era in automated testing. Voice Automation tool for web and windows application was released yesterday. This tool is capable of generating automation suites as you speak of appli…

Top 5 Selenium Webdriver Coding Tips to Improve Quality

SeleniumWebdriver is a powerful automation tool for testing web applications. It’s an open source library bundled with a rich set of features. Using it for testing a website is just like simulating the actions of a real user.
All these abilities together make it a perfect tool for automation. But you need proper guidance to get the best out of it. In this blog post, we’ve assembled some of the best and Top 5 Selenium Webdriver coding tips for software testers.




Tip-1: Best Method To Create Webdriver Instance.
It’s one of the most common Selenium Webdriver coding tips which you can’t avoid to use.
1.1- Use the <Factory> design pattern to create objects based on browser type.
1.2- Extend the below code or use it as is in your projects.
public class DriverFactory {
private WebDriver driver = null;
    public static WebDriver getBrowser(String browserType) {         if (driver == null) {             if (browserType.equals("Firefox"))
            {                 driver = new …