0% found this document useful (0 votes)
225 views94 pages

Selenium MCQ2

The document provides a series of questions and answers related to automation testing, specifically using Selenium, TestNG, and other related tools. It covers topics such as CSS selectors, WebDriver methods, TestNG annotations, and version control with Git. Each question is followed by a concise answer, making it a useful reference for automation engineers and testers.

Uploaded by

dhariyasonpal46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
225 views94 pages

Selenium MCQ2

The document provides a series of questions and answers related to automation testing, specifically using Selenium, TestNG, and other related tools. It covers topics such as CSS selectors, WebDriver methods, TestNG annotations, and version control with Git. Each question is followed by a concise answer, making it a useful reference for automation engineers and testers.

Uploaded by

dhariyasonpal46
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 94

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();

2. 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)

3. 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.)

4. Write in correct order.


a. Triggers the build
b. Open reports to see the latest test results.
c. Jenkins checks the Git Repository periodically to detect changes in
build project.
d. The build is successful / Failure.
e. Testers/ Developers commits source code changes to the shared Git
Repository.
ANS- e,c,a,d,b

5. Kevin has designed a TestClass with the following methods:


public class TestClass {
@Test
public void testMehod1() {int a = 78;}
@Test
public void testMehod2() {Assert.assertEquals(67, 76);}
public void testMehod3() {System.out.println("Welcome");}
@Test
public void testMehod4(){Assert.assertEquals("Hello”, “Hello");}
}
Kevin executes the above TestClass as a TestNG test. Which of the
following correctly represents the test result?
ANS - Total tests run: 3, Passed: 2, Failed: 1
6. 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();

7. 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()

8. 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']")
By.cssSelector("input[id$='Password']")

9. 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”)

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

11. 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
12. 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’]”)

13. Which of the following method causes a thread to pause for a


specified duration?
pause()

14. What are the features of TestNG?


Annotation Based
Parallel Testing
Reporting

15. __ Closes all the associated windows of webdriver.


Quit()

16. Which of the following components identify the artifacts in


Maven?
Artifact Id
Group ID
Version

17. What is the correct Syntax to instantiate a Firefox Browser


session?
WebDriver driver = new FirefoxDriver();
18. Consider there are three frames in a web page, which method
below is used to comeback to main window before switching to any
frame?
switchTo.defaultContent()

19. Which of the following methods will be used to handle an alert


dialog box?
alert.accept()

20. Which of the given options are structure-based locators?


CSS
XPATH

21. Which of the following command should be used to extract more


than one element on web page?
findElements

22. Which of the following is a term used in thee testing of computer


software to describe testing done using a table of conditions directly
as test data inputs?
Data Driven Testing

23. getText() method extracts the text from an element.


True

24. 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?
YES , webDriver will wait 20 more seconds.

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()

28. Match the following tools with the correct description.


Tools Description
A. GIT 1. A cloud service for remote hosting of git
repositories. In addition to hosting your
code, the site helps manage software
development projects.
B. Git Lab 2. Open-Source platform or continuous
inspection of code quality to perform
automatic review with static analysis of
code to detect bugs.
C. SonarQube 3. Software that handles source code
versioning, letting you make and track
local file changes and share with remote
repository.
A-3, B-1, C-2
29. 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?
driver.switchTo().frame(int index)
driver.switchTo().frame(string nameOrld)
driver.switchTo().frame(WebElement frameElement)

30. Sean is coding an automated script to launch the web application


on a browser window. Which of the following listed option will help
Sean to launch the desired application on a web browser in
selenium?
driver.get(“URL”)
driver.navigate().to(“URL”)

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.

32. 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.
wb.getSheetAt(1)

33. 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 retrieved by driver.getWindowHandles().
Suggest Sarah with a compatible return type to store the window
references.
set <string>

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”)

36. In distributed version control system for SCM, which of the


following is not true?
Only online commits are allowed.

37. Which plugin can be used as an IDE(like Eclipse) extension that


helps to detect and fix quality issues of code written in
java/python/html/JavaScript/php?
Sonar Lint

38. Sarah is an Automation Engineer and wants to build a job from


Jenkins server. The Jenkins server is up and running. What is the
default port number that Sarah needs to remember to access the
Jenkins server with URL?
8080

39. Which of the following are supporting attributes for @Test?


priority
enabled

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)

43. Which of the following is used to pass data from a source to a


particular test method to replace the constant values with variables
in TestNG?
Data Provider

44. In the TestNG framework, which of the following contains


Single/Multiple Test Cases?
Test Suite

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)

49. 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.
WebElement

50. 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?
isMultiple()

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

