
1) What is Selenium?
a) A programming language
b) A web browser
c) A tool for automating web browsers
d) A software for data analysis
Answer: c) A tool for automating web browsers
2) Which programming languages can be used with Selenium?
a) Java, Python, and Ruby
b) PHP, C#, and Perl
c) Java, JSON, and HTML
d) C++, Python, and XML
Answer: a) Java, Python, and Ruby
3) What is the difference between WebDriver and Selenium RC?
a) WebDriver supports multiple browsers, while Selenium RC only supports one browser
b) Selenium RC supports multiple browsers, while WebDriver only supports one browser
c) There is no difference between WebDriver and Selenium RC
d) WebDriver is faster and more reliable than Selenium RC
Answer: b) Selenium RC supports multiple browsers, while WebDriver only supports one browser
4) Which class in Selenium is used to interact with dropdown menus?
a) Select
b) Checkbox
c) Radiobutton
d) ComboBox
Answer: a) Select
5) How do you select multiple checkboxes in Selenium?
a) By using the select method
b) By using the click method
c) By using the checkAll method
d) By using the selectAll method
Answer: b) By using the click method
6) Which method in Selenium is used to switch between frames?
a) switchToFrame()
b) moveToFrame()
c) changeFrame()
d) setFrame()
Answer: a) switchToFrame()
7) How do you upload a file using Selenium?
a) By using the sendKeys method
b) By using the uploadFile method
c) By using the setFile method
d) By using the selectFile method
Answer: a) By using the sendKeys method
8) Which method in Selenium is used to get the current URL of the page?
a) getCurrentURL()
b) getCurrentPageURL()
c) getPageURL()
d) getUrl()
Answer: a) getCurrentURL()
9) How do you maximize the browser window in Selenium?
a) By using the maximizeWindow() method
b) By using the setMax() method
c) By using the maximize() method
d) By using the fullScreen() method
Answer: c) By using the maximize() method
10) Which method in Selenium is used to simulate keyboard actions?
a) sendKeys()
b) pressKey()
c) typeKeys()
d) simulateKeys()
Answer: a) sendKeys()
11) What is an XPath?
a) A syntax for creating HTML documents
b) A syntax for querying XML documents
c) A syntax for styling CSS documents
d) A syntax for defining SQL statements
Answer: b) A syntax for querying XML documents
12) Which XPath locates the first element in the HTML code that matches the given criteria?
a) //tagname[@attribute=’value’]
b) //tagname[position()=1]
c) //tagname[1]
d) //tagname/*[1]
Answer: b) //tagname[position()=1]
13) Which method in Selenium is used to clear the text of a text field?
a) clear()
b) delete()
c) reset()
d) clearText()
Answer: a) clear()
14) How do you scroll down a page using Selenium?
a) By using the scroll() method
b) By using the scrollTo() method
c) By using the scrollDown() method
d) By using the sendKeys() method with the PAGE_DOWN key
Answer: d) By using the sendKeys() method with the PAGE_DOWN key
15) Which annotation in Selenium is used to mark a method as a test case?
a) @BeforeEach
b) @AfterEach
c) @Test
d) @BeforeTest
Answer: c) @Test
16) How do you launch a Firefox browser using Selenium?
a) By creating an object of the FirefoxBrowser class
b) By creating an object of the FirefoxDriver class
c) By creating an object of the SeleniumDriver class
d) By creating an object of the Browser class
Answer: b) By creating an object of the FirefoxDriver class
17) Which method in Selenium is used to accept an alert box?
a) accept()
b) confirm()
c) dismiss()
d) getText()
Answer: a) accept()
18) How do you wait for an element to load in Selenium?
a) By using the waitForElement() method
b) By using the sleep() method
c) By using the wait() method
d) By using the WebDriverWait() class
Answer: d) By using the WebDriverWait() class
19) Which method in Selenium is used to get the title of the current page?
a) getTitle()
b) getCurrentTitle()
c) getPageTitle()
d) getWebTitle()
Answer: a) getTitle()
20) How do you refresh a page in Selenium?
a) By using the refresh() method
b) By using the reload() method
c) By using the restart() method
d) By using the refreshPage() method
Answer: a) By using the refresh() method
21) How do you close a browser window using Selenium?
a) By using the close() method
b) By using the exit() method
c) By using the quit() method
d) By using the stop() method
Answer: c) By using the quit() method
22) What is a WebElement in Selenium?
a) A browser window
b) An HTML element
c) A web page
d) A programming language
Answer: b) An HTML element
23) Which method in Selenium is used to select a radiobutton?
a) select()
b) deselect()
c) click()
d) tap()
Answer: c) click()
24) Which method in Selenium is used to get the value of an attribute of an HTML element?
a) getAttribute()
b) readAttribute()
c) fetchAttribute()
d) getElementAttribute()
Answer: a) getAttribute()
25) How do you switch to a new window in Selenium?
a) By using the switchToWindow() method
b) By using the changeWindow() method
c) By using the switch() method
d) By using the getWindowHandles() method
Answer: d) By using the getWindowHandles() method
26) Which method in Selenium is used to execute JavaScript code?
a) execute()
b) executeScript()
c) runScript()
d) evaluateScript()
Answer: b) executeScript()
27) Which method in Selenium is used to get the text of an alert box?
a) getText()
b) getMessage()
c) getContent()
d) getAlertText()
Answer: a) getText()
28) How do you navigate back to the previous page in Selenium?
a) By using the back() method
b) By using the previous() method
c) By using the navigateBack() method
d) By using the goBack() method
Answer: a) By using the back() method
29) Which method in Selenium is used to get the size of an HTML element?
a) getSize()
b) getDimension()
c) getArea()
d) getLength()
Answer: a) getSize()
30) How do you switch to an iframe in Selenium?
a) By using the switchToIframe() method
b) By using the changeIframe() method
c) By using the switch() method with the iframe ID
d) By using the switchTo().frame() method with the element
Answer: d) By using the switchTo().frame() method with the element
31) Which method in Selenium is used to drag and drop an element?
a) dragAndDrop()
b) moveAndDrop()
c) drag()
d) drop()
Answer: a) dragAndDrop()
32) How do you set the implicit wait time in Selenium?
a) By using the setImplicitWait() method
b) By using the setWaitTime() method
c) By using the ImplicitWait() class
d) By using the WebDriverWait() class
Answer: c) By using the ImplicitWait() class
33) Which method in Selenium is used to switch to the parent frame?
a) switchToParentFrame()
b) changeToParentFrame()
c) switchTo().parentFrame()
d) switch().parentFrame()
Answer: c) switchTo().parentFrame()
34) Which method in Selenium is used to hover over an element?
a) hover()
b) move()
c) drag()
d) clickAndHold()
Answer: b) move()
35) How do you clear a cookie in Selenium?
a) By using the clearCookie() method
b) By using the deleteCookie() method
c) By using the removeCookie() method
d) By using the clearAllCookies() method
Answer: b) By using the deleteCookie() method
36) Which method in Selenium is used to scroll to the bottom of a page?
a) scrollToBottom()
b) scrollDown()
c) scrollToEnd()
d) sendKeys() with the END key
Answer: d) sendKeys() with the END key
37) How do you set a timeout for a test case in Selenium?
a) By using the setTimeout() method
b) By using the setTestTimeout() method
c) By using the DefaultTimeout() class
d) By using the WebDriverWait() class
Answer: d) By using the WebDriverWait() class
38) Which method in Selenium is used to deselect all checkboxes?
a) deselectAll()
b) clear()
c) reset()
d) click()
Answer: a) deselectAll()
39) How do you execute Selenium tests in parallel?
a) By running multiple instances of the same test case
b) By using Selenium Grid
c) By using the ParallelExecution() class
d) By using the Java ExecutorService interface
Answer: b) By using Selenium Grid
40) Which method in Selenium is used to delete all cookies?
a) deleteAllCookies()
b) removeCookies()
c) clearAllCookies()
d) removeAllCookies()
Answer: a) deleteAllCookies()
41) How do you highlight an element in Selenium?
a) By using the highlight() method
b) By using the border() method
c) By using the outline() method
d) By using JavaScript code to change the CSS style
Answer: d) By using JavaScript code to change the CSS style
42) Which method in Selenium is used to drag an element to a specific location?
a) dragAndDropBy()
b) moveAndDropTo()
c) dragTo()
d) dropTo()
Answer: a) dragAndDropBy()
43) How do you get the list of all links on a webpage using Selenium?
a) By using the getLinks() method
b) By using the findElements() method with the tag name ‘a’
c) By using the getElementsByTagName() method with the value ‘a’
d) By using the linkList() method
Answer: b) By using the findElements() method with the tag name ‘a’
44) Which method in Selenium is used to take a screenshot of the page?
a) takeScreenshot()
b) captureScreen()
c) getScreenshot()
d) saveScreenshot()
Answer: a) takeScreenshot()
45) How do you set the size of the browser window in Selenium?
a) By using the setSize() method
b) By using the setDimension() method
c) By using the setWidth() and setHeight() methods
d) By using the manage().window().setSize() method
Answer: d) By using the manage().window().setSize() method
46) Which method in Selenium is used to get the text of a WebElement?
a) getText()
b) read()
c) fetchText()
d) getElementText()
Answer: a) getText()
47) How do you set the position of the browser window in Selenium?
a) By using the setPosition() method
b) By using the setLocation() method
c) By using the setX() and setY() methods
d) By using the manage().window().setPosition() method
Answer: d) By using the manage().window().setPosition() method
48) Which method in Selenium is used to get the current window handle?
a) getCurrentWindow()
b) getCurrentHandle()
c) getWindow()
d) getWindowHandle()
Answer: d) getWindowHandle()
49) How do you disable browser cookies in Selenium?
a) By using the disableCookies() method
b) By editing the browser settings manually
c) By using the options().disableCookies() method
d) By setting the ‘disableCookies’ property to ‘true’
Answer: c) By using the options().disableCookies() method
50) Which method in Selenium is used to delete a specific cookie?
a) deleteSpecificCookie()
b) removeCookieNamed()
c) clearCookieNamed()
d) deleteCookieNamed()
Answer: b) removeCookieNamed()
- Top 10 DevOps Trainers in the world - October 7, 2023
- What is Cookies and Why it is Used? - May 24, 2023
- TOP trends of transitions in TikTok - May 10, 2023