Selenium MCQ2
Selenium MCQ2
10. Select the correct order of execution of annotations, as per the life
cycle of the TestNG which can be applied for test methods along
with beforeXXXX – afterXXXX methods.
ANS - @BeforeTest, @BeforeClass, @BeforeMethod, @Test,
@AfterMethod, @AfterClass, @AfterTest
25. Sarah wants to automate the selection of only one option from a
drop-down box as shown below.
<html>
<body>
<select multiple>
<option value = “web”> html</option>
<option value = “prog”> python</option>
<option value = “prog”> java</option>
<option value = “prog”> python</option>
<option value = “prog”> java</option>
</select>
</body>
</html>
Sarah has to select only the fourth option i.e., python from the
option list .
selectByIndex()
26. Sean is automating a test scenario in which he has to fetch the URL
of the webpage using webDriver API. Suggest a method for Sean to
get the link address.
getCurrentURL()
27. Which method is used in the Apache POI library to fetch the cell
value from a row? Identify the correct format of invoking the
library functions to get the value from the cell.
sheet.getRow(rowno).getcell(col no).getStringCellValue()
31. Which of the following is correct about generating XML suite file
in TestNG for Test Suite Execution?
TestNG XML Suite file can be generated at the time of creating a
TestNG class.
TestNG XML Suite file can be generated using ‘convert to
TestNG’ option in Eclipse after a java class is created.
34. When verification fails in TestNG, what forces the test to stop
execution and mark as Fail?
AssertionError
35. Samantha wants to automate selection of value from a drop-down
menu. When the element was Inspected. She found:
<html>
<body>
<select name=”jobrole”>
<Option value=”1”>Manager</option >
<option value=”2”>Lead</option>
<option value=”3”>Analyst</option>
</select>
</body>
<html>
Choose “lead” as the test data. Assist her by choosing the correct
options.
selectByIndex(1);
selectByVisibleText(“Lead”)
selectByValue(“2”)
40. Identify the wait time method which is not the Selenium way to
handle synchronization in Test Automation.
Sleep()
41. Which of the following library is used for designing the test scripts
using the predefined classes, methods, and annotations?
TestNG Library
42. Sean is working on a Test Automation project; He is looking for
different strategies for identifying the elements/objects from the
web application using Selenium locators. Suggest Sean with the
available locators in Selenium.
By.id()
By.tagName()
By.partialLinkText()
(Explanation – SELENIUM Selectors - ID, Tag Name, Link Text,
Name, CSS Selector, Partial Link Text, Class Name, XPath)
45. List out the operating systems that are supported by Selenium.
Windows, Linux, Mac, android & iOS
46. Sean is filling a web form with his contact details like email, phone
number, and address while performing registration to an event. He
clicked on submit button without entering the phone number and a
pop-up window appeared saying "Contact Number is required".
Identify the correct way to handle such pop-up windows using
Selenium WebDriver.
driver.switchTo().alert()
47. Identify the child tags that are required to add inside dependency
tag in order to download the desired libraries/jar from the maven
central repository without any errors.
groupId
version
artifactId
48. Sarah is coding an automation script to switch to frame in a web
application. Help her to switch a particular frame on a web page
using the window library. She wants to interact with the pop-up
window and decline the confirmation pop up window show a
message “Do you want to cancel the payment?”. Assist Samantha to
interact with
Driver.SwitchTo().frame(int index)
Driver.SwitchTo().frame(String name or id)
Driver.switchto().frame(webelement frameelement)
51. Kevin wants to generate extensive report for the test automation
project. He decides to use Extent reports library. Which class in
this library is used to create labels, code blocks and labels in the
report?
Markup Helper
54. Which java Enum is used to handle the keyboard strokes from web
driver library? Choose the most appropriate option.
Keys
56. George is reviewing the quality of the Java code given to him using
SonarQube and identified that the variables are named without
following java variable naming convention rules. Under which
category this issue can be tracked in the tool? Choose the most
appropriate option.
Minor
57. Sam has created a TestNG project with below specified TestClass.
public class TestClass
{
@Test(priority=1)
public void method1() {….}
@Test
public void method3() {….}
@Test
public void method2() {….}
@Test(priority=2)
public void method4() {….}
}
Predict the test method execution sequence. Choose the most
appropriate option.
method2, method3, method1, method4
58. What method in the Web driver library is used to get the attribute
value of a web element? Choose the appropriate option.
getAttribute(“attributeName”)
61. Identify the correct flow of Jenkins build, when a maven project
job in Jenkins is triggered for build.
pom.xml >testing.xml- >testing classes>reports
62.Sarah has her code in git local repository, but her team lead had
pushed the new changes into the remote repository, which git
command would you recommend Sarah with new changes into her
working copy?
add
64. Sean configured his project for the test suite execution using
TestNG. He wants to perform parallel execution of the test cases.
Which attribute represents the parallel execution of the test cases?
parallel="tests"
66. Which of the following Java classes are from the Extent API
library?
ExtentReports
Status
67. Which date format is used to customize the system data to year-
month-day format?
new SimpleDateFormat(“yyyy-MM-dd”)
69. What are the various status options available in the Extent reports
library?
PASS,FAIL,SKIP,FATAL,ERROR,WARNING,INFO
70. Kevin wants to fetch all the data from the country drop down
menu and verify the data against data from the database. He is
looking into the library for a method to fetch all the data from the
country drop down box. Which method will help Kevin?
getOptions()
80. Sarah is coding an automation script, where she has to validate the
price of the holiday package based on the drag & drop of island city
from the menu. The price is fetched from the server and displays
without reloading the web page. Which WebDriver library class
has the predefined conditions for handling dynamic waits in
selenium WebDriver Library?
WebDriverWait
81. While using Soft Assertion in the Test Class, James must specify a
method, that will collate and display the assertion results.
assertAll()
1. Sean is coding to automate a web application using the webDriver library. He had set the implicit
wait of 30 seconds. However, the webelement was found within 10s. Will the webdriver wait for
further 20 seconds before executing the next line of code?
2. Which method is used in the Apache POI library to fetch the cell value from a row? Identify the
correct format of invoking the library functions to get the value from the cell
3. Sarah is coding to automate script to switch to multiple windows in a web application. She has to
store all the window instances in a java variable which is retrived by driver.getWindowHandles().
Suggest sarah with a compatable return type to store the window references.
Ans:Set <string>
4. sarah has her code in git local repository, but her team lead had pushed the new changes into the
remote repository, Which git command would you recommend Sarah with new changes into her
working copy?
Ans: add
5. Sean is automating a test scenario in which he has to fetch the URL of the webpage using
webDriver API. Suggest a method fo Sean to get the link address
Ans: getCurrentURL()
6. Mary is struggling to find a suitable simple wild cart character that matches any single character.
Please suggest to her which of the following characters many be relevant to her search
1) Which of the following is correct about generating XML suite file in testNG for Test Suite
Execution
a TestNG XML Suite file can be generated at the time of creating a TestNG class.
b TestNG XML Suite file can be generated using ‘convert to TestNG’ option in Eclipse after a java
class is created.
c TestNG XML Suite file can be automatically generated when user creates a maven java project
a driver.get(“url”)
b driver.navigate().to(“URL”)
c driver.navigate(“URL”)
d driver.getUrl(“URL”)
e driver.setUrl(“URL”)
3) Sam is designing an automation test, where test data is specified in an external excel file. Which
command will be helpful to get across to the 2nd sheet of excel file. Assume wb is the workbook
object.
a wb.getSheetAt(1)
b wb.getSheetAt(2)
c wb.getSheet(1)
d wb.getSheet(2)
4)Sean configured his project for the test suite execution using TestNG. He wants to perform parallel
execution of the test cases. Which attribute represents the parallel execution of the test cases?
a parallel = “methods”
b parallel="tests"
c parallel = “test-classes”
d parallel =”test-cases”
5) Kevin is designing an automation test, where test data is specified in an external excel file. Which
command will be helpful to write the data into a cell of the excel file? Assume c1 is the cell object.
a c1.setCellValue("data")
b c1.setValue(“data”)
c c1.writeCellValue(“data”)
d c1.setCellData(“data”)
6) Sarah wants to automate the selection of only one option from a drop-down box as shown
below.
<html>
<body>
<select multiple>
</select>
</body>
</html>
Sarah has to select only the fourth option i.e. python from the option list .
a selectByVisibleText()
b selectByValue()
c selectByIndex()
DDT
Sam is designing an automation test, where test data is specified in an external excel file. Which
command will be helpful to get access to the 2nd sheet of the excel file. Assume wb Is the workbook
object
wb.getSheetAt(1)
wb.getSheetAt(2)
wb.getSheet(1)
wb.getSheet(1)
EXTENT REPORTS
Which of the following Java classes are from the Extent API library?
ExtentReports
Status
TakesScreenshot
Actions
SWITCHING TO WINDOWS
Which of the following methods is used to close all the opened windows of WebDriver Instance?
Close()
Quit()
Null()
Sleep()
ACTIONS
Sean is coding an automation script for emulating user actions by mouse using the webdriver library.
Assist Sean to choose correct syntax to create an object for actions class from the following options
New Actions(driverInstance)
Actions.callMethods()
EXTENT REPORTS
Which date format is used to customize the system data to year-month-day format?
new SimpleDateFormat(“yyyy-mm-dd”)
new SimpleDateFormat(“yyyy-MM-dd”)
new SimpleDateFormat(“yyyy-month-dd”)
new SimpleDateFormat(“yyyy-mmm-dd”)
WEBDRIVER API
Fuller has written an automation script using selenium webdriver commands. He has used all the
necessary and appropriate locators for interacting with the web elements. When he executed the
script the web driver was not able to locate an element resulting in the test script failure. Which
error/ exception is thrown by webdriver?
NoSuchElementException
NoSuchElementError
NullPointerException
ObjectNotFoundException
WEBDRIVER API
Samantha wants to automate selection of value from a drop down menu. When the element was
Inspected. She foundAgain
<html>
<body>
<select name=”jobrole”>
<option value=”2”>Lead</option>
<option value=”3”>Analyst</option>
</select>
</body>
<html>
Choose “lead” as the test data. Assist her by choosing the correct options.
selectByIndex(1)
selectByValue(2)
selectByVisibleText(“Lead”)
selectByValue(“2”)
Q1- Which expression is used in CSS selectors to match the attribute value with a prefix?
Ans: ^
@Test(priority=1)
@Test
@Test
@Test(priority=2)
Ans: method2,method3,method1,method4
1. Which java enum is used to handle the keyboard strokes from webdriver library?
a. Actions
b. Keyboard
c. Keys
d. Keyword
2. Sam is designing an automation test, where test data is specified in an external excelfile.
Which command will be helpful to get access to the 2nd sheet of the excel file. Assume wb is
workbook object.
a. wb.getSheetAt(1)
b. wb.getSheetAt(2)
c. wb.getSheet(1)
d. wb.getSheet(2)
3. sarah wants to automate the selection of only one option from a drop down box as shown
below
<html>
<body>
<select multiple>
<option value=”web”>html</option>
<option value=”prog”>python</option>
<option value=”prog”>java</option>
<option value=”prog”>python</option>
<option value=”prog”>java</option>
</select>
</body>
</html>
Sarah has to select only the fourth option that is python from the options list
a. selectByVisibleText()
b. selectByValue ()
c. selectByIndex()
d. all the above
4. What are the various status options available in the Extent reports library?
a. PASS,FAIL,SKIP,FATAL,ERROR,WARNING,INFO
b. SUCCESS,FAIL,SKIP ,ERROR,WARNING,INFO
c. DONE,DEBUG,FAIL,SKIP,ERROR,WARNING,INFO
d. ABORT,PASS,FAIL,DONE,ERROR,WARNING,INFO
5. Sean is automating a test scenario, in which he has to fetch the URL of the web page using
WebDriver API . Suggest a method for Sean to get the link address.
a. getURL()
b. get()
c. getCurrentURL()
d. getURL()
6. Kevin wants to fetch all the data from the country drop down menu and verify the data
against data from the database. He is looking into the library for a method to fetch all the
data from the country drop down box. Which method will help Kevin?
a. selectAllOptions()
b. getOptions()
c. getAllOptions()
d. getData()
e. getText()
7. QUESTION NOT VISIBLE , multiple options
a. driver.get(“URL”)
b. driver.navigate().to(“URL”)
c. driver.navigate(“URL”)
d. driver.getUrl(“URL”)
e. driver.setUrl(“URL”)
f. Sarah is coding in a test scenario, in which she must fetch the booking id as a text
message from the span element.
The web element looks like
<Space> order completed with Booking id:6665<Space>
Help Sarah to find a method from the webdriver library to fetch the booking ID?
Ans - getText();
g. James is automating a script and using CSS Selector as a locator. What are the
primitive types for designing the CSS selector?
ANS - .id, .Attribute, .innerText()
(Explanation - There are 5 types of CSS Selectors in Selenium tests-
ID, Class, Attribute, Sub-String, Inner Text)
h. Which expression is used in CSS Selectors to match the attribute value with a prefix?
ANS- ^=
(Explanation - [attr^=value] Represents elements with an attribute name of attr whose value
is prefixed (preceded) by value.)
k. Identify the correct way of launching the Chrome browser through WebDriver instance
with the correct property.
ANS -
System.setProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe
");
WebDriver driver = new ChromeDriver();
l. Samantha wants to write an automation script that determines the count of Hobbies
checkboxes. These checkboxes have a name attribute as “hobbies”. Assist Samantha
by choosing the correct command.
ANS –
driver.findElements(By.name(“hobbies”)).size()
m. Henry is designing a script and using CSS Selector as the locator strategy. He must
locate the element effectively. The element inspected looks like:
<input id=“newPassword” type=“password”>
ANS - By.cssSelector("input[id='newPassword']")
n. Kevin is automating a test scenario. In which he wants to locate an element with the
class attribute “classg1 jkyu_90”. Assist Kevin in setting up the correct locator for the
element.
ANS - By.className(“classg1”)
o. Select the correct order of execution of annotations, as per the life cycle of the TestNG
which can be applied for test methods along with beforeXXXX – afterXXXX methods.
ANS - @BeforeTest, @BeforeClass, @BeforeMethod, @Test, @AfterMethod, @AfterClass,
@AfterTest
p. Sean is coding an automation script for emulating user actions by mouse actions using
webdriver library. Assist Sean to choose the correct syntax to create an object for
Actions class from the following options.
ANS -
Actions act = new Actions(driverinstance)
Actions act = new Actions()
Actions act = (Actions)driverinstance
q. Kevin is using a CSS Selector as a locator strategy for the following element:
<h1 id=“msg01” name=“success”>Registration completed</h1>
He must identify the element effectively.
ANS –
By.cssSelector(“h1[id=‘msg01’]”)
By.cssSelector(“h1[id=‘msg01’][name=‘success’]”)
89. Which of the following reports can be generated using plugins from Cucumber options?
90. James wants to design a scenario in a feature file, in which the complete scenario runs multiple
times for different data sets . Suggest James with a Gherkin keyword to activate drop-down testing
in the feature file ?
91. Jack had created the feature file with the below mentioned scenarios as shown below:
@crash Scenario: This is the second scenario In test runner class, Jack mentioned
@cucumberoptions (tags=(“smoke”)) predict which scenario is/are gets executed
92.Which of the following is the logical container that contains all the elements which drive the
performance test?
Ans: Load Testing Correct But, If Test Plan Available in option, Then, the correct Ans
will be Test Plan.
95. Which of the following input documents is used to create test scenarios and conditions?
96. Which of the following Java classes are from the extent API library?
97. Sean is coding to automate a web application using the webDriver library. He had set the implicit
wait of 30 seconds. However, the webelement was found / Test Plan correct correct correct Google :
ExtentReports correct within 10s . Will the webdriver wait for further 20 seconds before executing
the next line of code?
1) Which java enum is used to handle the keyboard strokes from webdriver library?
(a) Actions
(b) Keyboard
(c) Keys
(d) Keyword
2) Which expression is used in CSS selectors to match attribute value with a prefix?
(a)$=
(b)^=
(c)*=
(d)none
Ans: (b) ^=
3) Samantha wants to automate selection of valur from a drop…..
<html>
<body>
<select name=”jobrole”>
<option value=”1”>Manager</option>
<option value=”2”>Lead</option>
<option value=”3”>Analyst</option>
</select>
</body>
</html>
Ans: SelectByVisibleText(“Lead”)
SelectByValue(“2)
4) Sarah is coding an automation script to switch to IFRAME in a web application .Which of the
listed options(s) will help sarah to switch to a particular frame on a web page using the
webdriver library?
(a )driver.switchTo().frame(int index)
(b) driver.switchTo().frame(string nameOrld)
( c) driver.switchTo().frame(WebElement frameElement)
(d)driver.switchTo().frame()
(e) driver.switchTo().frame(String name)
ANS: (a) , (b), (c)
(a)ppt
(b)docs
(c)…
(d)…
Ans: POIFS
@beforeMethod
Public void method1() {…}
@afterMethod
@Test(dataProvider=”loginData”)
@data provider
****7) which method is used in apache poi library to fetch the cell value from a row? identify the
format of invoking the library functions to get value from a cell
(a)sheet.getStringCellValue()
(b) sheet.get(rowno).getstringCellvalue()
(d) sheet.get(rowno).getCell(colon).getstringCellvalue()
Ans : (c)
1. Samantha has to execute automation scripts across multiple platforms like windows, mac,
Linux which tool in the selenium suite will be used by Samantha?
Choose the most appropriate option.
Ans selenium RC
2. George is reviewing the quality of the java code given to him using SonarQube and
described that the variables are named without following java variables naming
convention. Under which category this issue can be tracked in the tool?
Choose the most appropriate option.
Ans minor
3. Identify the correct flow of jenkins build, when a maven project job in Jenkins is triggered
for build
Ans testing.xml->pom.xml>testing classes>reports
4. Sarah is coding to automate a scenario for the selection of the “from Cities” drop down
box on the flight booking application web page, which class is used?
Ans Select Class
5. Sarah is coding in a test scenario, in which she must fetch the booking id as a text message
from the span element The web element looks like <Space> order completed with Booking
id:6665<Space> Help Sarah to find a method from the webdriver library to fetch the
booking ID?
Ans get Text();
6. Which expression is used in CSS Selectors to match the attribute value with a prefix?
Ans ^=
1. Samantha has designed a TestClass with the following methods:
@BeforeMethod
@AfterMethod
@Test(dataProvider=”loginData”)
@DataProvider
Suppose loginData() generates 5 sets of login credentials, how many times method1, method2 and
method 3 would be executed ?
2. Sarah is coding an automation script to switch to iFRAME in a web application. Which of the listed
options will help Sarah to switch to a particular frame on a web page using the webdriver library?
Choose the appropriate options.
a) driver.switchTo().frame(int index)
b) driver.switchTo().frame(String name Or id)
c) driver.switchTo().frame(WebElement frameElement)
d) driver.switchTo().frame()
e) driver.switchTo().iframe(String name)
3. Sean is coding to automate mouse interactions on a web browser. Assist Sean to identify the mouse
event specific methods from the below options.
a) moveToElement()
b) moveByOffset()
c) release()
d) keyUp()
e) keyDown()
f) sendKeys()
4. What method in the Web driver library is used to get the attribute value of a web element?
a) getAttributeValue(“attributeName”)
b) getAttribute(“attributeName”)
c) getValue(“attributeName”)
d) getText()
6. Sarah is coding to automate a test scenario in which she must fetch the booking id as a text
message from the span element.
The web element looks like: <span>Order Completed With Booking ID:6665</span>
Help Sarah to find a method from the WebDriver Library to fetch the Booking ID.
a) getValue()
b) getID()
c) getText()
d) getTagName()
7. George is reviewing the quality of the Java code given to him using SonarQube and identified that
the variables are named without following java variable naming convention rules. Under which
category this issue can be tracked in the tool?
Choose the most appropriate option.
a) Info
b) Minor
c) Major
d) Critical
e) Sarah as an automation engineer triggers a new build from Jenkins as a maven project
having source codes in git repository which of the following tools/ Software are required
to be configured by Sarah in Jenkins to make the build success.
Ans: jre , jdk ,meavon
f) Henry is designing a script and using css selector as the locator strategy. He must locate
the element effectively. The element inspected looks like
<input id =”new Password” type =”password”>
Choose the most appropriate option.
ans: By.CssSelector(“input[id=’password’]”)
g) There is an element on the web page when inspected on the browser it looks like
<div class=”errorMsg”>Error Message</div> James want to use selenium locators to
identify the element. Choose the correct set of commands to locate the element
effectively.
Ans: By.CssSelector(“div.errorMsg”)
h) Match the following tools with the correct description
ans: A-3 B-1 C-2
i) When verification fails in TestNG, what forces the test to stop execution and mark as
failed. Choose the most appropriate option.
Ans: Assertion Fail
j) Which java enum is used to handle the keyboard strokes from web driver library? Choose
the most appropriate option.
Ans: keys
1) Testing an automation script to test a web application. He has to store the Logout link in the
using a driver.findElement() method. Suggest Sean with a compatible return to leg out least
object.
(a) String
(b) WebDriver
(c) WebElement
(d) List
Sub-topic: TestNG
2) Which of the following is correct about generating about an XML suite file in TestNG for Test
Suite Exception.
(a) TestNG XML suite can be generated at time of creating TestNG class.
(b) TestNG XML suite can be generated using "Convert to testNG" option..........class is
created.
(c) TestNG XML suite file is automatically generated when user create a maven java project.
(d) There is no option in Eclipse to generate XML suite file.
(e) TestNG XML suite file can be generated by Jenkins
Ans: (a) TestNG XML suite can be generated at time of creating TestNG class.
(b) TestNG XML suite can be generated using "Convert to testNG" option..........class is
created.
Sub-topics: Switching to windows
(a) List<String>
(b) Set<String>
(c) Array<String>
(d) Window<String>
4) Kevin wants to generate expensive report for the test automation project. He decides to use
Extent Report Library. Which class in the library is used to create labels, code blocks and
tables in the report?
(a). ExtentHtmlReporter.
(b). ExtentReports
(c). MarkupHelper
(d). ExtentTest.
Ans: ( c) MarkupHelper.
5) Sean is coding an automation Script to launch the web application on a browser window.
Which of the following listed option(s) will help Sean to lunch the desired application on a
web browser in selenium?
(a). driver.get(“URL”)
(b). driver.navigate().to(“URL”)
(c). driver.navigate(“URL”)
(d). driver.getUrl(“URL”)
(e). driver.setUrl(“URL”)
(b) driver.navigate().to("URL")
Sarah wants to locate the 3rd child element i.e Hydrabad. Suggest the appropriate locator stratgy
for
Sarah.
7) James wants to automate the selection of ID proofs drop-down box in the web application.
He has to verify the drop-down has a selection of more than one option. Which of the
following method is suggested to James?
Ans : isMultiple()
8) Kavin is using CSS selector as a locator strategy for the following element: <h1 id”msg01”
name=”success” > Registeration Completed </h1>
Ans: By.cssSelector("h1[id='msg01']")
By.cssSelector("h1[id='msg01'][name='success']")
1) Which is an IDE extension that helps you detect and fix quality issues as you write code in
python/HTML/Javascript/PHP?
SonarQube
SonarLint
SonarQubeServer
2) Sarah is coding an automation script to switch to iFRAME in a web application. Which of the
listed options will help sarah to switch to a particular frame on a web page using the library?
driver.switchTo().frame(int index)
driver.switchTo().frame(String nameOrld)
driver.switchTo().frame(Webelement frameElement)
driver.switchTo().frame()
driver.switchTo().iframe(String name)
Please check the correct command to help Kevin in automating this scenario. Assume that
text box element is already identified and stored in mobileTxtBox variable.
mobileTxtBox.clear(); mobileTxtBox.sendKeys(“9090909090”);
mobileTxtBox.sendKeys(“9090909090”);
mobileTxtBox.sendKeys(“9090909090”);mobileTxtBox.clear();
mobileTxtBox.value=”9090909090”;
4) Which Java enum is used to handle the keyboard strokes from WebDriver Library?
Actions
Keyboard
Keys
Keyword
1. Which java interface is used to capture screenshot of a web page using web driver API ?
Ans: TakeScreenshot
2. Henry is designing a script and using CSS Selector as the locator strategy. He must locate the
element effectively. The element inspected looks like:
<input id=“newPassword” type=“password”>
ANS : By.cssSelector("input[id='newPassword']")
3. Select the correct order of execution of annotations, as per the life cycle of the TestNG
which can be applied for test methods along with beforeXXXX – afterXXXX methods.
ANS :@BeforeTest, @BeforeClass, @BeforeMethod, @Test, @AfterMethod, @AfterClass,
@AfterTest
4. Kevin is using a CSS Selector as a locator strategy for the following element:
<h1 id=“msg01” name=“success”>Registration completed</h1>
He must identify the element effectively.
ANS :By.cssSelector(“h1[id=‘msg01’]”), By.cssSelector(“h1[id=‘msg01’][name=‘success’]”.
5. Testing an automation script to test a web application. He has to store the Logout link in the
using a driver.findElement() method. Suggest Sean with a compatible return to leg out least
object.
Ans:WebElement
6. While using soft assertion in the test class, james must specify a method, that will collate
and display assertion results
Ans:assertAll()
7. Sarah is coding to automate a test scenario in which she must fetch the booking id as a text
message from the span element.
The web element looks like: <span>Order Completed With Booking ID:6665</span>
Help Sarah to find a method from the WebDriver Library to fetch the Booking ID.
Ans: getText()
8. Sean is coding to automate mouse interactions on a web browser. Assist Sean to identify the
mouse event specific methods from the below options.
Ans: moveToElement(),moveByOffset(),release()
9. Which date format is used to customize the system data to year-month-day format?
ANS:new SimpleDateFormat(“yyyy-MM-dd”)
10. What are the various status options available in the Extent reports library?
Ans:PASS,FAIL,SKIP,FATAL,ERROR,WARNING,INFO
11. James is automating a script and using CSS Selector as a locator. What are the primitive
types for designing the CSS selector?
ANS - .id, .Attribute, .innerText()
12. Sam has created a TestNG project with below specified TestClass.
public class TestClass {
@Test(priority=1)
public void method1() {….}
@Test
public void method3() {….}
@Test
public void method2() {….}
@Test(priority=2)
public void method4() {….}
}Predict the test method execution sequence.Choose the most appropriate
option.Ans:method2, method3, method1, method4.
Q:1 Sarah wants to automate the selection of only one option from a dropdown box as shown below
<html>
<body>
<select multiple>
<option value=”web”>html</option>
<option value=”prog”>python</option>
<option value=”prog”>java</option>
<option value=”prog”>python</option>
<option value=”prog”>java</option>
</select>
</body>
</html>.
Sarah has to select only the fourth option,i.e,python from the options field.
Ans: selectByVisibleText()
selectByValue()
selectByIndex()
All of the above
Q2: Sean is automating a test scenario, in which he has to fetch the URL of the web page using
WebDriver API. Suggest a method for Sean to get the link address
Ans:-getURL()
get()
getCurrentURL()
getURI()
Q3: Sean configured his project for the test suite execution using TestNG. He wants to perform
parallel execution of the test cases. Which attribute represents the parallel execution of the test
cases?
a parallel = “methods”
b parallel="tests"
c parallel = “test-classes”
d parallel =”test-cases”
Q4: Fuller has written an automation script using selenium webdriver commands. He has used all the
necessary and appropriate locators for interacting with the web elements. When he executed the
script the web driver was not able to locate an element resulting in the test script failure. Which
error/ exception is thrown by webdriver?
NoSuchElementException
NoSuchElementError
NullPointerException
ObjectNotFoundException
Q5: Kevin is designing an automation test, where test data is specified in an external excel file.
Which command will be helpful to write the data into a cell of the excel file? Assume c1 is the cell
object.
a c1.setCellValue("data")
b c1.setValue(“data”)
c c1.writeCellValue(“data”)
d c1.setCellData(“data”)
Q6: Which of the following is correct about generating about an XML suite file in TestNG for Test
Suite Exception.
(a) TestNG XML suite can be generated at time of creating TestNG class.
(b) TestNG XML suite can be generated using "Convert to testNG" option..........class is
created.
(c) TestNG XML suite file is automatically generated when user create a maven java
project.
(d) There is no option in Eclipse to generate XML suite file.
Q7: Which of the following Java classes are from the Extent API library?
ExtentReports
Status
TakesScreenshot
Actions
Q8: Sean wants to switch to multiple frames on a web page when an operation is completed on a
frame and test flow needs to move to another frame. Calling the driver.switch To().frame()
immediately will not move the context to the next frame which is at the same level in DOM. The
test will first need to switch to the main document and then activate the desired frame. Which
method is used to switch back to the main document from the frame?
driver.switch To().mainDocument()
driver.switchTo().defaultContent()
Q9: Sam is designing an automation test, where test data is specified in an external excel file. Which
command will be helpful to get across to the 2nd sheet of excel file. Assume wb is the workbook
object.
a wb.getSheetAt(1)
b wb.getSheetAt(2)
c wb.getSheet(1)
d wb.getSheet(2)
Q10: Sean is performing verification using Assert class functions from TestNG. Suggest him the
corect method to verify the reference/address of the two objects to be identical
assert True(Object1,Object2)
assertRef(Obect1,Object2)
assertEquals(Object1,Object2)
assertSame(Object1,Object2)
Q11: Sean is coding an automation Script to launch the web application on a browser window.
Which of the following listed option(s) will help Sean to lunch the desired application on a web
browser in selenium?
(a). driver.get(“URL”)
(b). driver.navigate().to(“URL”)
(c). driver.navigate(“URL”)
(d). driver.getUrl(“URL”)
(e). driver.setUrl(“URL”)
Q12: Sarah is coding an automation Script to locate a child element in an unordered list. The list is
given below:
<html>
<body>
<ul class=”cities”>
<li>Bangalore</li>
<li>Chennai</li>
<li>Hydrabad</li>
<li>Mumbai</li>
<li>Pune</li>
</ul>
</body>
</html>
Sarah wants to locate the 3rd child element i.e Hydrabad. Suggest the appropriate locator stratgy
for
Sarah.
Q13: Sarah is coding an automation script, where she has to validate the price of the holiday
package based on the drag & drop of island city from the menu. The Price is fetched from the
server and displays without reloading the web page. Which WebDriver Library class has the
predefined conditions for handling dynamic waits in Selenium WebDriver Library?
ExplicitWait
ImplicitWait
WebDriverWait
Expected Conditions
Q14: What are the various status options available in the Extent reports library?
e. PASS,FAIL,SKIP,FATAL,ERROR,WARNING,INFO
f. SUCCESS,FAIL,SKIP ,ERROR,WARNING,INFO
g. DONE,DEBUG,FAIL,SKIP,ERROR,WARNING,INFO
h. ABORT,PASS,FAIL,DONE,ERROR,WARNING,INFO
Q15: Kevin wants to fetch all the data from the country drop down menu and verify the data against
data from the database. He is looking into the library for a method to fetch all the data from the
country drop down box. Which method will help Kevin?
f. selectAllOptions()
g. getOptions()
h. getAllOptions()
i. getData()
j. getText()
Q16: Which java interface is used to capture screenshot of a web page using Web Driver API?
ANS: TakeScreenshot
Q17: There is an element on the webpages when inspected on the browser it looks like <div
call=”errorMsg”>Error Message</div>.
James wants to use selenium locations to identify the element. Choose the correct set of commands
to locate the elements efficiently.
Ans:-By. CssSelector(“id=newPassword”)
By .CssSelector(“input.newPassword”)
By .CssSelector(“input_newPassword”)
By .CssSelector(“input[id$=’Password’]”)
Q19: Kevin is using a CSS Selector as a locator strategy for the following element:
Q20: Select the correct order of execution of annotations, as per the life cycle of the TestNG which
can be applied for test methods along with beforeXXXX – afterXXXX methods.
ANS - @BeforeTest, @BeforeClass, @BeforeMethod, @Test, @AfterMethod, @AfterClass,
@AfterTest
Q21: Testing an automation script to test a web application. He has to store the Logout link in the
using a driver.findElement() method. Suggest Sean with a compatible return to leg out least object.
(a) String
(b) WebDriver
(c) WebElement
(d) List
1Q) Sean is coding an automation script to test a web application. He has to store the Logout Ink in
a Java vanable using a driver findElement() method. Suggest Sean with a compatible return
a) String
b) WebDnver
c) WebElement
d) List
a) By.className('style1’)
b) By.id(‘Email')
c) By.name(‘Email’)
d) By.xpath(‘//label[@id='Email’]’)
3Q) James is automating a scnpt and using CSS Seleclor as a localor. What are the primitive types
a) Id
b) Attribute
c) Inner Text
d) Tagname
3Q) Sean is performing verification using Assert class functions from TesTNG. Suggest him the
a) assert True(Object1.Object2)
b) assertRef(Obect1, Object2)
c) assertEquals(Object1, Object2)
d) assertSame(Object1, Object2)
4Q)Sean is coding an automation script for emulating user actions by mouse using the webdriver
library. Assist Sean to choose the correct syntax to create an object for Actions class from the
following options
c) new Actions(driverInstance)
d) Actions act=(Actions)driverInstance
e) Aclions.callMethods()
5Q) Samantha wants to write an automation script that determines the count of Hobbies
a) driver.findElement(By.name("hobbies")).getCount()
b) driver.findElement(By.name("hobbies")).size()
c) driver.findElement(By.name("hobbies")).length()
d) driver.findElements(By.name("hobbies")).getCount()
e) driver.findElements(By.name("hobbies")).size()
6Q) Which Java Interface is used to capture screenshot of a web page using Web Driver API?
a) ScreenShot
b) Capture
c) TakesScreenshot
d) Image
7Q) Which date fomat is used to customize the system date to year-month-day format?
a) new SimpleDateFormat("yyyy-mm-dd")
b) new SimpleDateFormat("yyyy-MM-dd")
c) new SimpleDateFormat("yyyy-month-dd")
d) new SimpleDateFormat("yyyy-mmm-dd")
8Q) Sarah is coding an automation script to switch to IFRAME in a web application. Which of the
listed option(s) will help Sarah to switch to a particular frame on a web page using the webdriver
library?
9Q) Identify the correct way of launching the Chrome browser through WebDriver Instance with the
correct property
a) System.setProperty("webdriver.chrome.driver”, "src/test/resources");
b) System.setProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe");
System.setProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe");
d) System.getProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe");
A ExtentReports
B Status
C TakesScreenshot
D Actions
@Test
@Test
@Test
Kevin executes the above TestClass as a TestNG test. Which of the following correctly
12Q) Sarah coding a test script using TestNG classes. She has used all the necessary Assert
funtions to verify the test scripts When she executes the script. TestNG detected failures
Predict what type of message objects are thrown in the console as output?
A Exception Messages
B Error Messages
C Warning Messages
13Q) Sarah is validating the Registration Page for TestMe App using TestNG Assertions. She wants
to execute all the validation statements and display the status as Pass/Fail, along with failure
messages if any. Which type of assertions are recommended to Sarah for implementation
A Soft Assertions
B Hard Assertions
C Hard Exceptions
D Soft Exceptions
14Q) Kevin is automating a test scenario, in which he wants to locate an element with the class
attribute "classg1 jkyu_90". Assist Kevin in setting up the correct locator for the element.
By.className(“classg1 jkyu_90")
By.className(“classg1”)
By.class("classg1 jkyu_90”)
By.className(“jkyu_90")
15Q) Sarah is coding an automation script to switch to multiple windows in a web application. She
has to store all the window instances in a java variable which is returned by
driver.getWindowHandles(). Suggest Sarah with a compatible return type to store the window
references
List<String>
Set<String>
Array <String>
Window< String>
16Q) Sam is designing an automation test, where test data is specified in an external excel file.
Which command will be helpful to get across to the 2nd sheet of excel file. Assume wb is the
workbook object.
a wb.getSheetAt(1)
b wb.getSheetAt(2)
c wb.getSheet(1)
d wb.getSheet(2)
1…Sarah is coding a test script TESTNG classes she has ---ERROR MESSAGES
3…GIT CLONE
7….. which plugin can be used as an IDE (like eclipse extension that helps to detect and fix quality
issues-----SONARTLINT
11…..George is reviewinf=g the quality of the java code given to him using sonarqube an identified---
-MINOR
12….sarah wants to automate the selection of only one option from a drop ------SELECTBY INDEX
13….which of the following statement is tru about extent reports-----ALL THE ABOVE
14….has to execute automation scripts across multiple platforms like windows,mac,and linux.which
tool in-----SELENIUM GRID
15…… sean is performing verification using assert class functions testing.suggest him the correct …-
------ASSERTSAME(OBJECT1,OBJECT2)
SONARQUBE>OPEN-SOURCE
19---TAKESSCREENSHOT
20---ISMULTIPLE()
21---NOSUCHELEMENTEXCEPTION
22----MARKUPHELPER
24…EXTENTREPORTS ,STATUS
SELENIUM
1. Sean is coding to automate a web application using the webDriver library. He had set the implicit
wait of 30 seconds. However, the webelement was found within 10s. Will the webdriver wait for
further 20 seconds before executing the next line of code?
2. Which method is used in the Apache POI library to fetch the cell value from a row? Identify the
correct format of invoking the library functions to get the value from the cell
3. Sarah is coding to automate script to switch to multiple windows in a web application. She has to
store all the window instances in a java variable which is retrived by driver.getWindowHandles().
Suggest sarah with a compatable return type to store the window references.
Ans:Set <string>
4. sarah has her code in git local repository, but her team lead had pushed the new changes into the
remote repository, Which git command would you recommend Sarah with new changes into her
working copy?
Ans: add
5. Sean is automating a test scenario in which he has to fetch the URL of the webpage using
webDriver API. Suggest a method fo Sean to get the link address
Ans: getCurrentURL()
6. Mary is struggling to find a suitable simple wild cart character that matches any single character.
Please suggest to her which of the following characters many be relevant to her search
1) Which of the following is correct about generating XML suite file in testNG for Test Suite
Execution
a TestNG XML Suite file can be generated at the time of creating a TestNG class.
b TestNG XML Suite file can be generated using ‘convert to TestNG’ option in Eclipse after a java
class is created.
c TestNG XML Suite file can be automatically generated when user creates a maven java project
a driver.get(“url”)
b driver.navigate().to(“URL”)
c driver.navigate(“URL”)
d driver.getUrl(“URL”)
e driver.setUrl(“URL”)
3) Sam is designing an automation test, where test data is specified in an external excel file. Which
command will be helpful to get across to the 2nd sheet of excel file. Assume wb is the workbook
object.
a wb.getSheetAt(1)
b wb.getSheetAt(2)
c wb.getSheet(1)
d wb.getSheet(2)
4)Sean configured his project for the test suite execution using TestNG. He wants to perform parallel
execution of the test cases. Which attribute represents the parallel execution of the test cases?
a parallel = “methods”
b parallel="tests"
c parallel = “test-classes”
d parallel =”test-cases”
5) Kevin is designing an automation test, where test data is specified in an external excel file. Which
command will be helpful to write the data into a cell of the excel file? Assume c1 is the cell object.
a c1.setCellValue("data")
b c1.setValue(“data”)
c c1.writeCellValue(“data”)
d c1.setCellData(“data”)
6) Sarah wants to automate the selection of only one option from a drop-down box as shown
below.
<html>
<body>
<select multiple>
</select>
</body>
</html>
Sarah has to select only the fourth option i.e. python from the option list .
a selectByVisibleText()
b selectByValue()
c selectByIndex()
DDT
Sam is designing an automation test, where test data is specified in an external excel file. Which
command will be helpful to get access to the 2nd sheet of the excel file. Assume wb Is the workbook
object
wb.getSheetAt(1)
wb.getSheetAt(2)
wb.getSheet(1)
wb.getSheet(1)
EXTENT REPORTS
Which of the following Java classes are from the Extent API library?
ExtentReports
Status
TakesScreenshot
Actions
SWITCHING TO WINDOWS
Which of the following methods is used to close all the opened windows of WebDriver Instance?
Close()
Quit()
Null()
Sleep()
ACTIONS
Sean is coding an automation script for emulating user actions by mouse using the webdriver library.
Assist Sean to choose correct syntax to create an object for actions class from the following options
New Actions(driverInstance)
Actions.callMethods()
EXTENT REPORTS
Which date format is used to customize the system data to year-month-day format?
new SimpleDateFormat(“yyyy-mm-dd”)
new SimpleDateFormat(“yyyy-MM-dd”)
new SimpleDateFormat(“yyyy-month-dd”)
new SimpleDateFormat(“yyyy-mmm-dd”)
WEBDRIVER API
Fuller has written an automation script using selenium webdriver commands. He has used all the
necessary and appropriate locators for interacting with the web elements. When he executed the
script the web driver was not able to locate an element resulting in the test script failure. Which
error/ exception is thrown by webdriver?
NoSuchElementException
NoSuchElementError
NullPointerException
ObjectNotFoundException
WEBDRIVER API
Samantha wants to automate selection of value from a drop down menu. When the element was
Inspected. She foundAgain
<html>
<body>
<select name=”jobrole”>
<option value=”2”>Lead</option>
<option value=”3”>Analyst</option>
</select>
</body>
<html>
Choose “lead” as the test data. Assist her by choosing the correct options.
selectByIndex(1)
selectByValue(2)
selectByVisibleText(“Lead”)
selectByValue(“2”)
Q1- Which expression is used in CSS selectors to match the attribute value with a prefix?
Ans: ^
@Test(priority=1)
@Test
@Test
@Test(priority=2)
Ans: method2,method3,method1,method4
1. Which java enum is used to handle the keyboard strokes from webdriver library?
a. Actions
b. Keyboard
c. Keys
d. Keyword
2. Sam is designing an automation test, where test data is specified in an external excelfile.
Which command will be helpful to get access to the 2 nd sheet of the excel file. Assume wb is
workbook object.
a. wb.getSheetAt(1)
b. wb.getSheetAt(2)
c. wb.getSheet(1)
d. wb.getSheet(2)
3. sarah wants to automate the selection of only one option from a drop down box as shown
below
<html>
<body>
<select multiple>
<option value=”web”>html</option>
<option value=”prog”>python</option>
<option value=”prog”>java</option>
<option value=”prog”>python</option>
<option value=”prog”>java</option>
</select>
</body>
</html>
Sarah has to select only the fourth option that is python from the options list
a. selectByVisibleText()
b. selectByValue ()
c. selectByIndex()
d. all the above
4. What are the various status options available in the Extent reports library?
a. PASS,FAIL,SKIP,FATAL,ERROR,WARNING,INFO
b. SUCCESS,FAIL,SKIP ,ERROR,WARNING,INFO
c. DONE,DEBUG,FAIL,SKIP,ERROR,WARNING,INFO
d. ABORT,PASS,FAIL,DONE,ERROR,WARNING,INFO
5. Sean is automating a test scenario, in which he has to fetch the URL of the web page using
WebDriver API . Suggest a method for Sean to get the link address.
a. getURL()
b. get()
c. getCurrentURL()
d. getURL()
6. Kevin wants to fetch all the data from the country drop down menu and verify the data
against data from the database. He is looking into the library for a method to fetch all the
data from the country drop down box. Which method will help Kevin?
a. selectAllOptions()
b. getOptions()
c. getAllOptions()
d. getData()
e. getText()
7. QUESTION NOT VISIBLE , multiple options
a. driver.get(“URL”)
b. driver.navigate().to(“URL”)
c. driver.navigate(“URL”)
d. driver.getUrl(“URL”)
e. driver.setUrl(“URL”)
f. Sarah is coding in a test scenario, in which she must fetch the booking id as a text
message from the span element.
The web element looks like
<Space> order completed with Booking id:6665<Space>
Help Sarah to find a method from the webdriver library to fetch the booking ID?
Ans - getText();
g. James is automating a script and using CSS Selector as a locator. What are the
primitive types for designing the CSS selector?
ANS - .id, .Attribute, .innerText()
(Explanation - There are 5 types of CSS Selectors in Selenium tests-
ID, Class, Attribute, Sub-String, Inner Text)
h. Which expression is used in CSS Selectors to match the attribute value with a prefix?
ANS- ^=
(Explanation - [attr^=value] Represents elements with an attribute name of attr whose value
is prefixed (preceded) by value.)
k. Identify the correct way of launching the Chrome browser through WebDriver instance
with the correct property.
ANS -
System.setProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe
");
WebDriver driver = new ChromeDriver();
l. Samantha wants to write an automation script that determines the count of Hobbies
checkboxes. These checkboxes have a name attribute as “hobbies”. Assist Samantha
by choosing the correct command.
ANS –
driver.findElements(By.name(“hobbies”)).size()
m. Henry is designing a script and using CSS Selector as the locator strategy. He must
locate the element effectively. The element inspected looks like:
<input id=“newPassword” type=“password”>
ANS - By.cssSelector("input[id='newPassword']")
n. Kevin is automating a test scenario. In which he wants to locate an element with the
class attribute “classg1 jkyu_90”. Assist Kevin in setting up the correct locator for the
element.
ANS - By.className(“classg1”)
o. Select the correct order of execution of annotations, as per the life cycle of the TestNG
which can be applied for test methods along with beforeXXXX – afterXXXX methods.
ANS - @BeforeTest, @BeforeClass, @BeforeMethod, @Test, @AfterMethod, @AfterClass,
@AfterTest
p. Sean is coding an automation script for emulating user actions by mouse actions using
webdriver library. Assist Sean to choose the correct syntax to create an object for
Actions class from the following options.
ANS -
Actions act = new Actions(driverinstance)
Actions act = new Actions()
Actions act = (Actions)driverinstance
q. Kevin is using a CSS Selector as a locator strategy for the following element:
<h1 id=“msg01” name=“success”>Registration completed</h1>
He must identify the element effectively.
ANS –
By.cssSelector(“h1[id=‘msg01’]”)
By.cssSelector(“h1[id=‘msg01’][name=‘success’]”)
89. Which of the following reports can be generated using plugins from Cucumber options?
90. James wants to design a scenario in a feature file, in which the complete scenario runs multiple
times for different data sets . Suggest James with a Gherkin keyword to activate drop-down testing
in the feature file ?
91. Jack had created the feature file with the below mentioned scenarios as shown below:
@crash Scenario: This is the second scenario In test runner class, Jack mentioned
@cucumberoptions (tags=(“smoke”)) predict which scenario is/are gets executed
92.Which of the following is the logical container that contains all the elements which drive the
performance test?
Ans: Load Testing Correct But, If Test Plan Available in option, Then, the correct Ans
will be Test Plan.
95. Which of the following input documents is used to create test scenarios and conditions?
96. Which of the following Java classes are from the extent API library?
97. Sean is coding to automate a web application using the webDriver library. He had set the implicit
wait of 30 seconds. However, the webelement was found / Test Plan correct correct correct Google :
ExtentReports correct within 10s . Will the webdriver wait for further 20 seconds before executing
the next line of code?
1) Which java enum is used to handle the keyboard strokes from webdriver library?
(a) Actions
(b) Keyboard
(c) Keys
(d) Keyword
2) Which expression is used in CSS selectors to match attribute value with a prefix?
(a)$=
(b)^=
(c)*=
(d)none
Ans: (b) ^=
3) Samantha wants to automate selection of valur from a drop…..
<html>
<body>
<select name=”jobrole”>
<option value=”1”>Manager</option>
<option value=”2”>Lead</option>
<option value=”3”>Analyst</option>
</select>
</body>
</html>
Ans: SelectByVisibleText(“Lead”)
SelectByValue(“2)
4) Sarah is coding an automation script to switch to IFRAME in a web application .Which of the
listed options(s) will help sarah to switch to a particular frame on a web page using the
webdriver library?
(a )driver.switchTo().frame(int index)
(b) driver.switchTo().frame(string nameOrld)
( c) driver.switchTo().frame(WebElement frameElement)
(d)driver.switchTo().frame()
(e) driver.switchTo().frame(String name)
ANS: (a) , (b), (c)
(a)ppt
(b)docs
(c)…
(d)…
Ans: POIFS
@beforeMethod
Public void method1() {…}
@afterMethod
@Test(dataProvider=”loginData”)
@data provider
****7) which method is used in apache poi library to fetch the cell value from a row? identify the
format of invoking the library functions to get value from a cell
(a)sheet.getStringCellValue()
(b) sheet.get(rowno).getstringCellvalue()
(d) sheet.get(rowno).getCell(colon).getstringCellvalue()
Ans : (c)
1. Samantha has to execute automation scripts across multiple platforms like windows, mac,
Linux which tool in the selenium suite will be used by Samantha?
Choose the most appropriate option.
Ans selenium RC
2. George is reviewing the quality of the java code given to him using SonarQube and
described that the variables are named without following java variables naming
convention. Under which category this issue can be tracked in the tool?
Choose the most appropriate option.
Ans minor
3. Identify the correct flow of jenkins build, when a maven project job in Jenkins is triggered
for build
Ans testing.xml->pom.xml>testing classes>reports
4. Sarah is coding to automate a scenario for the selection of the “from Cities” drop down
box on the flight booking application web page, which class is used?
Ans Select Class
5. Sarah is coding in a test scenario, in which she must fetch the booking id as a text message
from the span element The web element looks like <Space> order completed with Booking
id:6665<Space> Help Sarah to find a method from the webdriver library to fetch the
booking ID?
Ans get Text();
6. Which expression is used in CSS Selectors to match the attribute value with a prefix?
Ans ^=
1. Samantha has designed a TestClass with the following methods:
@BeforeMethod
@AfterMethod
@Test(dataProvider=”loginData”)
@DataProvider
Suppose loginData() generates 5 sets of login credentials, how many times method1, method2 and
method 3 would be executed ?
2. Sarah is coding an automation script to switch to iFRAME in a web application. Which of the listed
options will help Sarah to switch to a particular frame on a web page using the webdriver library?
Choose the appropriate options.
a) driver.switchTo().frame(int index)
b) driver.switchTo().frame(String name Or id)
c) driver.switchTo().frame(WebElement frameElement)
d) driver.switchTo().frame()
e) driver.switchTo().iframe(String name)
3. Sean is coding to automate mouse interactions on a web browser. Assist Sean to identify the mouse
event specific methods from the below options.
a) moveToElement()
b) moveByOffset()
c) release()
d) keyUp()
e) keyDown()
f) sendKeys()
4. What method in the Web driver library is used to get the attribute value of a web element?
a) getAttributeValue(“attributeName”)
b) getAttribute(“attributeName”)
c) getValue(“attributeName”)
d) getText()
6. Sarah is coding to automate a test scenario in which she must fetch the booking id as a text
message from the span element.
The web element looks like: <span>Order Completed With Booking ID:6665</span>
Help Sarah to find a method from the WebDriver Library to fetch the Booking ID.
a) getValue()
b) getID()
c) getText()
d) getTagName()
7. George is reviewing the quality of the Java code given to him using SonarQube and identified that
the variables are named without following java variable naming convention rules. Under which
category this issue can be tracked in the tool?
Choose the most appropriate option.
a) Info
b) Minor
c) Major
d) Critical
e) Sarah as an automation engineer triggers a new build from Jenkins as a maven project
having source codes in git repository which of the following tools/ Software are required
to be configured by Sarah in Jenkins to make the build success.
Ans: jre , jdk ,meavon
f) Henry is designing a script and using css selector as the locator strategy. He must locate
the element effectively. The element inspected looks like
<input id =”new Password” type =”password”>
Choose the most appropriate option.
ans: By.CssSelector(“input[id=’password’]”)
g) There is an element on the web page when inspected on the browser it looks like
<div class=”errorMsg”>Error Message</div> James want to use selenium locators to
identify the element. Choose the correct set of commands to locate the element
effectively.
Ans: By.CssSelector(“div.errorMsg”)
h) Match the following tools with the correct description
ans: A-3 B-1 C-2
i) When verification fails in TestNG, what forces the test to stop execution and mark as
failed. Choose the most appropriate option.
Ans: Assertion Fail
j) Which java enum is used to handle the keyboard strokes from web driver library? Choose
the most appropriate option.
Ans: keys
1) Testing an automation script to test a web application. He has to store the Logout link in the
using a driver.findElement() method. Suggest Sean with a compatible return to leg out least
object.
(a) String
(b) WebDriver
(c) WebElement
(d) List
Sub-topic: TestNG
2) Which of the following is correct about generating about an XML suite file in TestNG for Test
Suite Exception.
(a) TestNG XML suite can be generated at time of creating TestNG class.
(b) TestNG XML suite can be generated using "Convert to testNG" option..........class is
created.
(c) TestNG XML suite file is automatically generated when user create a maven java project.
(d) There is no option in Eclipse to generate XML suite file.
(e) TestNG XML suite file can be generated by Jenkins
Ans: (a) TestNG XML suite can be generated at time of creating TestNG class.
(b) TestNG XML suite can be generated using "Convert to testNG" option..........class is
created.
Sub-topics: Switching to windows
(a) List<String>
(b) Set<String>
(c) Array<String>
(d) Window<String>
4) Kevin wants to generate expensive report for the test automation project. He decides to use
Extent Report Library. Which class in the library is used to create labels, code blocks and
tables in the report?
(a). ExtentHtmlReporter.
(b). ExtentReports
(c). MarkupHelper
(d). ExtentTest.
Ans: ( c) MarkupHelper.
5) Sean is coding an automation Script to launch the web application on a browser window.
Which of the following listed option(s) will help Sean to lunch the desired application on a
web browser in selenium?
(a). driver.get(“URL”)
(b). driver.navigate().to(“URL”)
(c). driver.navigate(“URL”)
(d). driver.getUrl(“URL”)
(e). driver.setUrl(“URL”)
(b) driver.navigate().to("URL")
Sarah wants to locate the 3rd child element i.e Hydrabad. Suggest the appropriate locator stratgy
for
Sarah.
7) James wants to automate the selection of ID proofs drop-down box in the web application.
He has to verify the drop-down has a selection of more than one option. Which of the
following method is suggested to James?
Ans : isMultiple()
8) Kavin is using CSS selector as a locator strategy for the following element: <h1 id”msg01”
name=”success” > Registeration Completed </h1>
Ans: By.cssSelector("h1[id='msg01']")
By.cssSelector("h1[id='msg01'][name='success']")
1) Which is an IDE extension that helps you detect and fix quality issues as you write code in
python/HTML/Javascript/PHP?
SonarQube
SonarLint
SonarQubeServer
2) Sarah is coding an automation script to switch to iFRAME in a web application. Which of the
listed options will help sarah to switch to a particular frame on a web page using the library?
driver.switchTo().frame(int index)
driver.switchTo().frame(String nameOrld)
driver.switchTo().frame(Webelement frameElement)
driver.switchTo().frame()
driver.switchTo().iframe(String name)
Please check the correct command to help Kevin in automating this scenario. Assume that
text box element is already identified and stored in mobileTxtBox variable.
mobileTxtBox.clear(); mobileTxtBox.sendKeys(“9090909090”);
mobileTxtBox.sendKeys(“9090909090”);
mobileTxtBox.sendKeys(“9090909090”);mobileTxtBox.clear();
mobileTxtBox.value=”9090909090”;
4) Which Java enum is used to handle the keyboard strokes from WebDriver Library?
Actions
Keyboard
Keys
Keyword
1. Which java interface is used to capture screenshot of a web page using web driver API ?
Ans: TakeScreenshot
2. Henry is designing a script and using CSS Selector as the locator strategy. He must locate the
element effectively. The element inspected looks like:
<input id=“newPassword” type=“password”>
ANS : By.cssSelector("input[id='newPassword']")
3. Select the correct order of execution of annotations, as per the life cycle of the TestNG
which can be applied for test methods along with beforeXXXX – afterXXXX methods.
ANS :@BeforeTest, @BeforeClass, @BeforeMethod, @Test, @AfterMethod, @AfterClass,
@AfterTest
4. Kevin is using a CSS Selector as a locator strategy for the following element:
<h1 id=“msg01” name=“success”>Registration completed</h1>
He must identify the element effectively.
ANS :By.cssSelector(“h1[id=‘msg01’]”), By.cssSelector(“h1[id=‘msg01’][name=‘success’]”.
5. Testing an automation script to test a web application. He has to store the Logout link in the
using a driver.findElement() method. Suggest Sean with a compatible return to leg out least
object.
Ans:WebElement
6. While using soft assertion in the test class, james must specify a method, that will collate
and display assertion results
Ans:assertAll()
7. Sarah is coding to automate a test scenario in which she must fetch the booking id as a text
message from the span element.
The web element looks like: <span>Order Completed With Booking ID:6665</span>
Help Sarah to find a method from the WebDriver Library to fetch the Booking ID.
Ans: getText()
8. Sean is coding to automate mouse interactions on a web browser. Assist Sean to identify the
mouse event specific methods from the below options.
Ans: moveToElement(),moveByOffset(),release()
9. Which date format is used to customize the system data to year-month-day format?
ANS:new SimpleDateFormat(“yyyy-MM-dd”)
10. What are the various status options available in the Extent reports library?
Ans:PASS,FAIL,SKIP,FATAL,ERROR,WARNING,INFO
11. James is automating a script and using CSS Selector as a locator. What are the primitive
types for designing the CSS selector?
ANS - .id, .Attribute, .innerText()
12. Sam has created a TestNG project with below specified TestClass.
public class TestClass {
@Test(priority=1)
public void method1() {….}
@Test
public void method3() {….}
@Test
public void method2() {….}
@Test(priority=2)
public void method4() {….}
}Predict the test method execution sequence.Choose the most appropriate
option.Ans:method2, method3, method1, method4.
Q:1 Sarah wants to automate the selection of only one option from a dropdown box as shown below
<html>
<body>
<select multiple>
<option value=”web”>html</option>
<option value=”prog”>python</option>
<option value=”prog”>java</option>
<option value=”prog”>python</option>
<option value=”prog”>java</option>
</select>
</body>
</html>.
Sarah has to select only the fourth option,i.e,python from the options field.
Ans: selectByVisibleText()
selectByValue()
selectByIndex()
All of the above
Q2: Sean is automating a test scenario, in which he has to fetch the URL of the web page using
WebDriver API. Suggest a method for Sean to get the link address
Ans:-getURL()
get()
getCurrentURL()
getURI()
Q3: Sean configured his project for the test suite execution using TestNG. He wants to perform
parallel execution of the test cases. Which attribute represents the parallel execution of the test
cases?
a parallel = “methods”
b parallel="tests"
c parallel = “test-classes”
d parallel =”test-cases”
Q4: Fuller has written an automation script using selenium webdriver commands. He has used all the
necessary and appropriate locators for interacting with the web elements. When he executed the
script the web driver was not able to locate an element resulting in the test script failure. Which
error/ exception is thrown by webdriver?
NoSuchElementException
NoSuchElementError
NullPointerException
ObjectNotFoundException
Q5: Kevin is designing an automation test, where test data is specified in an external excel file.
Which command will be helpful to write the data into a cell of the excel file? Assume c1 is the cell
object.
a c1.setCellValue("data")
b c1.setValue(“data”)
c c1.writeCellValue(“data”)
d c1.setCellData(“data”)
Q6: Which of the following is correct about generating about an XML suite file in TestNG for Test
Suite Exception.
(a) TestNG XML suite can be generated at time of creating TestNG class.
(b) TestNG XML suite can be generated using "Convert to testNG" option..........class is
created.
(c) TestNG XML suite file is automatically generated when user create a maven java
project.
(d) There is no option in Eclipse to generate XML suite file.
Q7: Which of the following Java classes are from the Extent API library?
ExtentReports
Status
TakesScreenshot
Actions
Q8: Sean wants to switch to multiple frames on a web page when an operation is completed on a
frame and test flow needs to move to another frame. Calling the driver.switch To().frame()
immediately will not move the context to the next frame which is at the same level in DOM. The
test will first need to switch to the main document and then activate the desired frame. Which
method is used to switch back to the main document from the frame?
driver.switch To().mainDocument()
driver.switchTo().defaultContent()
Q9: Sam is designing an automation test, where test data is specified in an external excel file. Which
command will be helpful to get across to the 2nd sheet of excel file. Assume wb is the workbook
object.
a wb.getSheetAt(1)
b wb.getSheetAt(2)
c wb.getSheet(1)
d wb.getSheet(2)
Q10: Sean is performing verification using Assert class functions from TestNG. Suggest him the
corect method to verify the reference/address of the two objects to be identical
assert True(Object1,Object2)
assertRef(Obect1,Object2)
assertEquals(Object1,Object2)
assertSame(Object1,Object2)
Q11: Sean is coding an automation Script to launch the web application on a browser window.
Which of the following listed option(s) will help Sean to lunch the desired application on a web
browser in selenium?
(a). driver.get(“URL”)
(b). driver.navigate().to(“URL”)
(c). driver.navigate(“URL”)
(d). driver.getUrl(“URL”)
(e). driver.setUrl(“URL”)
Q12: Sarah is coding an automation Script to locate a child element in an unordered list. The list is
given below:
<html>
<body>
<ul class=”cities”>
<li>Bangalore</li>
<li>Chennai</li>
<li>Hydrabad</li>
<li>Mumbai</li>
<li>Pune</li>
</ul>
</body>
</html>
Sarah wants to locate the 3rd child element i.e Hydrabad. Suggest the appropriate locator stratgy
for
Sarah.
Q13: Sarah is coding an automation script, where she has to validate the price of the holiday
package based on the drag & drop of island city from the menu. The Price is fetched from the
server and displays without reloading the web page. Which WebDriver Library class has the
predefined conditions for handling dynamic waits in Selenium WebDriver Library?
ExplicitWait
ImplicitWait
WebDriverWait
Expected Conditions
Q14: What are the various status options available in the Extent reports library?
e. PASS,FAIL,SKIP,FATAL,ERROR,WARNING,INFO
f. SUCCESS,FAIL,SKIP ,ERROR,WARNING,INFO
g. DONE,DEBUG,FAIL,SKIP,ERROR,WARNING,INFO
h. ABORT,PASS,FAIL,DONE,ERROR,WARNING,INFO
Q15: Kevin wants to fetch all the data from the country drop down menu and verify the data against
data from the database. He is looking into the library for a method to fetch all the data from the
country drop down box. Which method will help Kevin?
f. selectAllOptions()
g. getOptions()
h. getAllOptions()
i. getData()
j. getText()
Q16: Which java interface is used to capture screenshot of a web page using Web Driver API?
ANS: TakeScreenshot
Q17: There is an element on the webpages when inspected on the browser it looks like <div
call=”errorMsg”>Error Message</div>.
James wants to use selenium locations to identify the element. Choose the correct set of commands
to locate the elements efficiently.
Ans:-By. CssSelector(“id=newPassword”)
By .CssSelector(“input.newPassword”)
By .CssSelector(“input_newPassword”)
By .CssSelector(“input[id$=’Password’]”)
Q19: Kevin is using a CSS Selector as a locator strategy for the following element:
Q20: Select the correct order of execution of annotations, as per the life cycle of the TestNG which
can be applied for test methods along with beforeXXXX – afterXXXX methods.
ANS - @BeforeTest, @BeforeClass, @BeforeMethod, @Test, @AfterMethod, @AfterClass,
@AfterTest
Q21: Testing an automation script to test a web application. He has to store the Logout link in the
using a driver.findElement() method. Suggest Sean with a compatible return to leg out least object.
(a) String
(b) WebDriver
(c) WebElement
(d) List
1Q) Sean is coding an automation script to test a web application. He has to store the Logout Ink in
a Java vanable using a driver findElement() method. Suggest Sean with a compatible return
a) String
b) WebDnver
c) WebElement
d) List
a) By.className('style1’)
b) By.id(‘Email')
c) By.name(‘Email’)
d) By.xpath(‘//label[@id='Email’]’)
3Q) James is automating a scnpt and using CSS Seleclor as a localor. What are the primitive types
a) Id
b) Attribute
c) Inner Text
d) Tagname
3Q) Sean is performing verification using Assert class functions from TesTNG. Suggest him the
a) assert True(Object1.Object2)
b) assertRef(Obect1, Object2)
c) assertEquals(Object1, Object2)
d) assertSame(Object1, Object2)
4Q)Sean is coding an automation script for emulating user actions by mouse using the webdriver
library. Assist Sean to choose the correct syntax to create an object for Actions class from the
following options
c) new Actions(driverInstance)
d) Actions act=(Actions)driverInstance
e) Aclions.callMethods()
5Q) Samantha wants to write an automation script that determines the count of Hobbies
a) driver.findElement(By.name("hobbies")).getCount()
b) driver.findElement(By.name("hobbies")).size()
c) driver.findElement(By.name("hobbies")).length()
d) driver.findElements(By.name("hobbies")).getCount()
e) driver.findElements(By.name("hobbies")).size()
6Q) Which Java Interface is used to capture screenshot of a web page using Web Driver API?
a) ScreenShot
b) Capture
c) TakesScreenshot
d) Image
7Q) Which date fomat is used to customize the system date to year-month-day format?
a) new SimpleDateFormat("yyyy-mm-dd")
b) new SimpleDateFormat("yyyy-MM-dd")
c) new SimpleDateFormat("yyyy-month-dd")
d) new SimpleDateFormat("yyyy-mmm-dd")
8Q) Sarah is coding an automation script to switch to IFRAME in a web application. Which of the
listed option(s) will help Sarah to switch to a particular frame on a web page using the webdriver
library?
9Q) Identify the correct way of launching the Chrome browser through WebDriver Instance with the
correct property
a) System.setProperty("webdriver.chrome.driver”, "src/test/resources");
b) System.setProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe");
System.setProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe");
d) System.getProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe");
A ExtentReports
B Status
C TakesScreenshot
D Actions
@Test
@Test
@Test
Kevin executes the above TestClass as a TestNG test. Which of the following correctly
12Q) Sarah coding a test script using TestNG classes. She has used all the necessary Assert
funtions to verify the test scripts When she executes the script. TestNG detected failures
Predict what type of message objects are thrown in the console as output?
A Exception Messages
B Error Messages
C Warning Messages
13Q) Sarah is validating the Registration Page for TestMe App using TestNG Assertions. She wants
to execute all the validation statements and display the status as Pass/Fail, along with failure
messages if any. Which type of assertions are recommended to Sarah for implementation
A Soft Assertions
B Hard Assertions
C Hard Exceptions
D Soft Exceptions
14Q) Kevin is automating a test scenario, in which he wants to locate an element with the class
attribute "classg1 jkyu_90". Assist Kevin in setting up the correct locator for the element.
By.className(“classg1 jkyu_90")
By.className(“classg1”)
By.class("classg1 jkyu_90”)
By.className(“jkyu_90")
15Q) Sarah is coding an automation script to switch to multiple windows in a web application. She
has to store all the window instances in a java variable which is returned by
driver.getWindowHandles(). Suggest Sarah with a compatible return type to store the window
references
List<String>
Set<String>
Array <String>
Window< String>
16Q) Sam is designing an automation test, where test data is specified in an external excel file.
Which command will be helpful to get across to the 2nd sheet of excel file. Assume wb is the
workbook object.
a wb.getSheetAt(1)
b wb.getSheetAt(2)
c wb.getSheet(1)
d wb.getSheet(2)
1. Sarah is coding in a test scenario, in which she must fetch the
booking id as a text message from the span element.
The web element looks like
<Space> order completed with Booking id:6665<Space>
Help Sarah to find a method from the webdriver library to fetch the
booking ID?
Ans - getText();
10. Select the correct order of execution of annotations, as per the life
cycle of the TestNG which can be applied for test methods along
with beforeXXXX – afterXXXX methods.
ANS - @BeforeTest, @BeforeClass, @BeforeMethod, @Test,
@AfterMethod, @AfterClass, @AfterTest
25. Sarah wants to automate the selection of only one option from a
drop-down box as shown below.
<html>
<body>
<select multiple>
<option value = “web”> html</option>
<option value = “prog”> python</option>
<option value = “prog”> java</option>
<option value = “prog”> python</option>
<option value = “prog”> java</option>
</select>
</body>
</html>
Sarah has to select only the fourth option i.e., python from the
option list .
selectByIndex()
26. Sean is automating a test scenario in which he has to fetch the URL
of the webpage using webDriver API. Suggest a method for Sean to
get the link address.
getCurrentURL()
27. Which method is used in the Apache POI library to fetch the cell
value from a row? Identify the correct format of invoking the
library functions to get the value from the cell.
sheet.getRow(rowno).getcell(col no).getStringCellValue()
31. Which of the following is correct about generating XML suite file
in TestNG for Test Suite Execution?
TestNG XML Suite file can be generated at the time of creating a
TestNG class.
TestNG XML Suite file can be generated using ‘convert to
TestNG’ option in Eclipse after a java class is created.
34. When verification fails in TestNG, what forces the test to stop
execution and mark as Fail?
AssertionError
35. Samantha wants to automate selection of value from a drop-down
menu. When the element was Inspected. She found:
<html>
<body>
<select name=”jobrole”>
<Option value=”1”>Manager</option >
<option value=”2”>Lead</option>
<option value=”3”>Analyst</option>
</select>
</body>
<html>
Choose “lead” as the test data. Assist her by choosing the correct
options.
selectByIndex(1);
selectByVisibleText(“Lead”)
selectByValue(“2”)
40. Identify the wait time method which is not the Selenium way to
handle synchronization in Test Automation.
Sleep()
41. Which of the following library is used for designing the test scripts
using the predefined classes, methods, and annotations?
TestNG Library
42. Sean is working on a Test Automation project; He is looking for
different strategies for identifying the elements/objects from the
web application using Selenium locators. Suggest Sean with the
available locators in Selenium.
By.id()
By.tagName()
By.partialLinkText()
(Explanation – SELENIUM Selectors - ID, Tag Name, Link Text,
Name, CSS Selector, Partial Link Text, Class Name, XPath)
45. List out the operating systems that are supported by Selenium.
Windows, Linux, Mac, android & iOS
46. Sean is filling a web form with his contact details like email, phone
number, and address while performing registration to an event. He
clicked on submit button without entering the phone number and a
pop-up window appeared saying "Contact Number is required".
Identify the correct way to handle such pop-up windows using
Selenium WebDriver.
driver.switchTo().alert()
47. Identify the child tags that are required to add inside dependency
tag in order to download the desired libraries/jar from the maven
central repository without any errors.
groupId
version
artifactId
48. Sarah is coding an automation script to switch to frame in a web
application. Help her to switch a particular frame on a web page
using the window library. She wants to interact with the pop-up
window and decline the confirmation pop up window show a
message “Do you want to cancel the payment?”. Assist Samantha to
interact with
Driver.SwitchTo().frame(int index)
Driver.SwitchTo().frame(String name or id)
Driver.switchto().frame(webelement frameelement)
51. Kevin wants to generate extensive report for the test automation
project. He decides to use Extent reports library. Which class in
this library is used to create labels, code blocks and labels in the
report?
Markup Helper
54. Which java Enum is used to handle the keyboard strokes from web
driver library? Choose the most appropriate option.
Keys
56. George is reviewing the quality of the Java code given to him using
SonarQube and identified that the variables are named without
following java variable naming convention rules. Under which
category this issue can be tracked in the tool? Choose the most
appropriate option.
Minor
57. Sam has created a TestNG project with below specified TestClass.
public class TestClass
{
@Test(priority=1)
public void method1() {….}
@Test
public void method3() {….}
@Test
public void method2() {….}
@Test(priority=2)
public void method4() {….}
}
Predict the test method execution sequence. Choose the most
appropriate option.
method2, method3, method1, method4
58. What method in the Web driver library is used to get the attribute
value of a web element? Choose the appropriate option.
getAttribute(“attributeName”)
61. Identify the correct flow of Jenkins build, when a maven project
job in Jenkins is triggered for build.
pom.xml >testing.xml- >testing classes>reports
62.Sarah has her code in git local repository, but her team lead had
pushed the new changes into the remote repository, which git
command would you recommend Sarah with new changes into her
working copy?
add
64. Sean configured his project for the test suite execution using
TestNG. He wants to perform parallel execution of the test cases.
Which attribute represents the parallel execution of the test cases?
parallel="tests"
66. Which of the following Java classes are from the Extent API
library?
ExtentReports
Status
67. Which date format is used to customize the system data to year-
month-day format?
new SimpleDateFormat(“yyyy-MM-dd”)
69. What are the various status options available in the Extent reports
library?
PASS,FAIL,SKIP,FATAL,ERROR,WARNING,INFO
70. Kevin wants to fetch all the data from the country drop down
menu and verify the data against data from the database. He is
looking into the library for a method to fetch all the data from the
country drop down box. Which method will help Kevin?
getOptions()
80. Sarah is coding an automation script, where she has to validate the
price of the holiday package based on the drag & drop of island city
from the menu. The price is fetched from the server and displays
without reloading the web page. Which WebDriver library class
has the predefined conditions for handling dynamic waits in
selenium WebDriver Library?
WebDriverWait
81. While using Soft Assertion in the Test Class, James must specify a
method, that will collate and display the assertion results.
assertAll()