52. Sarah is coding an automation script to switch to multiple windows


in a web application . She has to store all the window instance in a
java variable which is returned by driver.getWindowHandles().
Suggest Sarah with a compatible return type to store the window
References.
Set<String>
53. 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>Hyderabad</li>
<li>Mumbai</li>
<li>Pune</li>
</ul>
</body>
</html>
Sarah wants to locate the 3rd child element i.e., Hyderabad.
Suggest the appropriate locator strategy for Sarah.
CSS = "ul.cities li:nth-of-type("Hyderabad")

54. Which java Enum is used to handle the keyboard strokes from web
driver library? Choose the most appropriate option.
Keys

55. There is an element on the web page when inspected on the


browser it looks like <div class=”errorMsg”>Error Message</div>
James wants to use selenium locators to identify the element.
Choose the correct set of commands to locate the element
effectively.
By.cssSelector(“div.errorMsg”)

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”)

59. Sean is coding to automate mouse interactions on a web browser.


Assist Sean to identify the mouse event specific methods from the
below options. Choose the appropriate options.
moveToElement()
moveByOffset()
release()

60. Samantha has designed a TestClass with the following methods:


public class TestClass
{
@BeforeMethod
public void method1() {……}
@AfterMethod
public void method2() {……}
@Test(dataProvider=”loginData”)
public void method3(String u, String p) {…..}
@DataProvider
public Object[][] loginData() {….}
}
Suppose loginData() generates 5 sets of login credentials, how many
times method1, method2 and method 3 would be executed ? Choose
the appropriate option.
Method1 – 5 times, Method2 – 5 times, Method3 – 5 times

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

63. 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
(?) - single character search (*) - one or more

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"

65. 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.
c1.setCellValue("data")

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”)

68. 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

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()

71. 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.
selenium RC

72. The web element looks like


<a href=”icart.jsp? params”>cart[19]</a>.
Which locator is most recommended for the scan to identify the
cart web element for all test iterations ?
By.partialLinkText()

73. Kevin is planning to write automation script for below scenario.


Given the user is on the payment page. He views a textbox with
attribute values . “Enter Mobile Number” written in the box. The
user must enter the mobile number in the box to proceed. Please
choose the correct command to help Kevin in automating the
scenario. Assume the textbox element is already identified and
stored in mobile txt box variable.
mobileTxtBox.clear(); mobileTxtBox.sendKeys(“xxxxxxxxxx”);

74. Which MS office component(s) can be handled by Apache POI


Library?
XLSX

75. Sarah is coding to automate a scenario for the selection of the


“from Cities” drop down box IN the flight booking application web
page, which WebDriver library class helps Sarah to automate the
drop-down box with different functions?
Select Class

76. Sean is performing verification using assert class functions from


TestNG. Suggest him the correct method to verify the
reference/address of the two objects to be identical?
assertSame(object1,object2)
77. Samantha has to execute automation scripts across multiple
platforms like windows, max and Linux. Which tool in the
Selenium suite will be useful for Samantha?
Selenium Grid

78. 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.switchTo().frame() immediately
will not move the context to 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 frame. Which method is used to switch back
to the main document from the frame?
switchTo.defaultContent()

79. Samantha is automating a test scenario. This scenario involves a


pop-up of confirmation window. She wants to interact with the pop-
up window and decline the confirmation. Pop-up window shows a
message “Do you want to cancel the payment?”
Driver.switchTo().alert().dismiss()

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()

82. Which java interface is used to capture screenshot of web page


using Web Driver API?
TakesScreenshot

83. Consider the below HTML code snippet.


Email ; <label id= “Email” class= “style1” name= “input”>
Which is the best locator to identify the email web element?
By.xpath(“//label[@id= ‘email’]”)
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?

Ans: No, webDriver won’t wait 20 more seconds.

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

Ans: sheet.getRow(rowno).getcell(col no).getStringCellValue()

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

Ans: (?) – single character search (*) – one or more

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

d There is no option in Eclipse to generate XML Suite file

e TestNG XML Suite file can be generated by Jenkins plugin


2) Sean is coding an automated script to launch the web application on a browser window. Which of
the following listed option will help Sean to launch 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”)

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>

<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 .

a selectByVisibleText()

b selectByValue()

c selectByIndex()

d All of the above

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

Actions act = new Actions(driverInstance)

Actions act = new Actions()

New Actions(driverInstance)

Actions act = (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

Cannot predict the name of error/ exception

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=”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)

selectByValue(2)

selectByVisibleText(“Lead”)

selectByValue(“2”)
Q1- Which expression is used in CSS selectors to match the attribute value with a prefix?

