Here are some of the most popularly asked Selenium interview questions which are being asked during evaluation for Selenium Automation Engineers. These will certainly help you prepare one for yourself. Lets us know if it does and also help us and others by submitting a new questions that been asked to you.
check out latest version here
You may want to mention the languages(s), you are comfortable with. Your rest of the interview might be related to that.
– Selenium support only web-based applications, it doesn’t support any windows based applications.
– Using Selenium tool alone mobile applications cannot be tested, with use of Appium we can achieve it.
– The Windows-based popup cannot be tested using Selenium alone we need to use AutoIT to handle the windows based popups.
– Selenium doesn’t have inbuilt reporting capability so JUnit/ TestNG need to use.
– Limited support for image testing.
– Selenium IDE supports only Firefox browser.
– Selenium doesn’t have built-in object repository.
– Selenium is an open source so no reliable support is available.
Double Slash “//” – Double slash is used to create Xpath with relative path i.e. the xpath would be created to start selection from anywhere within the document.
To avoid “Same Origin Policy” proxy injection method is used, in proxy injection mode the Selenium Server acts as a client configured HTTP proxy , which sits between the browser and application under test and then masks the AUT under a fictional URL
@Before public void method() – It will perform the method () before each test, this method can prepare the test
@Test public void method() – Annotations @Test identifies that this method is a test method environment
@After public void method()- To execute a method before this annotation is used, test method must start with test@Before
Selenium WebDriver: Selenium WebDriver is a tool used to automate testing for web application. It allows us to execute tests against different browsers like Firefox, Chrome, IE & Safari. Selenium WebDriver eliminated the use of Selenium Server thus making it to work faster than RC
WebElement element = driver.findElements(By.xpath(“//div[@id='example']//ul//li”));
findElements(): findElements() is used to find all the elements in the current web page matching to the specified locator value. Take a note that all the matching elements would be fetched and stored in the list of WebElements.
List <WebElement> elementList = driver.findElements(By.xpath(“//div[@id='example']//ul//li”));
Verify will log the failure but continue to execute the test case.
@TestSoft Assert does not throw an exception when an assert fails and would continue with the next step after the assert statement.
Hard Assert: Hard Assert throws an AssertException immediately when an assert statement fails and test suite continues with next
The advantages of using POM are:
– Allows us to separate operations and flows in the UI from Verification improves code readability
– Since the Object Repository is independent of Test Cases, multiple tests can use the same Object Repository
– Reusability of code
driver.quit() – Used to close all the browser instances
String text = driver.findElement("elementLocator").getText();
.pressKey(“non-text keys”) – Used for keys like control, function keys etc that are non-text.
.releaseKey(“non-text keys”) – Used in conjunction with key press event to simulate releasing a key from keyboard event.