Selenium Interview Questions
Selenium Interview Questions
Automation testing is the process of testing the software using an automation tool to find the defects. In this
process, executing the test scripts and generating the results are performed automatically by automation
tools. Some most popular tools to do automation testing are HP QTP/UFT, Selenium WebDriver, etc.,
5. What is a Framework?
A framework defines a set of rules or best practices which we can follow in a systematic way to achieve the
desired results. There are different types of automation frameworks and the most common ones are:
• Data Driven Testing Framework
• Keyword Driven Testing Framework
• Hybrid Testing Framework
7. Can you explain the Framework which you have used in your Selenium Project?
Here we have clearly explained each component of Framework.
9. What is Selenium?
Selenium is an open source (free) automated testing suite to test web applications. It supports different
platforms and browsers. It has gained a lot of popularity in terms of web-based automated testing and giving a
great competition to the famous commercial tool HP QTP (Quick Test Professional) AKA HP UFT (Unified
Functional Testing).
Selenium is a set of different software tools. Each tool has a different approach in supporting web based
automation testing.
It has four components namely,
i Selenium IDE (Integrated Development Environment)
ii Selenium RC (Remote Control) – selenium 1
iii Selenium WebDriver – selenium 2 & 3
iv Selenium Grid
12. Which is the only browser that supports Selenium IDE to be used?
Firefox
In simple words, it is used to distribute your test execution on multiple platforms and environments
concurrently.
28. What is the difference between Absolute Path and Relative Path?
Absolute XPath starts from the root node and ends with desired descendant element’s node. It starts with top
HTML node and ends with input node. It starts with a single forward slash(/) as shown below.
/html/body/div[3]/div[1]/form/table/tbody/tr[1]/td/input
Relative XPath starts from any node in between the HTML page to the current element’s node(last node of the
element). It starts with a single forward slash(//) as shown below.
//input[@id='email']
Hard Assert: Hard Assert throws an AssertException immediately when an assert statement fails and test suite
continues with next @Test
<2.53 – no geckodriver
3.x – geckodriver for FF
To launch Firefox Driver:
WebDriver driver = new FirefoxDriver();
To launch Chrome Driver:
WebDriver driver = new ChromeDriver();
To launch Internet Explorer Driver:
WebDriver driver = new InternetExplorerDriver();
37. What are the different exceptions you have faced in Selenium WebDriver?
• WebDriverException
• TimeoutException
• NoAlertPresentException
• NoSuchWindowException
• NoSuchElementException
• StaleElementReferenceException
• IllegalStateException
38. How To Login Into Any Site If It Is Showing Any Authentication Pop-Up For Username And Password?
To do this we pass username and password with the URL
http://username:password@url
e.g. http://admin:[email protected]
43. How to input text in the text box using Selenium WebDriver?
By using sendKeys() method
WebDriver driver = new FirefoxDriver();
driver.get("https://www.gmail.com");
driver.findElement(By.xpath("xpath")).sendKeys("test");
44. How to input text in the text box without calling the sendKeys()?
// To initialize js object
JavascriptExecutor JS = (JavascriptExecutor)driver;
// To enter username
JS.executeScript("document.getElementById(‘User').value=test.com'");
45. How to clear the text in the text box using Selenium WebDriver?
By using clear() method
WebDriver driver = new FirefoxDriver();
driver.get("https://www.gmail.com");
driver.findElement(By.xpath("xpath_of_element1")).sendKeys("Software Testing Material Website");
driver.findElement(By.xpath("xpath_of_element1")).clear();
54. What is the alternative to driver.get() method to open an URL using Selenium WebDriver?
Alternative method to driver.get(“url”) method is driver.navigate.to(“url”)
driver.navigate().forward(); – to navigate to the next web page with reference to the browser’s history
driver.navigate().back(); – takes back to the previous webpage with reference to the browser’s history
driver.navigate().refresh(); – to refresh the current web page thereby reloading all the web elements
driver.navigate().to(“url”); – to launch a new web browser window and navigate to the specified URL
57. What are the different types of navigation commands?
Refer above question (Can I navigate back and forth in a browser)
61. What are the ways to refresh a browser using Selenium WebDriver?
There are multiple ways to refresh a page in selenium
• Using driver.navigate().refresh() command as mentioned in the question 45
• Using driver.get(“URL”) on the current URL or using driver.getCurrentUrl()
• Using driver.navigate().to(“URL”) on the current URL or driver.navigate().to(driver.getCurrentUrl());
• Using sendKeys(Keys.F5) on any textbox on the webpage
In Selenium 3, we may face few issues while capturing Screenshots. To overcome we use aShot utility. Click on
below links to see posts related to the normal way of capturing a screenshot and capturing a screenshot using
aShot utility.
72. How can you find Broken Links in a page using Selenium WebDriver?
73. How to find more than one web element in the list?
// To store the list
List <WebElement> eleList = driver.findElements(By.xpath("xpath"));
// To fetch the size of the list
int listSize = eleList.size();
//for loop
for (int i=0; i<listSize; i++)
{
// Clicking on each link
links.get(i).click();
// Navigating back to the previous page that stores the links
driver.navigate().back();
}
77. List some scenarios which we cannot automate using Selenium WebDriver?
1. Bitmap comparison Is not possible using Selenium WebDriver
2. Automating Captcha is not possible using Selenium WebDriver
3. We can not read bar code using Selenium WebDriver
4. windows OS based pop ups
5. third party calendars/element
6. Image
7. Word/PDF
79. How can you use the Recovery Scenario in Selenium WebDriver?
By using “Try Catch Block” within Selenium WebDriver Java tests.
try {
driver.get("www.xyz.com");
}catch(Exception e){
System.out.println(e.getMessage());
}
82. How to run Selenium WebDriver Test from the command line?
Class A{
}
cd c
c: javac A.java
c: java A.java
87. How To Perform Right Click Action (Context Click) In Selenium WebDriver?
We use Actions class in Selenium WebDriver to do Right-Click (Context Click) action.
action.contextClick(driver.findElement(By.xpsjht()).build().perform();
Interview Questions:
//Selenium basic question
1. Explain the Selenium Architecture
2. Difference between Selenium-IDE & Selenium RC , WebDriver
3. Difference between
WebDriver driver = new FirefoxDriver()
FirefoxDriver driver = new FirefoxDriver()
4. Difference between get(), navigate().to()
5. What is API , where it is being used
6. Difference between quit() & close()
7. How to maximixe & minimize the browser
8. What is WEbdriver “interface” or Class
9. What is Super interface for WebDriver
10. What is WebElement & explain all the Mtds available in WebElement
11. How many locator is available in Webdriver , & which locator is preferred
12. How to check whether object is available in GUI
13. How to check the text from the UI
14. How to capture color , height , width , font –size of the Element
15. How to get the Location of the Webelement
16. How to check whether object is selected or not ?
17. How to check whether object is enabled in GUI
18. How to delete All Cookies
19. Do we use any constructor in webdriver
20. How to compare Image
21. How to get the webelemnt height & width
Question on WebDriver wait statement
22. What is Synchronization
23. How to handle Synchronization wait available in Webdriver
24. Which wait statement will be used to wait till page load
25. How to handle dynamic object
26. Difference between thread wait , implicitly wait , explicitly wait
27. What is fluent wait
Question DropDown & keyboard & mouse operation
28. How to handle dropdown
29. List out all mtds available in Select class
30. How to capture all the value from the dropdown
31. How to capture only Selected value from the dropdown
32. How to capture only non-selected value from the dropdown
33. How to how with multiSelect value from the dropdown
34. How to select all the similar value from the dropdown
EG we have multiSelect dropdown, like automation testing , manual testing , sql testing , java ,
we should all the option which contains “testing” word
35. How to work with custom select dropdown/ auto suggest dropDown
36. How to take mouse over operation on the element
37. How to perform keyboard operation
38. How to perform “control+c”
39. Difference between build() & perform()
40. How to perform drogAndDrop Operation
41. How to perform rightClick operation
Question on Window Handling
42. How to work with new Tab, new Browse-window
43. How to work with new Tab, new Browse-window with our GetWindowHAnles() mtd
44. How to handle Alert popup
45. How to work Calender POP-up
46. How to work with advitiseMent popup
47. How to work with SSL pop-up
48. How to File Download PopUP
49. How to handle File Upload Pop-up using AutoIT
50. How to Handle File Uplaod Pop-up usinh ROBOT class
51. How to Handle Browser Scrool-bar
52. How to execute java-script
Question Frame Handle
53. How to work with frame-Window
54. How to Work with nested Frame
55. How to work with multiple frame
56. How many ways to work with frame
57. How to work frame , when frame does not have id & @name attribute
Question on Multiple Browser
58. What is IllegalState Exception
59. How to work with IE , Chrome browser
60. How to write xpath in IE & chrome browser
Block- 1 : Framework interview Question
61. What is framework , Explain types of framework
62. Which framework you have used& WHY?
63. Explain framework, with components
TestNG interview Questions
64. What is TestNG , why it is required
Ans : Unit testing framework Tool , used for parallel , grouping , parallel execution , Assertion ,
HTML mREport
65. With OUT TESTNG , what all the challenges you faced