Ans: ^

Q2- public class TestClass

@Test(priority=1)

public void method1(){...}

@Test

public void method3(){...}

@Test

public void method2(){...}

@Test(priority=2)

public void method4(){...}

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.)

i. Write in correct order.


a. Triggers the build
b. Open reports to see the latest test results.
c. Jenkins checks the Git Repository periodically to detect changes in build project.
d. The build is successful / Failure.
e. Testers/ Developers commits source code changes to the shared Git Repository.
ANS- e,c,a,b,d

j. Kevin has designed a TestClass with the following methods:


public class TestClass {
@Test
public void testMehod1() {int a = 78;}
@Test
public void testMehod2() {Assert.assertEquals(67, 76);}
public void testMehod3() {System.out.println("Welcome");}
@Test
public void testMehod4(){Assert.assertEquals("Hello”, “Hello");}
}
Kevin executes the above TestClass as a TestNG test. Which of the following correctly
represents the test result?
ANS - Total tests run: 3, Passed: 2, Failed: 1

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?

ANS- All of the above Correct

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 ?

ANS- Use Scenario outline. Correct

91. Jack had created the feature file with the below mentioned scenarios as shown below:

@smoke Scenario: This is the first scenario

@crash Scenario: This is the second scenario In test runner class, Jack mentioned
@cucumberoptions (tags=(“smoke”)) predict which scenario is/are gets executed

Ans: Execute first scenario Correct

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.

93. Which of the following assertions is not applied in Jmeter?

Ans: web Correct

94. Which of the following is an invalid configuration element in Jmeter?

Ans: FTP cookie manager Correct

95. Which of the following input documents is used to create test scenarios and conditions?

Ans: Use cases Correct

96. Which of the following Java classes are from the extent API library?

Ans: ExtentReports, Status Correct Google: ExtentReports

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?

Ans: Yes, webDriver will wait 20 more seconds. Correct

1) Which java enum is used to handle the keyboard strokes from webdriver library?
(a) Actions
(b) Keyboard
(c) Keys
(d) Keyword

Ans: (b) keyboard

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)

5)Which Ms office components(s) can be handled by apache POI library?

(a)ppt

(b)docs

(c)…

(d)…

(e)all the above

Ans: POIFS

6)Samanta has designed a testclass, with the….

Public class testclass

@beforeMethod
Public void method1() {…}

@afterMethod

Public void method2() {…}

@Test(dataProvider=”loginData”)

Public void method2(string u, string p) {…}

@data provider

Public object[][] login data() {…}

Suppose login data () generates 5 sets og login credentials …..

Choose right answer.

ANS: Method1 – 5 times…….

****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()

(c) sheet.getCell(collno) .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:

public class TestClass

@BeforeMethod

public void method1() {……}

@AfterMethod

public void method2() {……}

@Test(dataProvider=”loginData”)

public void method3(String u, String p) {…..}

@DataProvider

public Object[][] loginData() {….}

Suppose loginData() generates 5 sets of login credentials, how many times method1, method2 and
method 3 would be executed ?

Choose the appropriate option

a) Method1 – 5 times, Method2 – 5 times, Method3 – 5 times


b) Method1 – 1 time, Method2 – 1 time, Method3 – 5 times
c) Method1 – 1 time, Method2 – 1 time, Method3 – 1 time
d) Cannot predict the iterations

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.

Choose the appropriate 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?

Choose the appropriate option.

a) getAttributeValue(“attributeName”)
b) getAttribute(“attributeName”)
c) getValue(“attributeName”)
d) getText()

5. 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.

a) method2, method3, method1, method4


b) method1, method4, method3, method2
c) method1, method4, method2, method3
d) Random order of execution

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.

Choose the most appropriate option.

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

Ans: (c) WebElement

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

3) Sarah is coding an automation script to switch to multiple windows in a web application .


She has to store all the window instance in a java variable which is returned by
driver.getWindowHandles(). Suggest Sarah with a compatible return type to store the
window
References.

(a) List<String>
(b) Set<String>
(c) Array<String>
(d) Window<String>

Ans: (b) Set<String>

Sub-topics: Extent Reports

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.

Sub-topics: WebDriver API

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”)

Ans: (a) driver.get("URL")

(b) driver.navigate().to("URL")

Sub-topics: WebDriver API


6) 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.

(a) CSS = “ul:cities li:nth-child(2)”


(b) CSS = “ul:cities li:nth-of-type(“Hydrabad”)
(c) CSS =” ul:cities li:nth-child(“Hydrabad”)
(d) CSS= “ul:cities li:nth-child(])”

