Interview Questions.

Selenium Interview Questions and Answers For Experienced


Selenium Interview Questions and Answers For Experienced

Q1. What are the annotations used in TestNG?

Ans:@Test@BeforeSuite,@AfterSuite,@BeforeTest,@AfterTest, @BeforeClass, @AfterClass, @BeforeMethod, @AfterMethod, @BeforeGroups, @AfterGroups

Q2. What is a hub in Selenium Grid?

Ans: A hub is a server or a imperative factor that controls the test executions on distinct machines.

Q3. How do you read statistics from excel?

Ans: FileInputStream fis = new FileInputStream (“path of excel file”);

Workbook wb = WorkbookFactory.Create (fis);

Sheet s = wb.GetSheet (“sheetName”)

String value = s.GetRow (rowNum).GetCell (cellNum).GetStringCellValue ();

Q4. What is a node in Selenium Grid?

Ans: Node is the device that's attached to the hub. There can be multiple nodes in Selenium Grid.

Q5. What are Soft Assert and Hard Assert in Selenium?

Ans: Soft Assert: Soft Assert collects mistakes at some stage in @Test Soft Assert does not throw an exception whilst an assert fails and might retain with the following step after the assert declaration

Hard Assert: Hard Assert throws an Assert Exception immediately whilst an assert assertion fails and take a look at suite maintains with next @Test

Q6. What are the verification points to be had in Selenium?

Ans: In Selenium IDE, we use Selenese Verify and Assert Commands as Verification factors

In Selenium WebDriver, there's no integrated functions for verification points. It totally relies upon on our coding style. Some of the Verification points are

To check for web page title

To test for positive text

To take a look at for certain detail (text field, button, drop down, and so on.)

Q7. What is POM (Page Object Model)? What are its advantages?

Ans: Page Object Model is a design sample for creating an Object Repository for internet UI elements. Each web page within the application is required to have it’s personal corresponding web page class. The web page class is as a result answerable for locating the Web Elements in that page and then perform operations on the ones Web Elements. The advantages of the use of POM are: Allows us to split operations and flows in the UI from Verification – improves code clarity Since the Object Repository is unbiased of Test Cases, a couple of exams can use the equal Object Repository Reusability of code

Q8. How to release a browser the use of Selenium WebDriver?

Ans: WebDriver is an Interface. We create Object of a WebDriver Interface.

<2.53 – no geckodriver

three.X – geckodriver for FF

To release Firefox Driver:?WebDriver driver = new FirefoxDriver();

To launch Chrome Driver:?WebDriver driving force = new ChromeDriver();

To release Internet Explorer Driver:?WebDriver driver = new InternetExplorerDriver();

Q9. Is the FirefoxDriver a Class or an Interface? 

Ans: FirefoxDriver is a Java magnificence, and it implements the WebDriver interface.

Q10. What is the superb interface of WebDriver?

Ans: SearchContext.

Q11. What is Page Factory?

Ans: Page Factory gives an optimized way to enforce Page Object Model. When we are saying it's miles optimized, it refers back to the fact that the reminiscence usage is excellent and also the implementation is performed in an item orientated way. Page Factory is used to initialize the elements of the Page Object or instantiate the Page Objects itself. Annotations for elements can also be created (and endorsed) as the describing homes won't continually be descriptive enough to distinguish one item from the opposite. The concept of setting apart the Page Object Repository and Test Methods is observed here also. Instead of getting to use ‘FindElements’, we use annotations like: @FindBy to locate WebElement, and initElements technique to initialize net factors from the Page Factory magnificence. @FindBy can take delivery of tagName, partialLinkText, name, linkText, identity, css, className & xpath as attributes. Since the Object Repository is unbiased of Test Cases, multiple exams can use the same Object Repository Reusability of code

Q12. Explain the line of code Webdriver driving force = new FirefoxDriver(); ?

Ans: ‘WebDriver‘ is an interface and we're creating an item reference of kind WebDriver instantiating an item of FirefoxDriver magnificence.

Q13. We do create a reference variable ‘driver’ of type WebDriver

Ans: WebDriver driving force = new FirefoxDriver();

in place of growing

FirefoxDriver driving force = new FirefoxDriver();

What is the cause of doing this way?

F we create a reference variable driving force of kind WebDriver then we should use the identical driver variable to paintings with any browser of our choice which includes IEDriver, SafariDriver and so forth.,

