Last Updated On
This post contains 25 useful Selenium multiple-choice questions (quiz) to self-test your knowledge of Selenium.
You can find the questions for the below-mentioned answers in this post –
Selenium Multiple Choice Questions – MCQ1
Answers
1) b) Selenium is the open-source test automated tool to test web-based UI which supports many different languages like Java, Python, Perl, PHP, Ruby, and C#.
2) a) Interface
WebDriver is an interface in Selenium which provides a simple interface to interact with and test web applications. It encompasses several implementations like ChromeDriver, FirefoxDriver, and others, each corresponding to different web browsers.
3) e) WebElement
WebElement is not considered a standalone component of Selenium; instead, it is an interface within Selenium WebDriver used to represent elements on a web page.
4) b) ASP
5) b) Compilation error- Cannot instantiate the type WebDriver
In Selenium, WebDriver is an interface, and you cannot instantiate an interface directly. You need to create an instance of a class that implements the WebDriver interface, such as ChromeDriver, FirefoxDriver, etc.
WebDriver driver = new ChromeDriver();
6) c) Chromedriver
To run Selenium WebDriver scripts on the Chrome browser, we use ChromeDriver.
// Initialize ChromeDriver
WebDriver driver = new ChromeDriver();
7) d) i, ii, iii
8) a) thread.sleep();
It can be used to pause the execution in Java (and consequently in Selenium tests) for a specified duration, it is not considered a Selenium-specific wait mechanism.
9) a) Yes
To know more about the Implicit Wait in Selenium, please refer to Implicit and Explicit Wait in Selenium WebDriver.
10) c) Both a and b
Example of Fluent Wait
To know more about the Fluent Wait in Selenium, please refer to What is Fluent Wait in Selenium WebDriver.
11) b) driver.close() closes the current window and d) driver.quit() closes every associated window with this driver and quits the driver
12) b) //tag-name[@attribute=’attribute value’]
13) a) isDisplayed()
It returns true if the element is visible and false if it is not.
14) b) isEnabled()
It returns true if the element is enabled and false if it is not.
15) b) StaleElementReferenceException
This exception is thrown when a web element that was previously located is no longer present in the DOM (Document Object Model). If the web page is refreshed or modified after locating an element, the reference to that element may become stale, leading to this exception.
16) b) .*
17) a) WebElement element = driver.findElement(By.xpath(“//*[contains(text(), ‘ QAAutomation’)]”));
18) d) None
Correct commands are
driver.navigate().to("https://www.qaautomation.expert");
driver.get("https://www.qaautomation.expert");
19) a) i & ii
i. navigate().to("url") - driver.navigate().to("https://www.qaautomation.expert");
ii. open("url") - driver.get("https://www.qaautomation.expert");
20) a) sendKeys() is used to enter the text inthe textbox.
// Locate the text box element
WebElement textBox = driver.findElement(By.id("textboxId"));
// Enter text into the text box
textBox.sendKeys("Sample text");
21) c) List of WebElements
22) c) driver.manage().window().maximize();
To know more about the maximizing the window in Selenium, please refer to How to maximize and minimize the window in Selenium.
23) b) findElements(By.XPath)
24) a) element.clear()
25) a) Select
Select class allows us to select and deselect options by visible text, index, or value.
To learn more about Select class, please refer to this tutorial – How to Select value from Drop down list or perform Multiple Selection Operations in WebDriver
19 & 25 are wrongly mentioned in this page.
LikeLike
Thank you. I have updated answer for 19, but 25 is correct.
LikeLike