Ans: (b) css="ul.cities li:nth-of-type("Hyderabad")

Sub-topic: WebDriver Api

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

None of the above

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)

3) Kevin is planning to write an automation script for below test scenario:


Given the user is on the Payment Page, he views a text box with attribute value=”Enter
Mobile Number” written inside the box. The user must enter the mobile number in the box.

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.

Choose the most appropriate option.

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

Choose the most appropriate option

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

Cannot predict the name of error/ exception

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.

(e)TestNG XML suite file can be generated by Jenkins

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().body()

driver.switch To().mainDocument()

driver switch To().defaultDocument()

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”)

Ans: (a) driver.get("URL")


(b) driver.navigate().to("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.

(e) CSS = “ul:cities li:nth-child(2)”


(f) CSS = “ul:cities li:nth-of-type(“Hydrabad”)
(g) CSS =” ul:cities li:nth-child(“Hydrabad”)
(h) CSS= “ul:cities li:nth-child(])”

Ans: (b) css="ul.cities li:nth-of-type("Hyderabad")

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.CSS Selector(“div#errorMsg”)


By.CSS Selector(“div.errorMsg”)
By.CSS Selector(“div_errorMsg”)
By.CSS Selector(“errorMsg”)
Q18: ) 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="nowPassword" type="password">

Choose the most appropriate option.

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:

<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’]”)

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

Ans: (c) WebElement

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

type to store the Log out test object.

Choose the best option

a) String

b) WebDnver

c) WebElement

d) List

2Q) Consider the below hlml code snippet

Email : <label id='Email' class='style 1' name='input>

Which is the best localor to identify the Email web element?

Choose the most appropnate option.

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

for designing the CSS Selector?

Choose all the appropnate options.

a) Id

b) Attribute

c) Inner Text

d) Tagname

3Q) Sean is performing verification using Assert class functions from TesTNG. Suggest him the

correct method to verify the reference/address of the two objects to be identical.

Choose the most appropnale option.

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

Choose all the appropriate options.

a) Actions act=new Actions(driverInstance)

b) Actions act=new Actions()

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

checkboxes. These checkboxes have a name attribute as "hobbies". Assist Samantha by

choosing the correct command

Choose the most appropriate option

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?

Choose the most appropriate option.

a) ScreenShot

b) Capture

c) TakesScreenshot

d) Image

7Q) Which date fomat is used to customize the system date to year-month-day format?

For example: 2019-04-24

Choose the most appropriate option.

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?

Choose all the appropriate options.

Ans: driver. switch To() .frame(int index)

driver. switch To(). frame(String nameOrid)

driver switch To().frame(WebElement frameElement)

driver switch To().frame()

driver switch To().iframe(String name)

9Q) Identify the correct way of launching the Chrome browser through WebDriver Instance with the

correct property

Choose the most appropriate option.

a) System.setProperty("webdriver.chrome.driver”, "src/test/resources");

WebDriver driver=new ChromeDriver();

b) System.setProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe");

WebDriver driver=new ChromeDriver();

c) WebDriver driver=new ChromeDriver();

System.setProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe");

d) System.getProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe");

WebDriver driver=new ChromeDriver();


10Q) Which of the following Java classes are from the Extent API library?

Choose the most appropriate option.

A ExtentReports

B Status

C TakesScreenshot

D Actions

11Q) Kevin has designed a TestClass with the following methods:

public class TestClass

@Test

public void testMethod1() {int a = 78; }

@Test

public void testMethod2() { Assert.assertEquals(67,76); }

public void testMethod3() { System.out.println("Welcome"); }

@Test

public void testMethod4() {Assert.assertEquals("Hello", "Hello"); }

Kevin executes the above TestClass as a TestNG test. Which of the following correctly

represents the test results?

Choose the most appropriate option

A Total Tests Run: 3 Passed 2 Faited 1

B Total Tests Run: 4 Passed 3 Failed. 1

C Total Tests Run: 4 Passed 1 Failed 1

D Total Tests Run: 3 Passed: 1 Failed: 1

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

D No Messages displays on Console

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

Choose the most appropriate option

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.

Choose the most appropriate option.

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

2….Sarah is coding an automation script.where she has to fetch(HTML CODE)------webelement


desired table=driver.find element(by.id(“table3”)); List <Web element>
rows=desiredtable.findelements(by.tagname(“tr”));system.out println(rows.size());

3…GIT CLONE

4….sarah has on automation engineer triggers anew-----JRE,JDK OR JRE,JDE,MAVEN

5----when a maven project ijob in jenkinsis triggers-------TESTING XML-→POM XML--→TETINGC

