Selenium Java Interview Questions and Answers - Part 2
Selenium Java Interview Questions and Answers - Part 2
Interview Questions
And Answers
Pramod Dutta
Cracking Automation Tester Interview Series : Part #2 Sr. SDET
TheTestingAcademy.com
Question #1 : How will you find an element using
Selenium?
● ID
● Name
● Tag
● Attribute
● CSS
● Linktext
● PartialLink Text
● Xpath etc
https://www.guru99.com/using-contains-sbiling-ancestor-to-find-element-in-selenium.html
TheTestingAcademy.com
Question #2 : What is the difference between verify and
assert commands?
Assert: In other words, the test
will terminated at the point
where check fails.
TheTestingAcademy.com
Question #3 : Explain what are the JUnits annotation linked
with Selenium?
@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
TheTestingAcademy.com
Question #4 : Explain what is DataDriven framework and
Keyword driven?
DDT : The test data is separated and kept outside
the Test Scripts, while Test Case logic resides in Test
Scripts.
TheTestingAcademy.com
Question #5 : How you can switch between frames?
TheTestingAcademy.com
Question #6 : How you can perform double click ?
TheTestingAcademy.com
Question #7 : How to read a JavaScript variable in
Selenium WebDriver?
JavascriptExecutor js = (JavascriptExecutor)driver;
//Click on button using JS
js.executeScript("arguments[0].click();", button);
TheTestingAcademy.com
Question #8 : How to wait for Element to visible by a AJAX
call?
TheTestingAcademy.com
Question #9 : What is Page Object Model (POM) ?
Page Object Model is a design pattern for creating an object repository
for web UI elements.
The page class is thus responsible for finding the WebElements in that
page and then perform operations on those web elements.
TheTestingAcademy.com
Question #10 : What is Page Factory?
PageFactory.initElements(driver, Login.class);
TheTestingAcademy.com
Question #11 : What is the difference between Page Object
Model and Page Factory?
TheTestingAcademy.com
Question #12 : How to upload a file in Selenium
WebDriver?
driver.get(baseUrl);
WebElement uploadElement =
driver.findElement(By.id("uploadfile_0"));
uploadElement.sendKeys("D:\\newhtml.txt");
TheTestingAcademy.com
TheTestingAcademy.com