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!

Q61

Q61 Which method in Selenium is used to switch to a new browser window?

A

driver.switchTo().window()

B

driver.switchTo().tab()

C

driver.getWindowHandle()

D

driver.selectWindow()

Q62

Q62 How can you check if a checkbox is selected in Selenium WebDriver?

A

isChecked()

B

isSelected()

C

isClicked()

D

getValue()

Q63

Q63 Which Selenium command is used to retrieve the attribute value of a web element?

A

element.getText()

B

element.getValue()

C

element.getAttribute()

D

element.getProperties()

Q64

Q64 What is the purpose of the driver.switchTo().frame() method?

A

To close the frame

B

To move focus to a specific frame

C

To maximize the frame

D

To reload the frame

Q65

Q65 How can you interact with hidden elements in Selenium?

A

Use JavaScript Executor

B

Direct click

C

Clear text

D

Use getText()

Q66

Q66 How do you handle browser alerts in Selenium WebDriver?

A

driver.alert().accept()

B

driver.switchTo().alert().accept()

C

driver.alertAccept()

D

driver.confirmAlert()

Q67

Q67 Which method is used to select an option by visible text in a dropdown list?

A

selectByValue()

B

selectByIndex()

C

selectByVisibleText()

D

selectText()

Q68

Q68 In Selenium WebDriver, how do you simulate pressing the Enter key?

A

sendKeys(Keys.ENTER)

B

driver.click(Keys.Enter)

C

driver.type(Keys.Enter)

D

pressEnter()

Q69

Q69 How can you perform a double-click action on an element in Selenium WebDriver?

A

action.doubleClick(element)

B

element.doubleClick()

C

element.click(2)

D

driver.doubleClick()

Q70

Q70 A test fails with a "NoAlertPresentException" error. What could be the cause?

A

Alert is not displayed

B

Network connection issue

C

Invalid URL

D

Alert is maximized

Q71

Q71 A script fails when trying to select an option from a dropdown. What could be a likely solution?

A

Use click() method instead

B

Verify dropdown is loaded

C

Restart the browser

D

Update browser version

Q72

Q72 A Selenium test encounters an "ElementNotInteractableException." What is a common cause?

A

Element is hidden or off-screen

B

Test case has a typo

C

Incorrect Selenium version

D

Network speed is high

Q73

Q73 What is the main purpose of waits in Selenium?

A

To speed up script execution

B

To handle page load times

C

To reduce code lines

D

To automatically close the browser

Q74

Q74 Which type of wait applies to all elements and is set once in Selenium WebDriver?

A

Explicit Wait

B

Thread.sleep

C

Implicit Wait

D

Fluent Wait

Q75

Q75 What is the advantage of using Explicit Wait over Implicit Wait?

A

It’s faster

B

It allows waiting for specific conditions

C

It applies to all elements

D

It doesn’t require imports

Q76

Q76 Which of the following conditions can be used with WebDriverWait?

A

Element to be editable

B

Element to load

C

Browser to close

D

Page title to update

Q77

Q77 In which scenario would Fluent Wait be preferred over Explicit Wait?

A

When wait conditions are static

B

For short load times

C

When polling is needed

D

For global application

Q78

Q78 How do you set an Implicit Wait of 10 seconds in Selenium?

A

driver.manage().timeouts().implicitWait(10)

B

driver.wait(10)

C

driver.setWait(10)

D

driver.setImplicitWait(10)

Q79

Q79 How would you apply an Explicit Wait until an element is clickable in Selenium?

A

WebDriverWait(driver,10).until(element.isClickable())

B

WebDriverWait(driver,10).until(EC.element_to_be_clickable(locator))

C

driver.waitClickable(10)

D

EC.clickable(driver,10)

Q80

Q80 Which method in Fluent Wait allows setting an exception to ignore during polling?

A

withIgnoreException()

B

ignoring()

C

pollException()

D

waitWithException()

Q81

Q81 A script fails due to a "TimeoutException." What is a likely solution?

A

Increase the wait time

B

Reduce screen size

C

Run on a different browser

D

Ignore the error

Q82

Q82 A script with Implicit Wait works on some elements but not others. What could be a better approach?

A

Add Explicit Waits for specific elements

B

Increase screen brightness

C

Run on headless mode

D

Decrease browser resolution

Q83

Q83 A test intermittently fails when waiting for a dynamic element. What might improve its reliability?

A

Increase Implicit Wait

B

Switch to Fluent Wait with polling

C

Reduce screen size

D

Change element locator

Q84

Q84 What is TestNG primarily used for in Selenium?

A

Browser automation

B

Test case management

C

Java development

D

Data analysis

Q85

Q85 Which annotation in TestNG is used to define a method that runs before each test?

A

@AfterTest

B

@BeforeMethod

C

@BeforeClass

D

@Test

Q86

Q86 What does the @Test annotation indicate in TestNG?

A

Setup method

B

Test method

C

Ignore method

D

Exit method

Q87

Q87 Which method in TestNG allows executing tests in a specified order?

A

@OrderOfExecution

B

@Test(priority=...)

C

@RunOrder

D

@SequentialExecution

Q88

Q88 How does TestNG manage data-driven testing?

A

@DataProvider

B

@Test

C

@Parameters

D

@Provider

Q89

Q89 How do you set up a group of tests in TestNG?

A

@Test(groups="groupName")

B

@Group(group="groupName")

C

@RunGroup("groupName")

D

@TestGroup("groupName")

Q90

Q90 How would you use a @DataProvider in TestNG to pass data to a test?

A

@DataProvider("name")

B

@Test(data="providerName")

C

@Test(dataProvider="name")

D

@Provider(name="data")

ad verticalad vertical
ad