6…..which MSoffice components can be handled by apache Poi libraery ----POIFS

7….. which plugin can be used as an IDE (like eclipse extension that helps to detect and fix quality
issues-----SONARTLINT

8……sean is coding to automate mouse interaction-----move to element() ,movebyoffset(),release()

9…..which method in the webdriver library is used----GETATTRIBUTE(“ATTRIBUTENAME”)

10….which plugin can be used as an IDE (like eclipse extension

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)

16….kevin is debugging an automation test ,where test data-----c1.SETCELLVALUE(“DATA”)

17….A3,B1,C2------ GIT >SOFTWARETHAT HANDLES

GITLAB>A CLOUD SERVICE

SONARQUBE>OPEN-SOURCE

18….samantha is automating a test scenario-----DRIVER.SWITCHTO().ALERT()DISMISS();

19---TAKESSCREENSHOT

20---ISMULTIPLE()

21---NOSUCHELEMENTEXCEPTION

22----MARKUPHELPER

23----WEBELEMENT….sean is coding an automation element script test a web application.he has to


store thelogout link------

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?

Ans: No, webDriver won’t wait 20 more seconds.

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

Ans: sheet.getRow(rowno).getcell(col no).getStringCellValue()

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

Ans: (?) – single character search (*) – one or more

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

d There is no option in Eclipse to generate XML Suite file

e TestNG XML Suite file can be generated by Jenkins plugin


2) Sean is coding an automated script to launch the web application on a browser window. Which of
the following listed option will help Sean to launch 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”)

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>

<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 .

a selectByVisibleText()

b selectByValue()

c selectByIndex()

d All of the above

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

Actions act = new Actions(driverInstance)

Actions act = new Actions()

New Actions(driverInstance)

Actions act = (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

Cannot predict the name of error/ exception

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=”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)

selectByValue(2)

selectByVisibleText(“Lead”)

selectByValue(“2”)
Q1- Which expression is used in CSS selectors to match the attribute value with a prefix?

Ans: ^

Q2- public class TestClass

@Test(priority=1)

public void method1(){...}

@Test

public void method3(){...}

@Test

public void method2(){...}

@Test(priority=2)

public void method4(){...}

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.)

i. Write in correct order.


a. Triggers the build
b. Open reports to see the latest test results.
c. Jenkins checks the Git Repository periodically to detect changes in build project.
d. The build is successful / Failure.
e. Testers/ Developers commits source code changes to the shared Git Repository.
ANS- e,c,a,b,d

j. Kevin has designed a TestClass with the following methods:


public class TestClass {
@Test
public void testMehod1() {int a = 78;}
@Test
public void testMehod2() {Assert.assertEquals(67, 76);}
public void testMehod3() {System.out.println("Welcome");}
@Test
public void testMehod4(){Assert.assertEquals("Hello”, “Hello");}
}
Kevin executes the above TestClass as a TestNG test. Which of the following correctly
represents the test result?
ANS - Total tests run: 3, Passed: 2, Failed: 1

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?

ANS- All of the above Correct

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 ?

ANS- Use Scenario outline. Correct

91. Jack had created the feature file with the below mentioned scenarios as shown below:

@smoke Scenario: This is the first scenario

@crash Scenario: This is the second scenario In test runner class, Jack mentioned
@cucumberoptions (tags=(“smoke”)) predict which scenario is/are gets executed

Ans: Execute first scenario Correct

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.

93. Which of the following assertions is not applied in Jmeter?

Ans: web Correct

94. Which of the following is an invalid configuration element in Jmeter?

Ans: FTP cookie manager Correct

95. Which of the following input documents is used to create test scenarios and conditions?

Ans: Use cases Correct

96. Which of the following Java classes are from the extent API library?

Ans: ExtentReports, Status Correct Google: ExtentReports

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?

Ans: Yes, webDriver will wait 20 more seconds. Correct

1) Which java enum is used to handle the keyboard strokes from webdriver library?
(a) Actions
(b) Keyboard
(c) Keys
(d) Keyword

Ans: (b) keyboard

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)

5)Which Ms office components(s) can be handled by apache POI library?

(a)ppt

(b)docs

(c)…

(d)…

(e)all the above

Ans: POIFS

6)Samanta has designed a testclass, with the….

Public class testclass

@beforeMethod
Public void method1() {…}

@afterMethod

Public void method2() {…}

@Test(dataProvider=”loginData”)

Public void method2(string u, string p) {…}

@data provider

Public object[][] login data() {…}

Suppose login data () generates 5 sets og login credentials …..

