Selenium Interview Questions and Answers
Selenium Interview Questions and Answers
Selenium Interview Questions and Answers for beginners and experts. List of frequently asked Selenium Interview Questions with answers by Besant Technologies. We hope these Selenium interview questions and answers are useful and will help you to get the best job in the networking industry. This Selenium interview questions and answers are prepared by Selenium Professionals based on MNC Companies expectation. Stay tuned we will update New Selenium Interview questions with Answers Frequently. If you want to learn Practical Selenium Training then please go through this Selenium Training in Chennai and Selenium Training in Bangalore
Best Selenium Interview Questions and Answers
Besant Technologies supports the students by providing Selenium interview questions and answers for the job placements and job purposes. Selenium is the leading important course in the present situation because more job openings and the high salary pay for this Selenium and more related jobs. We provide the Selenium online training also for all students around the world through the Gangboard medium. These are top Selenium interview questions and answers, prepared by our institute experienced trainers.
Selenium interview questions and answers for the job placements
Here is the list of most frequently asked Selenium Interview Questions and Answers in technical interviews. These questions and answers are suitable for both freshers and experienced professionals at any level. The questions are for intermediate to somewhat advanced Selenium professionals, but even if you are just a beginner or fresher you should be able to understand the answers and explanations here we give.
Q1. What the feasibility test in automation testing life cycle does?
It checks for which test cases of manual test cases can be automated.
The module of the application that can be considered for automation.
The tool to be used.
Calculating the no of regression test cases that can be automated.
Q2. To automate and test the mobile application what kind of automation is used for?
Appium
Q3. To automate and test the windows application what kind of automation is used for?
AutoIT
Q4. To automate and test the performance of an application what kind of automation is used for?
Performance testing => Jmeter and Load Runner
Q5. The process of implementing the functionality of the web driver into the Firefox, chrome and IE driver (Browser) is called as ——-
Interface
Q6. It is said that the Firefox is the native browser for selenium, if so how to work with chrome, IE and other browsers?
Use System.setProperty (“webdriver.chrome.driver”, path of chromedriver);
Q7. If user wants to maximize and minimize the screen of an application which is to be automated, what is the code or the syntax used for?
Driver.manage().window().Maximize();
Driver.manage().window().Minimize();
Q8. If the user wished to handle textbox present in the application they are automating, what is the syntax or code used for?
Webelement.sendkeys (“MAHA”);
Q9. If the user wished to handle buttons present in the application they are automating, what is the syntax or code used for?
Webelement.click (); or webelement.submit ();
Q10. If the user wished to handle static dropdown present in the application they are automating, what is the syntax or code used for?
Select S = new select (“Country”);
S.selectByValue ();
S.selectByVisibleTest ();
S.selectByIndex ();
Q11. If the user wished to handle dynamic dropdown present in the application they are automating, what is the syntax or code used for?
List ls = driver. FindElement (By.tagname (“option”));
System.out.println (ls.size);
For (WebElement w1: ls)
{
System.out.println (w1.getText);
Q12. If the user wished to clear the texts present in the textbox of an application they are automating, what is the syntax or code used for?
clear ();
Q13. If the user wished to handle mouse and keyboard action of an application they are automating, what is the syntax or code used for?
To Handle Mouse Action
Actions action = new Actions(driver);
WebElement e1 = driver.findElement(By.id(“ “);
Action.moveToElement(e1);
Action.click(e1).build().perform();
Keyboard action:
KeyDown(Modifier_Key) – Perform a modifier key press.
Don’t release the modifierkey(Key ALT , Keys.Shift) E1.sendKeys(Keys.ARROW_DOWN); E1.sendKeys(keys.ARROW_UP); E1.sendKeys(keys.ENTER);
Methods in Keyboard and Mouse action
ClickAndHold() – It Clicks(without releasing) at the current mouse location.
ContentClick() – It Performs a content click operation..
DoubleClick() – It Performs a double-click operation.
DragAndDrop(source,target) – It performs the dragging and dropping of an element for which we are fetching address.
Q14. If the user wished to take the screenshot of every test case (steps) of an application they are automating, what is the syntax or code used for?
File screenshot = ((TakesScreenshot) driver).getScreenshotAs (OutputType.FILE); FileUtils.copyFile (screenshot, new File (“D:\\framework\\screenshots.jpg”));
Q15. How the user handles the window based popups of an application
Robot r = new Robot ();
r.keypress(KD_alt);
r.keyrelease();
Q16. Which type of wait command is applied to all the web elements to wait for certain amount of time before throwing an exception?
Implicit wait
driver.manage().timeouts().implicitTimeout(60,TimeUnit.Seconds);
Q17. Which type of wait command is applied to particular web elements to wait for certain amount of time and also associated with the expected conditions before throwing an exception?
Explicit wait – WebDriver Wait
WebDriverWait wait = new WebDriverWait(driver,60); Wait.WebDriver.until(ExpectedConditions.visibilityof(driver.findElement(By.classname(“”)));
Q18. Which type of wait command is applied to particular web elements to wait for certain amount of time, where frequency is set and also associated with the expected conditions before throwing an exception?
Wait wait = new FluentWait(driver) .withTimeout(60, SECONDS) .pollingEvery(10, SECONDS) .ignoring(NoSuchElementException.class);
WebElement dynamicelement = wait.until(new 38 Function()
{
public WebElement apply(WebDriver driver)
{
return driver.findElement(By.id(“dynamicelement”));
}
} );
Q19. If the user wished to handle alerts present in the application they are automating, what is the syntax or code used for? Mention all the possible methods?
driver.switchto.alert.accept();
driver.switchto.alert.dismiss();
Q20. If the user wished to handle different kinds of navigation in the application they are automating, what is the syntax or code used for?
navigate().to()
navigate().refresh()
navigate().back()
navigate().forward()
Q21. How to capture or identify the address of the web elements in the application, Mention all the kinds? Locators in Web Driver
• ID
• Name
• CSS Selector
• TagName
• ClassName
• LinkText
• Partial LinkText
• Xpath
Q22. If the user wished to handle different set of windows of the application they are automating, what is the syntax or code used for? Mention all the possible methods?
Windows Handling,
String mainWindow=driver.getWindowHandle();
// It returns no. of windows opened and will also return Set of Strings
Set<String> set =driver.getWindowHandles();
// Using Iterator dunction to iterate through the windows
Iterator<String> itr= set.iterator();
while(itr.hasNext()){
String childWindow=itr.next();
if(!mainWindow.equals(childWindow))
{
driver.switchTo().window(childWindow);
System.out.println(driver.switchTo().window(childWindow).getTitle());
Driver.close();
Q23. What is the return type of the windows handling?
String
Q24. If the user wished read the text provided in the text box of an application they are automating, what is the syntax or code used for? Mention all the possible methods?
Getattribute()
Q25. Writ the syntax to select multiple values from the dropdown?
ISMultiple()
Q26. If the user wished to checkbox present in the application they are automating, what is the syntax or code used for? Mention all the possible methods?
IsEnabled(), ISSelected(), ISDisplayed()
Q27. If the user wished to handle alerts radio button present in the application they are automating, what is the syntax or code used for? Mention all the possible methods?
driver.switchto.alert.accept(); • driver.switchto.alert.dismiss();
Q28. If the user wished to handle radio group present in the application they are automating, what is the syntax or code used for? Mention all the possible methods?
List ls = driver.findElement(By.tagname(“option”));
System.out.println(ls.size);
For(WebElement w1 : ls)
{
System.out.println(w1.getText);
}
Q29. How to differentiate the action performed when driver.get (URL) and driver.navigate ().to (URL) is used?
get (URL) -> Open and wait until the whole webpage loads
navigate (URL) -> Opens but does not wait until the whole webpage loads
Q30. How to differentiate the action performed when findElement and findElements is used?
FindElements -> It will return the list of WebElement matching as per the given locator mechanism.
FindElement -> It will return only one WebElement
Q31. Write syntax for scrolling the webpage?
Driver.get(URL);
JavaScriptExecutor je = JavascriptExecutor(driver);
Js = executescript(“window.scrollBy(0,4000);
Q32. How user achieves performing drag and drop in a web application using the action class?
WebElement From = driver.findElement(By.xpath(“.//*[@id=’101′]/a”));
WebElement To =driver.findElement(By.xpath(“.//*[@id=’102′]/a”));
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(From) .moveToElement(To) .release(To) .build(); dragAndDrop.perform();
Q33. How user achieves performing right click in a web application using the action class?
Action.contectclick(a).build().perform();
Q34. How user achieves performing mouse hover in a web application using the action class?
Action.moveToElement(a).perform();
Q35. How user achieves clicking on the web element in a web application using the action class?
Actions act = new Actions(driver);
WeElement e = driver.findElement(By.xpath(“Xpath Expression);
Action.MoveToelement(a);
Actions.click().build().Perofrm();
Q36. If the user wishes to terminate a browser sessions what will be the syntax be?
Driver.close();
Q37. If the user wishes to terminate a entire session what will be the syntax be?
Driver.quit();
Q38. How the user handles frames present in the web application?
driver.switchto().frame();
driver.switchto().defaultContent();
Q39. How to differentiate between the soft assert and hard assert
Soft Assert: Collects error during @test
Don’t throw exception if exception fails bu5t continues after assert statement with next step
Hard Assert: Throws assertException immediately when an assert statement fails and test suite continue with next assert
Q40. Which type of xpath is advised for the user to use to fins the address of the web element present in the web application? And why?
Relative Xpath, because absolute xpath starts from the root node whereas the relative xpath starts from the exact position where web element is present.
Q41. When an element is no longer available in the DOM or when the element is deleted permanently, destroyed or recreated then it is called?
Stale Element Exception.
Q42. Which type of wait is used to handle the AJAX web elements?
Explicit wait
Q43. Why and how constructor, abstract and Interfaces are used in selenium?
Constructor: To link different class written for framework we use constructor
Interface: To Implement the functionality of the web driver into the Firefox, chrome and IE driver (Browser).
Abstract:
Which kind of framework produces HTML report of execution, uses Annotations, Which can be grouped, priotrized and where parallel testing is possible? TestNG
Q44. How the user gets the current URL of the web page?
getCurrentUrl() – To get the Current URL of the Page.
Q45. How the user view the page source of the web application?
getPageSource() – To get the source code of the Page.
Q46. How the user takes the screenshot along with the date and time?
Calender currdate = calender.getInstance();
SimpleDateFormat formatter = NewSimpledate(format(“yyyy-mm-dd HH:MM:SS”);
String Datetime = formatter.format(CurrentDate.gettime());
Q47. How test priority in the TestNG framework of selenium works?
We achieve it by using the priority attribute of @Test annotations. If priority is not set then the test scripts will be executed in alphabetical order.
Q48. How the user differentiates between the driver.getWindowHandle() and driver.getWindowHandles() in Selenium?
driver.getWindowHandle() – It returns a handle of the current page which is also said to be as an unique identifier.
driver.getWindowHandles() – It returns a set of handles of the all the pages available in the browser.
Q49. What are all the different ways by which a user refreshes the web page in selenium?
driver.navigate().refresh()
driver.get(“URL”) or driver.getCurrentUrl()
Using driver.navigate().to(“URL”) or driver.navigate().to(driver.getCurrentUrl());
Using sendKeys(Keys.F5)
Q50. How to completely detele all the cookies captured using the selenium?
driver.manage().deleteAllCookies();