selenium banner

Selenium Multiple Choice Questions (MCQs) and Answers

Master Selenium with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of Selenium concepts. Begin your placement preparation journey now!

Q91

Q91 How do you skip a test case conditionally in TestNG?

A

@Ignore

B

skipTest()

C

throw SkipException()

D

ignoreTest()

Q92

Q92 A TestNG test case runs even though it should be skipped. What is likely missing?

A

@BeforeClass

B

SkipException

C

@Test(enabled=false)

D

@BeforeTest

Q93

Q93 A test with multiple dependencies fails. What can be used to manage test order in TestNG?

A

@AfterTest

B

dependsOnMethods

C

@TestGroup

D

SequentialExecution

Q94

Q94 What is the main purpose of the Page Object Model (POM) design pattern?

A

To store data in pages

B

To centralize web elements and methods

C

To handle web services

D

To improve test data management

Q95

Q95 How does POM improve test maintenance?

A

By reducing the number of test cases

B

By consolidating element locators

C

By adding extra code

D

By enabling faster execution

Q96

Q96 In POM, where are the page elements and actions defined?

A

Directly in the test script

B

In a separate Page class

C

In the test configuration file

D

In the data source file

Q97

Q97 What is a disadvantage of using POM for small test suites?

A

It increases execution time

B

It adds complexity and overhead

C

It uses more test data

D

It requires more storage

Q98

Q98 How would you initialize a Page Object class in Selenium?

A

new Page(driver)

B

driver.getPage()

C

driver.load(Page.class)

D

Page page = new Page(driver)

Q99

Q99 In POM, which annotation is used in Selenium to initialize WebElements?

A

@DataProvider

B

@FindBy

C

@Test

D

@Locator

Q100

Q100 How do you use the PageFactory in Selenium POM?

A

PageFactory.load()

B

PageFactory.initElements(driver, pageClass)

C

Page.load(driver)

D

driver.init(pageClass)

Q101

Q101 A test script fails to interact with elements in a POM class. What could be the issue?

A

Incorrect URL

B

Page not initialized

C

Wrong test order

D

Low network speed

Q102

Q102 A test fails due to a "NullPointerException" in a POM class. What is a likely solution?

A

Set an Implicit Wait

B

Initialize the Page Object class

C

Restart WebDriver

D

Disable page caching

Q103

Q103 What is the primary purpose of Selenium Grid?

A

To execute tests on mobile applications

B

To enable parallel testing on multiple machines

C

To run tests on a single browser

D

To create test data

Q104

Q104 Which component acts as the central server in a Selenium Grid setup?

A

Node

B

Client

C

Hub

D

WebDriver

Q105

Q105 What is a "Node" in Selenium Grid?

A

A central server

B

A connected machine to execute tests

C

A test data storage location

D

A WebDriver configuration

Q106

Q106 Which file format is used to configure nodes in a Dockerized Selenium Grid setup?

A

.xml

B

.properties

C

.json

D

.yml

Q107

Q107 How do you specify a remote URL for the WebDriver in Selenium Grid?

A

driver.remote(url)

B

new RemoteWebDriver(url, capabilities)

C

driver.startRemote()

D

new WebDriver(url)

Q108

Q108 Which capability is required to specify the browser type in a Selenium Grid test?

A

browserName

B

platform

C

version

D

nodeName

Q109

Q109 How do you limit the number of concurrent sessions in a Selenium Grid node configuration?

A

Set maxSessions parameter

B

Use maxNodes parameter

C

Configure in hub

D

Limit browser count

Q110

Q110 A Selenium Grid test fails with a "SessionNotCreatedException." What could be a likely cause?

A

Incorrect URL

B

Unsupported browser version

C

Invalid test case

D

Hub is down

Q111

Q111 A node fails to register with the hub in Selenium Grid. What should you check?

A

Verify the test case

B

Ensure network connectivity

C

Test browser compatibility

D

Run without Grid

Q112

Q112 Which method is used to switch to an alert in Selenium WebDriver?

A

driver.switchTo().frame()

B

driver.switchTo().window()

C

driver.switchTo().alert()

D

driver.getAlert()

Q113

Q113 Which method would you use to accept a browser alert in Selenium?

A

alert.dismiss()

B

alert.accept()

C

alert.confirm()

D

alert.click()

Q114

Q114 What does the driver.switchTo().frame(int index) method do in Selenium?

A

Closes a frame

B

Switches to a frame based on index

C

Switches to the parent window

D

Opens a new frame

Q115

Q115 In Selenium, which method is used to switch back to the main window from a frame?

A

switchTo().defaultContent()

B

switchTo().mainWindow()

C

switchTo().parentWindow()

D

switchTo().root()

Q116

Q116 How do you close the current window in Selenium WebDriver?

A

driver.quit()

B

driver.close()

C

driver.dismiss()

D

driver.switchTo().window()

Q117

Q117 How do you switch to a new window by its title in Selenium?

A

switchTo().title()

B

switchTo().window(title)

C

switchTo().alert(title)

D

switchTo().frame(title)

Q118

Q118 How do you dismiss a confirmation alert in Selenium WebDriver?

A

alert.accept()

B

alert.confirm()

C

alert.dismiss()

D

alert.ignore()

Q119

Q119 A Selenium test fails due to an "UnhandledAlertException." What is a likely cause?

A

Alert is already handled

B

Alert is ignored

C

An unexpected alert is present

D

WebDriver is not initialized

Q120

Q120 A test fails to switch to a frame. What could be a common cause?

A

The frame does not exist

B

The frame is hidden

C

The frame is minimized

D

WebDriver is outdated

ad verticalad vertical
ad