Selenium Automation MCQs

Selenium Automation MCQs

These Selenium Automation multiple-choice questions and their answers will help you strengthen your grip on the subject of Selenium Automation. You can prepare for an upcoming exam or job interview with these 90+ Selenium Automation MCQs.
So scroll down and start answering.

1: Which of the following methods makes an expectation that a new window will be opened and have the number of windows handles increase?

A. xpected_conditions.new_window_is_opened(current_handles)

B.   selenium.webdriver.supporLexpected_conditions.number_of_windows_to_be(num_windows)

C.   None

2: If you wanted to access the element that has the text "This element has an ID that changes every time the page is loaded" in it, then which of the following is used?

A.   lldiv[contains(@id,‘time_')]

B.   lldiv[contains(@id_time())]

C.   l/div[parameter(@id_time())]

D.   l/div[parameter(@id,'time_')]

3: Method which selects the option which displays the text matching the parameter passed to it

A.   selectVisibleText

B.   selectByVisibleText

C.   select_VisibleText

D.   select_ByVisibleText()

4: Which of the following base classes should be extended while def‌ining servlets for a hub in which you are required to access the internals of the Hub in Selenium-Grid?

A.   javax.servlet.http.HttpServlet

B.   org.openqa.grid.web.servlet.RegistryBasedServlet

C.   Either option a or b could be used.

5: Which of the following commands is used for conf‌iguring implicit wait and which also allows the driver to wait for an element to appear in DOM for 15 seconds after an initial try?

A.   driver.manage0.imp|icitlyWait.timeouts(15,TimeUnitSECONDS);

B.   driver.manage0.timeoutso.implicitlyWait(15.TimeUnit.SECONDS);

C.   implicitlyWait.timeouts(15).driver.manageo;

D.   implicitlyWait.driver.manage(timeouts (T imeUnitSECONDS, 15));

6: How to select all Options that have a value matching the argument?

A.   None

B.   call select_by_visible_text(text)

C.   call select_by_value(value)

D.   call select_by_index(index)

7: Which of the following is the correct Java syntax that is used for moving between named windows using WebDriver?

A.   driver.switchT00.window("windowName");

B.   driver.switchTo(window("windowName"));

C.   driver.switchTo().window.windowNarne;

D.   driver.window.switchToO.windowName;

8: We use the dot (.) operator followed by either a ‘ or a +. The + tells the regular expression that there will be instances between "0" and “n", while the * tells the regular expression that there will be instances between "1" and "n".



9: Which of the following commands is used by Selenium grid for checking the ports used by all running programs on your machine?

A.   netstat -at

B.   netstat -a

C.   netstat -u

D.   netstat —|

10: Which of the following is the correct syntax of the command that is used for setting up Selenium-Grid and starting a hub with default parameters?

A.   java -jar grid.selenium-server-standalone-2.44.0.jar -role hub

B.   java -jar selenium-server—standalone-2.44.0.jar -role hub

C.   java -jar hub-grid~selenium-server-standalone-2.44.0.jar -role

D.   java -jar hub-selenium-server-standalone-2.44.0.jar -role

11: Which of the following is a correct difference b/w getWindowHandles() and getWindowHandleO?

A.   None of these.

B.   getWindowHandlesO returns handles of all the open browsers whereas getWindowHandleo gets the address of the current browser.

C.   getWindowI-landleso returns the active browser handle whereas getWindowI-Iandleo gives the top most browser handle.

D.   getWindowI-landleso returns a String whereas getWindowI-landleo returns an lterator.

12: Which of the following WebDriver commands is used to check the presence of a web element?

A.   VerifyElementPresent

B.   lsElementExist

C.   lsElementPresent

D.   verifyTextPresent

13: Which two commands you can use to validate a button?

A.   VerifyTextPresent and assertTextPresent

B.   VerinylementPresent and assertElementPresent

C.   VerifyAlertPresent and assertAlertPresent

D.   VerifyAlert and assertAlert

14: Which of the following methods makes an expectation for checking that the title contains a case- sensitive substring?


B.   seleniumwebdrivensupport.expected_conditions.text_to_be_present_in__element_value(locator, text_)

C.   None



Consider the element given below.

Which of the following Java commands will be used for locating the above element in WebDriver?


WebElement element = WebElemenLf‌"exampleDiv");  


WebElement element = driver.element.f‌“exampleDiv"));   


WebElement element = driver.findElement("exampleDiv")); 


WebElement element = WebElemeanindElementid("exampleDiv");

16: How to wait until an element is no longer attached to the DOM?

A.   selenium.webdriver.supportexpected_conditions.presence_of_element_located(locator)


C.   selenium.webdrivensupportexpected_conditions.presence_of_a|l_eIements_located(locator)

D.   None

17: Which of the following is the correct syntax for defining an explicit wait for a set of common conditions using ExpectedConditions class?


