1) 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
2) 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
3) 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.
4) 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
5) 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
6) 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”);
7) 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
8) 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
9) 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);
10) 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.
11) 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
12) 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”
13) 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
14) Explain how you can switch back from a frame?
To switch back from a frame use method defaultContent()
Syntax-driver.switchTo().defaultContent();
15) 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()
16) 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
17) 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
18) 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) ; }
19) 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
20) 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