Choose right answer.

ANS: Method1 – 5 times…….

****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()

(c) sheet.getCell(collno) .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:

public class TestClass

@BeforeMethod

public void method1() {……}

@AfterMethod

public void method2() {……}

@Test(dataProvider=”loginData”)

public void method3(String u, String p) {…..}

@DataProvider

public Object[][] loginData() {….}

Suppose loginData() generates 5 sets of login credentials, how many times method1, method2 and
method 3 would be executed ?

Choose the appropriate option

a) Method1 – 5 times, Method2 – 5 times, Method3 – 5 times


b) Method1 – 1 time, Method2 – 1 time, Method3 – 5 times
c) Method1 – 1 time, Method2 – 1 time, Method3 – 1 time
d) Cannot predict the iterations

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.

Choose the appropriate 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?

Choose the appropriate option.

a) getAttributeValue(“attributeName”)
b) getAttribute(“attributeName”)
c) getValue(“attributeName”)
d) getText()

5. 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.

a) method2, method3, method1, method4


b) method1, method4, method3, method2
c) method1, method4, method2, method3
d) Random order of execution

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.

Choose the most appropriate option.

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

Ans: (c) WebElement

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

3) Sarah is coding an automation script to switch to multiple windows in a web application .


She has to store all the window instance in a java variable which is returned by
driver.getWindowHandles(). Suggest Sarah with a compatible return type to store the
window
References.

(a) List<String>
(b) Set<String>
(c) Array<String>
(d) Window<String>

Ans: (b) Set<String>

Sub-topics: Extent Reports

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.

Sub-topics: WebDriver API

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”)

Ans: (a) driver.get("URL")

(b) driver.navigate().to("URL")

Sub-topics: WebDriver API


6) 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.

(a) CSS = “ul:cities li:nth-child(2)”


(b) CSS = “ul:cities li:nth-of-type(“Hydrabad”)
(c) CSS =” ul:cities li:nth-child(“Hydrabad”)
(d) CSS= “ul:cities li:nth-child(])”

Ans: (b) css="ul.cities li:nth-of-type("Hyderabad")

Sub-topic: WebDriver Api

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

None of the above

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)

3) Kevin is planning to write an automation script for below test scenario:


Given the user is on the Payment Page, he views a text box with attribute value=”Enter
Mobile Number” written inside the box. The user must enter the mobile number in the box.

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.

Choose the most appropriate option.

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

Choose the most appropriate option

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

Cannot predict the name of error/ exception

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.

(e)TestNG XML suite file can be generated by Jenkins

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().body()

driver.switch To().mainDocument()

driver switch To().defaultDocument()

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”)

Ans: (a) driver.get("URL")


(b) driver.navigate().to("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.

(e) CSS = “ul:cities li:nth-child(2)”


(f) CSS = “ul:cities li:nth-of-type(“Hydrabad”)
(g) CSS =” ul:cities li:nth-child(“Hydrabad”)
(h) CSS= “ul:cities li:nth-child(])”

Ans: (b) css="ul.cities li:nth-of-type("Hyderabad")

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.CSS Selector(“div#errorMsg”)


By.CSS Selector(“div.errorMsg”)
By.CSS Selector(“div_errorMsg”)
By.CSS Selector(“errorMsg”)
Q18: ) 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="nowPassword" type="password">

Choose the most appropriate option.

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:

<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’]”)

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

Ans: (c) WebElement

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

type to store the Log out test object.

Choose the best option

a) String

b) WebDnver

c) WebElement

d) List

2Q) Consider the below hlml code snippet

Email : <label id='Email' class='style 1' name='input>

Which is the best localor to identify the Email web element?

Choose the most appropnate option.

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

for designing the CSS Selector?

Choose all the appropnate options.

a) Id

b) Attribute

c) Inner Text

d) Tagname

3Q) Sean is performing verification using Assert class functions from TesTNG. Suggest him the

correct method to verify the reference/address of the two objects to be identical.

Choose the most appropnale option.

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

Choose all the appropriate options.

a) Actions act=new Actions(driverInstance)

b) Actions act=new Actions()

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

checkboxes. These checkboxes have a name attribute as "hobbies". Assist Samantha by

choosing the correct command

Choose the most appropriate option

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?

Choose the most appropriate option.

a) ScreenShot

b) Capture

c) TakesScreenshot

d) Image

7Q) Which date fomat is used to customize the system date to year-month-day format?

For example: 2019-04-24

Choose the most appropriate option.

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?

Choose all the appropriate options.

Ans: driver. switch To() .frame(int index)

driver. switch To(). frame(String nameOrid)