WebDriverWait exampleWait = new WebDriverWait (15, TimeUnitSECONDS);
ExpectedConditions.exampleWait.until.titleContains("Learning Selenium");


WebDriverWait exampleWait = new WebDriverWait (T imeUnit.SECONDS, 15);
ExpectedConditions.until.titleContains. exampleWait("Learning Selenium");   


WebDriverWait exampleWait = new WebDriverWait (15, driver);
exampleWait.until(ExpectedConditions.title.contains("Learning Selenium"));


WebDriverWait exampleWait = new WebDriverWait (driver, 15);
exampleWait.until(ExpectedConditions.titleContains("Learning Selenium"));    

18: If you wish to move backward in your browser's history, irrespective of the behavior of browser, then which of the following is the correct Java method to do so in WebDriver?

A.   driver.get0.backward0;

B.   driver.get(back);

C.   driver.navigate(back);

D.   driver.navigate().back();

19: Which of the following is the correct syntax of the method that is used for creating an explicit wait condition for an alert to be displayed on a page?

A.   new WebDriverWait(10).get(ExpectedCondtions.alertlsPresentO);

B.   new WebDriverWait(ExpectedCondtions.alertlsPresent(10));

C.   new WebDriverWait0.wait(ExpectedCondtions.alertlsPresent(driver, 10));

D.   new WebDriverWait(driver. 10).untiI(ExpectedCondtions.alertlsPresent0);

20: Which among the following is the most efficient location strategy in Selenium, in terms of test performance, such that it also makes your test code more readable?

A.   Using element's ID

B.   By a link's text

C.   Using an XPath statement

D.   Using document Object model (DOM)

21: Which of the following combination of the WebDriver's sendKeysO is not correct?

A.   sendKeys(Keys.T' AB) == sendKeys("\uE004“)

B.   sendKeys(Keys.F5) = sendKeys("\uEO35")

C.   sendKeys(Keys.PAGE_DOWN) == sendKeys(AuEOOF")

D.   sendKeys(KeysARROW_DOWN) = sendKeys("\uE015")

E.   sendKeys(Keys.ENTER) = sendKeys("\u EO0A")

F.   sendKeys(Keys.SPACE) = sendKeys(“\uEOOD”)

22: Which of the following is the correct method for initializing Page Factory in Selenium?

A.   initElements.PageFactoryO;

B.   PageFactory.initialize();

C.   PageFactory.initElements();

D.   initialize.PageFactory();

23: Which of the following options can be used for performing a right-click operation in Selenium?

A.   click()

B.   beforeClickOn

C.   contextClick

D.   None of these

24: ln Selenium-Grid, which of the following Selenium commands using Java can be used for changing the port used by hub to 4441?

A.   java -selenium—server—standalone-2.44.0.jar hub -node 4441.port

B.   java -selenium-server-standalone-2.44.0.jar snode- role hub —add -port 4441

C.   java -jar selenium-server-standalone-2.44.0.jar -role hub -port 4441

D.   java -jar selenium-server—standalone-2.44.0.jar -role hub 4441-port

25: Which of the following Selenium commands using Java can be used for accessing command-line help for Selenium-Grid?

A.   java -jar selenium-server-standalone-2.44.0.jar -h

B.   java -jar selenium-server-standalone-2.44.0.jar -help

C.   java ~jar selenium-server—standalone-2.44.0.jar -role node -h

D.   java -jar selenium-server-standalone-2.44.0.jar -role -help -node

26: Using Selenium, how can we click on an element at certain coordinates?

A.   Selenium WebDriver does not support this functionality

B.   Using the Actions class‘ method moveToElement (element, xOffset, yOffset)

C.   Using the Actions class' method moveToElement ( xOffset. yOffset)

D.   Using the Actions class' method moveToElement ( xOffset. yOffset. element)

27: Which of the following Selenium commands is responsible for verifying the expected text and its corresponding HTML tag to be present on the page?

A.   verifyTextPresent

B.   verinylementPresent

C.   verifyText

D.   Either option a or b could be used

28: Which of the following drivers does/do NOT provide native XPath support?

A.   HtmlUnit Driver

B.   Firefox Driver

C.   Internet Explorer Driver

D.   Both options a and b


What does the below lines of code meant for?

WebDriver driver = new FirefoxDriverO;

Selenium selenium = new WebDriverBackedSelenium(driver,



Will simply start the browser and open the site. 


Will run Selenium 1.0 tests in webdriver. 


None of these.


Will run webdriver tests using selenium.

30: The FluentWait class is implementation of which of the following Selenium WebDriver interfaces?

A.   Alert

B.   Wait

C.   TargetLocator


Choose True or False.

While running tests with RemoteWebDriver or Selenium-Grid. you can take screenshots.





32: Which of the following is the correct syntax of the method that is used for performing double click on an element?

A.   Actions builder = new Actionso; doubleClick.builder.message.perform();

B.   Actions builder = new Actions(driver); builder.doubleClickfmessage).perform0;

C.   Actions driver = new Actions(builder); builder.doubleClick.perform0;

D.   Actions driver = new Actions(builder); builder.doubleClick.perform(message);


In Order to mouse hover on a web element using WebDriver? Is the below written code uses the correct syntax and code

// lnstantiating Action Interface

Actions actions=new Actions(driver);

ll howering on the dropdown

actionsmoveToElement(driver.f‌indElement("id of the dropdown"))).perform();

// Clicking on one of the items in the list options

WebElernent subLinkOption=driver.findElement("id of the sub |ink"));;