//FirefoxDriver driving force = new FirefoxDriver();

ChromeDriver driver = new ChromeDriver();

motive force.Get(“http://www.Google.Com”);

WebDriver driver = new FirefoxDriver();

Q14. What are the unique exceptions you've got confronted in Selenium WebDriver?

Ans: WebDriverException







Q15. How to deal with keyboard and mouse actions the usage of Selenium?

Ans: We can handle unique keyboard and mouse events by way of the use of Advanced User Interactions API. The Advanced User Interactions API consists of the Actions and the Action Classes which are wanted for executing these events. Most usually used keyboard and mouse occasions supplied by using the Actions magnificence are in the table underneath: Method Description clickAndHold() Clicks (with out liberating) the contemporary mouse place. DragAndDrop() Performs click on-and-preserve at the area of the source detail, actions. Source, goal() Moves to the place of the target detail, then releases the mouse

Q16. How To Login Into Any Site If It Is Showing Any Authentication Pop-Up For Username And Password?

Ans: To do this we bypass username and password with the URL


e.G. Http://admin:admin123@xyz.Com

Q17. What are the types of waits available in Selenium WebDriver?

Ans: In Selenium we ought to see three forms of waits together with Implicit Waits, Explicit Waits and Fluent Waits.

Implicit Waits –

Explicit Waits –

Fluent Waits –


Thread.Sleep() – static wait

Q18. What is Implicit Wait In Selenium WebDriver?

Ans: Implicit waits tell to the WebDriver to watch for a positive amount of time before it throws an exception. Once we set the time, WebDriver will await the element based totally on the time we set before it throws an exception. The default putting is zero (zero). We need to set some wait time to make WebDriver to await the specified time.

Q19. What is WebDriver Wait In Selenium WebDriver?

Ans: WebDriverWait is carried out on a certain element with defined anticipated condition and time. This wait is simplest implemented to the required element. This wait also can throw an exception whilst an element is not discovered.

Q20. What are the distinct sorts of Drivers that WebDriver carries?

Ans: These are the extraordinary drivers to be had in WebDriver: FirefoxDriver InternetExplorerDriver ChromeDriver SafariDriver OperaDriver AndroidDriver IPhoneDriver HtmlUnitDriver

Q21. What is Fluent Wait In Selenium WebDriver?

Ans: FluentWait can outline the maximum amount of time to wait for a particular condition and frequency with which to check the condition before throwing an “ElementNotVisibleException” exception.

Q22. How to input textual content inside the textual content field the usage of Selenium WebDriver?

Ans: By using sendKeys() method

WebDriver motive force = new FirefoxDriver();


driving force.FindElement(By.Xpath("xpath")).SendKeys("check");

Q23. How to input text inside the text box without calling the sendKeys()?

Ans: // To initialize js object

JavascriptExecutor JS = (JavascriptExecutor)motive force;

// To enter username

JS.ExecuteScript("document.GetElementById(‘User').Fee=take a look at.Com'");

Q24. How to clear the text within the textual content box the use of Selenium WebDriver?

Ans: By using clean() technique

WebDriver driver = new FirefoxDriver();

motive force.Get("https://www.Gmail.Com");

driving force.FindElement(By.Xpath("xpath_of_element1")).SendKeys("Software Testing Material Website");

driving force.FindElement(By.Xpath("xpath_of_element1")).Clean();

Q25. How do you confirm if the checkbox/radio is checked or now not?

Ans: We can use isSelected () method.

Syntax – driver.FindElement (By.Xpath (“xpath of the checkbox/radio button”)).IsSelected ();

If the go back price of this technique is genuine then it is checked else it isn't.

Q26. How to get a textual content of an internet detail?

Ans: By the use of getText() technique

Q27. How to get an characteristic price using Selenium WebDriver?

Ans: By using getAttribute(price);

Q28. How to click on on a link the usage of Selenium WebDriver?

Ans: We use click() approach in Selenium to click on the hyperlink

driving force.FindElement(By.LinkText(“Software Testing Material Website”)).Click on();

Q29. How to post a shape the usage of Selenium WebDriver?

Ans: We use “publish” approach on detail to publish a form


Alternatively, you could use click approach on the detail which does shape submission

Q30. How to press ENTER key on text field In Selenium WebDriver?

Ans: To press ENTER key the usage of Selenium WebDriver, We need to apply Selenium Enum Keys with its consistent ENTER.