driver switch To().frame(WebElement frameElement)

driver switch To().frame()

driver switch To().iframe(String name)

9Q) Identify the correct way of launching the Chrome browser through WebDriver Instance with the

correct property

Choose the most appropriate option.

a) System.setProperty("webdriver.chrome.driver”, "src/test/resources");

WebDriver driver=new ChromeDriver();

b) System.setProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe");

WebDriver driver=new ChromeDriver();

c) WebDriver driver=new ChromeDriver();

System.setProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe");

d) System.getProperty("webdriver.chrome.driver","src/test/resources/chromedriver.exe");

WebDriver driver=new ChromeDriver();


10Q) Which of the following Java classes are from the Extent API library?

Choose the most appropriate option.

A ExtentReports

B Status

C TakesScreenshot

D Actions

11Q) Kevin has designed a TestClass with the following methods:

public class TestClass

@Test

public void testMethod1() {int a = 78; }

@Test

public void testMethod2() { Assert.assertEquals(67,76); }

public void testMethod3() { System.out.println("Welcome"); }

@Test

public void testMethod4() {Assert.assertEquals("Hello", "Hello"); }

Kevin executes the above TestClass as a TestNG test. Which of the following correctly

represents the test results?

Choose the most appropriate option

A Total Tests Run: 3 Passed 2 Faited 1

B Total Tests Run: 4 Passed 3 Failed. 1

C Total Tests Run: 4 Passed 1 Failed 1

D Total Tests Run: 3 Passed: 1 Failed: 1

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

D No Messages displays on Console

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

Choose the most appropriate option

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.

Choose the most appropriate option.

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();

2. 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)

3. 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.)

4. Write in correct order.


a. Triggers the build
b. Open reports to see the latest test results.
c. Jenkins checks the Git Repository periodically to detect changes in
build project.
d. The build is successful / Failure.
e. Testers/ Developers commits source code changes to the shared Git
Repository.
ANS- e,c,a,d,b

5. Kevin has designed a TestClass with the following methods:


public class TestClass {
@Test
public void testMehod1() {int a = 78;}
@Test
public void testMehod2() {Assert.assertEquals(67, 76);}
public void testMehod3() {System.out.println("Welcome");}
@Test
public void testMehod4(){Assert.assertEquals("Hello”, “Hello");}
}
Kevin executes the above TestClass as a TestNG test. Which of the
following correctly represents the test result?
ANS - Total tests run: 3, Passed: 2, Failed: 1
6. 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();

7. 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()

8. 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']")
By.cssSelector("input[id$='Password']")

9. 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”)

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

11. 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
12. 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’]”)

13. Which of the following method causes a thread to pause for a


specified duration?
pause()

14. What are the features of TestNG?


Annotation Based
Parallel Testing
Reporting

15. __ Closes all the associated windows of webdriver.


Quit()

16. Which of the following components identify the artifacts in


Maven?
Artifact Id
Group ID
Version

17. What is the correct Syntax to instantiate a Firefox Browser


session?
WebDriver driver = new FirefoxDriver();
18. Consider there are three frames in a web page, which method
below is used to comeback to main window before switching to any
frame?
switchTo.defaultContent()

19. Which of the following methods will be used to handle an alert


dialog box?
alert.accept()

20. Which of the given options are structure-based locators?


CSS
XPATH

21. Which of the following command should be used to extract more


than one element on web page?
findElements

22. Which of the following is a term used in thee testing of computer


software to describe testing done using a table of conditions directly
as test data inputs?
Data Driven Testing

23. getText() method extracts the text from an element.


True

24. 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?
YES , webDriver will wait 20 more seconds.

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()

28. Match the following tools with the correct description.


Tools Description
A. GIT 1. A cloud service for remote hosting of git
repositories. In addition to hosting your
code, the site helps manage software
development projects.
B. Git Lab 2. Open-Source platform or continuous
inspection of code quality to perform
automatic review with static analysis of
code to detect bugs.
C. SonarQube 3. Software that handles source code
versioning, letting you make and track
local file changes and share with remote
repository.
A-3, B-1, C-2
29. 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?
driver.switchTo().frame(int index)
driver.switchTo().frame(string nameOrld)
driver.switchTo().frame(WebElement frameElement)

30. Sean is coding an automated script to launch the web application


on a browser window. Which of the following listed option will help
Sean to launch the desired application on a web browser in
selenium?
driver.get(“URL”)
driver.navigate().to(“URL”)

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.

32. 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.
wb.getSheetAt(1)

33. 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 retrieved by driver.getWindowHandles().
Suggest Sarah with a compatible return type to store the window
references.
set <string>

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”)