B.   False

34: How to import Selenium's TimeoutException in Python?

A.   None

B.   import selenium.common.exceptions

C.   import selenium.common.exceptions.TimeoutException

D.   from selenium.common.exceptions import TimeoutException

35: While testing an application in Selenium, which of the following should either not be used at all or should be minimally used?

A.   Implicit Wait

B.   Explicit Wait

36: Which of the following WebDriver methods is used to change focus to an alert, a frame or a browser window?

A.   switchTol)

B.   changeFocus

C.   changeTo

D.   setFocuso

37: Which of the following statements is incorrect?

A.   The waitForElementPresent command pauses an execution until an expected new page loads. This method is automatically called whenever clickAndWait is used.

B.   The assertTitle command verifies an expected page title.

C.   The open command is used for opening a page using URL.

D.   The verifyTable command verifies the expected contents of a table.

38: Which of the following is the correct syntax of the method that is used for directly accessing the alert box in Selenium?

A.   driver.alert().accepto;

B.   driver.switchTo().alert0.accept0;

C.   driver.get0.alert0.accept0;

D.   driver.switchT00.get0.alert0.accept0;


Select the correct the WebDriver methods to manage web-based alerts?




4.sendKeys(String stringToSend)



1,2 & 5 


3.5 &1 


All of the Above


1,2,4 & s

40: Which method is used when you want to verify whether a certain check box, radio button, or Option in drop-down box is selected in Web driver Selenium ?

A.   is_Selected0

B.   isSelect()

C.   isSelected()

D.   is_Select()

41: Which of the following Selenium methods defines whether an element is visible and enabled?

A.   elementToBeSelected (WebElement element)

B.   presenceOfElementLocated (By locator)

C.   elementToBeClickable(By locator)

D.   titleContains

42: While working with multiple frames, when the test f‌low needs to be moved to another frame after the completion of an operation on the previous frame, which of the following methods should be called first?

A.   driver.switchT00.frarne()

B.   drivenf‌indElement

C.   drivenswitchToO.defaultContent

D.   driver.switchTo().window0

43: When a conf‌irmation is generated. which of the following options must be called to consume it in order to avoid failure of the next Selenium action?

A.   getConf‌irmation

B.   verifyConf‌irmation

C.   waitForConf‌irmation

D.   assertConf‌irmation

44: Which of the following options should be used in your test case if you want the failure of any test to abort the current test case?

A.   verify

B.   assert

C.   wait

D.   Either option a or b can be used

45: Which of the following is the correct command that causes the Node to be spawned and a new servlet "" to be added to the node?

A.   java -cp ':. org.openqa.grid.selenium.GridLauncher -role node -hub -servlets

B.   java -cp ‘ - selenium-server-standalone-2.44.0.jar -role node http://localhostz4444 lgrid/register -servlets

C.   java -cp ' - selenium-server-standalone-2.44.0.jar -ro|e node - -servlets

D.   java -cp ”:. org.openqa.grid.selenium.GridLauncher -role node -hub http://localhost:4444 lgrid/register -servIets


Which of the following is the correct path for accessing all the servlets added to the node running on port 5555?

Consider abc as the machine name or ip on which the node is running.










Which of the following is/are the correct reason(s) for using Selenium-Grid?

i) For running tests against multiple browsers.

ii) For running tests against browsers running on different operating systems.

iii) For reducing the time taken by the test suite to complete a test pass.

iv) For running the test using Internet Explorer Driver on Mac OS or Unix.

v) For running tests with slow speed.


Only option iii) 


Only options i), ii) and iii) 


Only options i), iii) and iv)


Only options iii), iv) and v)

48: Which of the following statements is correctly def‌ining the Time-out test in TestNG?

A.   It‘s the time duration to wait for a test suite to finish its execution.

B.   It's the time duration to wait for a test group to finish its execution.

C.   It‘s the time duration to wait for a test to f‌inish its execution.

D.   None of the above

49: Which Of the following is correct about tag and attribute name for HtmlUnit Driver?

A.   It should be upper-cased

B.   It should be lower-cased

C.   It can be case insensitive

50: ln Selenium, up to how many parameters can be passed to an action method?

A.   One

B.   Two

C.   Three

D.   Four