36. In distributed version control system for SCM, which of the


following is not true?
Only online commits are allowed.

37. Which plugin can be used as an IDE(like Eclipse) extension that


helps to detect and fix quality issues of code written in
java/python/html/JavaScript/php?
Sonar Lint

38. Sarah is an Automation Engineer and wants to build a job from


Jenkins server. The Jenkins server is up and running. What is the
default port number that Sarah needs to remember to access the
Jenkins server with URL?
8080

39. Which of the following are supporting attributes for @Test?


priority
enabled

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)

43. Which of the following is used to pass data from a source to a


particular test method to replace the constant values with variables
in TestNG?
Data Provider

44. In the TestNG framework, which of the following contains


Single/Multiple Test Cases?
Test Suite

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)

49. 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.
WebElement

50. 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?
isMultiple()

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

52. Sarah is coding an automation script to switch to multiple windows


in a web application . She has to store all the window instance in a
java variable which is returned by driver.getWindowHandles().
Suggest Sarah with a compatible return type to store the window
References.
Set<String>
53. 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>Hyderabad</li>
<li>Mumbai</li>
<li>Pune</li>
</ul>
</body>
</html>
Sarah wants to locate the 3rd child element i.e., Hyderabad.
Suggest the appropriate locator strategy for Sarah.
CSS = "ul.cities li:nth-of-type("Hyderabad")

54. Which java Enum is used to handle the keyboard strokes from web
driver library? Choose the most appropriate option.
Keys

55. There is an element on the web page when inspected on the


browser it looks like <div class=”errorMsg”>Error Message</div>
James wants to use selenium locators to identify the element.
Choose the correct set of commands to locate the element
effectively.
By.cssSelector(“div.errorMsg”)

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”)

59. Sean is coding to automate mouse interactions on a web browser.


Assist Sean to identify the mouse event specific methods from the
below options. Choose the appropriate options.
moveToElement()
moveByOffset()
release()

60. Samantha has designed a TestClass with the following methods:


public class TestClass
{
@BeforeMethod
public void method1() {……}
@AfterMethod
public void method2() {……}
@Test(dataProvider=”loginData”)
public void method3(String u, String p) {…..}
@DataProvider
public Object[][] loginData() {….}
}
Suppose loginData() generates 5 sets of login credentials, how many
times method1, method2 and method 3 would be executed ? Choose
the appropriate option.
Method1 – 5 times, Method2 – 5 times, Method3 – 5 times

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

63. 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
(?) - single character search (*) - one or more

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"

65. 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.
c1.setCellValue("data")

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”)

68. 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

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()

71. 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.
selenium RC

72. The web element looks like


<a href=”icart.jsp? params”>cart[19]</a>.
Which locator is most recommended for the scan to identify the
cart web element for all test iterations ?
By.partialLinkText()

73. Kevin is planning to write automation script for below scenario.


Given the user is on the payment page. He views a textbox with
attribute values . “Enter Mobile Number” written in the box. The
user must enter the mobile number in the box to proceed. Please
choose the correct command to help Kevin in automating the
scenario. Assume the textbox element is already identified and
stored in mobile txt box variable.
mobileTxtBox.clear(); mobileTxtBox.sendKeys(“xxxxxxxxxx”);

74. Which MS office component(s) can be handled by Apache POI


Library?
XLSX

75. Sarah is coding to automate a scenario for the selection of the


“from Cities” drop down box IN the flight booking application web
page, which WebDriver library class helps Sarah to automate the
drop-down box with different functions?
Select Class

76. Sean is performing verification using assert class functions from


TestNG. Suggest him the correct method to verify the
reference/address of the two objects to be identical?
assertSame(object1,object2)
77. Samantha has to execute automation scripts across multiple
platforms like windows, max and Linux. Which tool in the
Selenium suite will be useful for Samantha?
Selenium Grid

78. 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.switchTo().frame() immediately
will not move the context to 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 frame. Which method is used to switch back
to the main document from the frame?
switchTo.defaultContent()

79. Samantha is automating a test scenario. This scenario involves a


pop-up of confirmation window. She wants to interact with the pop-
up window and decline the confirmation. Pop-up window shows a
message “Do you want to cancel the payment?”
Driver.switchTo().alert().dismiss()

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()

82. Which java interface is used to capture screenshot of web page


using Web Driver API?
TakesScreenshot

83. Consider the below HTML code snippet.


Email ; <label id= “Email” class= “style1” name= “input”>
Which is the best locator to identify the email web element?
By.xpath(“//label[@id= ‘email’]”)

You might also like