Friday, August 23, 2024

Radio Button Handling Using Selenium Java MCQ

 MCQs on Radio Button Handling Using Selenium Java


Which Selenium WebDriver method is used to select a radio button? 

a) click()

b) select()

c) choose()

d) press()


Answer: a) click()


How do you check if a radio button is selected in Selenium WebDriver? a) isSelected()

b) isChecked()

c) isEnabled()

d) isChosen()


Answer: a) isSelected()


Which method would you use to check if a radio button is displayed on the webpage? 

a) isVisible()

b) isSelected()

c) isDisplayed()

d) isEnabled()


Answer: c) isDisplayed()


How can you select a radio button using its ID attribute in Selenium WebDriver? 

a) driver.findElement(By.xpath("//radio[@id='radio1']")).click();

b) driver.findElement(By.id("radio1")).click();

c) driver.findElement(By.className("radio1")).click();

d) driver.findElement(By.name("radio1")).click();


Answer: b) driver.findElement(By.id("radio1")).click();


Which exception is thrown if a radio button element is not found on the page? a) ElementNotVisibleException

b) NoSuchElementException

c) ElementNotSelectableException

d) TimeoutException


Answer: b) NoSuchElementException


How would you locate a radio button using its name attribute and select it? 

a) driver.findElement(By.id("radioButton")).click();

b) driver.findElement(By.name("gender")).click();

c) driver.findElement(By.className("radioButton")).click();

d) driver.findElement(By.tagName("input")).click();


Answer: b) driver.findElement(By.name("gender")).click();


If you need to verify the default selected state of a radio button, which method would you use? 

a) isDefaultSelected()

b) isSelected()

c) isDefault()

d) isChosen()


Answer: b) isSelected()


Which Selenium locator strategy would you use to find a radio button using its value attribute? 

a) By.linkText("radio")

b) By.xpath("//input[@value='male']")

c) By.id("radio")

d) By.className("radio")


Answer: b) By.xpath("//input[@value='male']")



What would be the correct way to interact with a disabled radio button? 

a) click()

b) isEnabled()

c) sendKeys(Keys.SPACE)

d) click() will throw an exception


Answer: d) click() will throw an exception




Which of the following is true about radio buttons in HTML? 

a) Multiple radio buttons with the same name can be selected at the same time.

b) Only one radio button in a group with the same name can be selected at a time.

c) Radio buttons are always disabled by default.

d) Radio buttons cannot have a default selected state.

Answer: b) Only one radio button in a group with the same name can be selected at a time.


How would you verify if a radio button is not selected?

 a) !element.isEnabled()

b) !element.isSelected()

c) element.isNotSelected()

d) element.isDeselected()

Answer: b) !element.isSelected()



What will happen if you try to click on a hidden radio button in Selenium? 

a) It will select the radio button without any error.

b) It will throw ElementNotVisibleException.

c) It will throw NoSuchElementException.

d) It will select the radio button after scrolling to it.

Answer: b) It will throw ElementNotVisibleException.


If you want to check whether a radio button is displayed on the screen, which of the following Selenium commands would you use? 

a) element.isVisible()

b) element.isSelected()

c) element.isDisplayed()

d) element.isEnabled()

Answer: c) element.isDisplayed()


Which of the following WebDriver methods will be useful to check whether a radio button is enabled or not?

a) isSelected()

b) isEnabled()

c) isVisible()

d) isChosen()

Answer: b) isEnabled()


Which Selenium method is used to locate a radio button element by its class name? 

a) By.id("radioButton")

b) By.name("radioButton")

c) By.className("radioButtonClass")

d) By.xpath("radioButton")

Answer: c) By.className("radioButtonClass")


What is the result of getAttribute("checked") on a selected radio button? 

a) Returns "true"

b) Returns "checked"

c) Returns null

d) Returns "selected"

Answer: b) Returns "checked"  -recheck 


Which locator strategy is best when handling dynamic radio buttons generated at runtime? 

a) By.id()

b) By.name()

c) By.cssSelector()

d) By.xpath()

Answer: d) By.xpath()


Password Handling Using Selenium Java MCQ

MCQs on Password Handling Using Selenium Java

Which WebElement method is used to enter a password into a password field using Selenium WebDriver?

a) sendKeys()

b) setText()

c) typePassword()

d) inputPassword()


Answer: a) sendKeys()


What is the best way to locate a password input field using its name attribute in Selenium WebDriver?

a) driver.findElement(By.id("password")).sendKeys("password123");

b) driver.findElement(By.name("password")).sendKeys("password123");

c) driver.findElement(By.className("password")).sendKeys("password123");

d) driver.findElement(By.tagName("password")).sendKeys("password123");


Answer: b) driver.findElement(By.name("password")).sendKeys("password123");


Which Selenium WebDriver method is used to clear the contents of a password field?

a) delete()

b) removeText()

c) clear()

d) reset()


Answer: c) clear()


How can you verify if a password field is enabled for user interaction?

a) isVisible()

b) isEnabled()

c) isDisplayed()

d) isAccessible()


Answer: b) isEnabled()


Which attribute would you check to ensure that an input field is of type password?

a) getAttribute("text")

b) getAttribute("type")

c) getAttribute("password")

d) getAttribute("fieldType")


Answer: b) getAttribute("type")


If you want to find a password field by its ID and enter text "SecurePass", what is the correct line of code?

a) driver.findElement(By.xpath("password")).sendKeys("SecurePass");

b) driver.findElement(By.id("password")).sendKeys("SecurePass");

c) driver.findElement(By.name("password")).sendKeys("SecurePass");

d) driver.findElement(By.linkText("password")).sendKeys("SecurePass");


Answer: b) driver.findElement(By.id("password")).sendKeys("SecurePass");


What will getAttribute("value") return when called on a password field?

a) The masked password (e.g., "*******")

b) The actual password

c) Null

d) The placeholder text


Answer: b) The actual password


To ensure a password field is present on the page before interacting with it, which method would you use?

a) isEnabled()

b) isSelected()

c) isDisplayed()

d) isPresent()


Answer: c) isDisplayed()


Which exception is thrown if the password field element is not found on the page?

a) ElementNotVisibleException

b) NoSuchElementException

c) ElementNotSelectableException

d) TimeoutException


Answer: b) NoSuchElementException


How would you simulate typing a password in a field followed by pressing the ENTER key?

a) element.sendKeys("password123", Keys.RETURN);

b) element.sendKeys("password123" + Keys.RETURN);

c) element.sendKeys("password123", Keys.ENTER);

d) Both a and c


Answer: d) Both a and c


Which Selenium method would you use to hide or mask input text for a password field?

a) setType("password")

b) sendKeys(Keys.HIDE)

c) This feature is automatically handled by the browser

d) maskText()

Answer: c) This feature is automatically handled by the browser



Which locator strategy would you use to find a password input field when the type attribute is set as "password"?

a) By.tagName("password")

b) By.cssSelector("input[type='password']")

c) By.id("password")

d) By.linkText("password")

Answer: b) By.cssSelector("input[type='password']")


What will happen if you try to retrieve the value of a masked password using getText()?

a) It will return the actual password

b) It will return an empty string

c) It will return the masked version (e.g., "*******")

d) It will throw an exception

Answer: b) It will return an empty string (Recheck this answer)


To verify that a password field's value is hidden (masked), you should check:

a) element.isMasked()

b) element.getAttribute("type").equals("password")

c) element.getText().equals("*******")

d) element.getValue().equals("password")

Answer: b) element.getAttribute("type").equals("password")



Which command sequence will clear and then enter a new password in a password field?

a) element.clear(); element.sendKeys("newPass123");

b) element.sendKeys(Keys.DELETE, "newPass123");

c) element.reset(); element.sendKeys("newPass123");

d) element.deleteText(); element.sendKeys("newPass123");

Answer: a) element.clear(); element.sendKeys("newPass123");


Textbox Handling Using Selenium Java MCQ

 MCQs on Textbox Handling Using Selenium Java


Which Selenium WebDriver method is used to enter text into a textbox?

a) typeText()

b) enterText()

c) sendKeys()

d) setText()


Answer: c) sendKeys()


How can you clear the text from a textbox in Selenium WebDriver?

a) clearText()

b) reset()

c) deleteText()

d) clear()


Answer: d) clear()


What is the correct syntax to locate a textbox by its name attribute and enter text "Hello"?

a) driver.findElement(By.id("textbox")).sendKeys("Hello");

b) driver.findElement(By.name("textbox")).sendKeys("Hello");

c) driver.findElement(By.className("textbox")).sendKeys("Hello");

d) driver.findElement(By.tagName("textbox")).sendKeys("Hello");


Answer: b) driver.findElement(By.name("textbox")).sendKeys("Hello");


If you want to verify whether a textbox is enabled or not, which method would you use?

a) isVisible()

b) isSelected()

c) isEnabled()

d) isDisplayed()


Answer: c) isEnabled()


Which method is used to retrieve the current text entered in a textbox?

a) getText()

b) getAttribute("value")

c) getValue()

d) getContent()


Answer: b) getAttribute("value")


To find a textbox using its ID and enter text "Automation", what is the correct line of code?

a) driver.findElement(By.xpath("textbox")).sendKeys("Automation");

b) driver.findElement(By.id("textbox")).sendKeys("Automation");

c) driver.findElement(By.name("textbox")).sendKeys("Automation");

d) driver.findElement(By.linkText("textbox")).sendKeys("Automation");


Answer: b) driver.findElement(By.id("textbox")).sendKeys("Automation");


How do you simulate pressing the ENTER key in a textbox using Selenium WebDriver?

a) element.sendKeys(Keys.RETURN)

b) element.sendKeys(Keys.ENTER)

c) element.press(Keys.ENTER)

d) Both a and b


Answer: d) Both a and b


What is the return type of the getAttribute() method when used to get the value of a textbox?

a) int

b) String

c) boolean

d) void


Answer: b) String


Which exception might you encounter if you try to interact with a non-existent textbox element?

a) NoSuchElementException

b) ElementNotVisibleException

c) StaleElementReferenceException

d) InvalidElementStateException


Answer: a) NoSuchElementException


To clear text from a textbox identified by CSS selector, what is the correct Selenium WebDriver command?

a) driver.findElement(By.cssSelector("textbox")).reset();

b) driver.findElement(By.cssSelector("textbox")).delete();

c) driver.findElement(By.cssSelector("textbox")).clear();

d) driver.findElement(By.cssSelector("textbox")).removeText();


Answer: c) driver.findElement(By.cssSelector("textbox")).clear();


How would you verify if a textbox is present on the webpage?

a) isPresent()

b) isDisplayed()

c) isVisible()

d) isEnabled()

Answer: b) isDisplayed()




Which method would you use to input a large amount of text into a textbox without typing each character individually?

a) setValue()

b) sendKeys(CharSequence...)

c) enterText()

d) appendText()

Answer: b) sendKeys(CharSequence...)


If you want to append text to the existing text in a textbox, which of the following commands should you use?

a) element.clear(); element.sendKeys("new text");

b) element.sendKeys(Keys.END, "new text");

c) element.clear(); element.sendKeys("new text appended");

d) element.sendKeys("new text appended");


Answer: b) element.sendKeys(Keys.END, "new text");




Which of the following methods allows you to verify if a textbox contains the expected default text?

a) getText()

b) getAttribute("value")

c) getCssValue("content")

d) isEnabled()

Answer: b) getAttribute("value")


What is the Selenium method to handle textboxes that require clearing old values before entering new ones?

a) sendKeys()

b) clear(), then sendKeys()

c) reset()

d) deleteText(), then sendKeys()

Answer: b) clear(), then sendKeys()


By Class Locators MCQ

 Here are 20 multiple-choice questions (MCQs) focusing on different types of locators in Selenium, including Name, ID, Class, Link Text, Partial Link Text, Tag Name, XPath, and CSS Selector:



Which locator strategy is generally the fastest and most reliable to find elements in Selenium?

a) XPath

b) ID

c) Class Name

d) CSS Selector


Answer: b) ID


Which locator strategy would you use to locate an element using its HTML tag name?

a) By.xpath()

b) By.tagName()

c) By.className()

d) By.cssSelector()


Answer: b) By.tagName()


If you want to find a web element by its name attribute, which locator should you use?

a) By.id()

b) By.name()

c) By.className()

d) By.cssSelector()


Answer: b) By.name()


Which of the following locators would be best to use if you want to locate an element with a unique ID attribute?

a) By.name()

b) By.id()

c) By.tagName()

d) By.linkText()


Answer: b) By.id()


To locate a hyperlink text that says "Home", which locator strategy would you use?

a) By.linkText("Home")

b) By.partialLinkText("Home")

c) By.xpath("//a[contains(text(),'Home')]")

d) By.cssSelector("a[title='Home']")


Answer: a) By.linkText("Home")


Which locator strategy allows you to find a link element based on a substring of its text?

a) By.linkText()

b) By.partialLinkText()

c) By.xpath()

d) By.cssSelector()


Answer: b) By.partialLinkText()


Which Selenium locator strategy is best to use when selecting elements by their CSS class?

a) By.id()

b) By.tagName()

c) By.className()

d) By.name()


Answer: c) By.className()



Which locator strategy uses a combination of tag name, class, ID, or attributes to locate elements?

a) By.className()

b) By.xpath()

c) By.linkText()

d) By.tagName()


Answer: b) By.xpath()



If an element does not have an ID, name, or class, which locator would be the most flexible to use?

a) By.linkText()

b) By.cssSelector()

c) By.xpath()

d) By.tagName()

Answer: c) By.xpath()



WebElement methods MCQ

 Absolutely, here are some multiple-choice questions (MCQs) focusing on Selenium WebElement methods:



Which method is used to enter text into a text field in Selenium WebElement?

a) sendText()

b) sendKeys()

c) enterText()

d) type()


Answer: b) sendKeys()


What does the click() method do when used on a Selenium WebElement?

a) Enters text into a text field

b) Submits a form

c) Simulates a mouse click on the element

d) Clears the text of an input field


Answer: c) Simulates a mouse click on the element


Which method would you use to clear the text from an input field?

a) clearText()

b) reset()

c) clear()

d) deleteText()


Answer: c) clear()


How can you retrieve the text content of a WebElement?

a) getTextContent()

b) getValue()

c) getText()

d) retrieveText()


Answer: c) getText()


To determine if a WebElement is currently displayed on the web page, which method should be used?

a) isDisplayed()

b) isVisible()

c) isPresent()

d) isEnabled()


Answer: a) isDisplayed()


Which method checks if a WebElement is enabled?

a) isDisplayed()

b) isClickable()

c) isActive()

d) isEnabled()


Answer: d) isEnabled()


To verify if a WebElement is selected, such as in the case of a checkbox or radio button, which method is used?

a) isChecked()

b) isSelected()

c) isMarked()

d) isToggled()


Answer: b) isSelected()


Which method retrieves the value of a specified attribute of a WebElement?

a) getAttributeValue()

b) fetchAttribute()

c) getAttribute()

d) retrieveAttribute()


Answer: c) getAttribute()


What does the getTagName() method return?

a) The text of an element

b) The name of the WebElement

c) The tag name of the WebElement

d) The attribute of an element


Answer: c) The tag name of the WebElement


Which method is used to submit a form using a WebElement?

a) submit()

b) send()

c) formSubmit()

d) sendForm()


Answer: a) submit()


If you want to get the CSS value of a particular property of a WebElement, which method would you use?

a) getCssValue()

b) getStyle()

c) getCss()

d) fetchCssValue()


Answer: a) getCssValue()


To find a child element within a parent WebElement, which method should you use?

a) findChildElement(By locator)

b) findElement(By locator)

c) findElementWithin(By locator)

d) locateElement(By locator)


Answer: b) findElement(By locator)


Which method is used to find multiple WebElements on a page that match a given criteria?

a) findAllElements(By locator)

b) getElements(By locator)

c) findElements(By locator)

d) locateElements(By locator)


Answer: c) findElements(By locator)


What is the return type of the findElements(By locator) method?

a) WebElement

b) List<WebElement>

c) Set<WebElement>

d) Array<WebElement>


Answer: b) List<WebElement>


To get the dimensions and position of a WebElement on the web page, which method is used?

a) getLocation()

b) getSizeAndLocation()

c) getRect()

d) getDimensions()


Answer: c) getRect()


Which method retrieves the size (width and height) of a WebElement?

a) getSize()

b) getDimension()

c) getBoundingBox()

d) getArea()


Answer: a) getSize()


Which WebElement method helps to get the X and Y coordinates of an element on the page?

a) getPosition()

b) getLocation()

c) getCoordinates()

d) getXY()


Answer: b) getLocation()


What does the isDisplayed() method return if a WebElement is hidden using CSS?

a) true

b) false

c) null

d) An exception is thrown


Answer: b) false


Selenium webdriver methods MCQ

develop MCQ on Selenium webdriver methods?

1. Which WebDriver method is used to open a specific URL in the browser?  

A. `openURL()`

B. `navigateTo()`

C. `get()`

D. `load()`


Ans.C. get()


2. What WebDriver method is used to locate an element using its ID attribute?

   

A. `findElementById()`

B. `getElementById()`

C. `findElement(By.id())`

D. `locateById()`


C. findElement(By.id())


3. Which WebDriver method is used to click on a web element? 

  

A. `clickElement()

B. `performClick()

C. `click()

D. `elementClick()


Ans.C. `click()


4. Which WebDriver method is used to retrieve the current URL of the browser?

 

  

A. `getCurrentURL()`

B. `fetchURL()`

C. `getURL()`

D. `retrieveURL()`


ans .A. `getCurrentURL()`


If you want to navigate back to the previous page in the browser history, which method should you use?

a) driver.back()

b) driver.navigate().back()

c) driver.navigateBack()

d) driver.goBack()


Answer: b) driver.navigate().back()


6. Which WebDriver method is used to submit a form?

 

  

A. `submitForm()`

B. `submit()`

C. `formSubmit()`

D. `sendForm()`


ans. B. submit()


8. Which WebDriver method is used to close the current browser window?

 

  

A. `closeWindow()`

B. `quit()`

C. `exitBrowser()`

D. `close()


D. close()




10. Which WebDriver method is used to get the title of the current page?

 

  

A. `title()`

B. `getPageTitle()`

C. `getCurrentPageTitle()`

D. `getTitle()`


Answers:D. getTitle()



What method is used to refresh the current page in Selenium WebDriver?


a) driver.refresh()

b) driver.navigate().refresh()

c) driver.reloadPage()

d) driver.reload()

Answer: b) driver.navigate().refresh()


What method is used to go to the next page in Selenium WebDriver?


a) driver.refresh()

b) driver.navigate().refresh()

c) driver.reloadPage()

d) driver.navigate().forward()

Answer: d) driver.navigate().forward()


What method is used to maximize the browser window in Selenium WebDriver?


a) driver.window().maximize()

b) driver.manage().maximizeWindow()

c) driver.manage().window().maximize()

d) driver.maximize()

Answer: c) driver.manage().window().maximize()


Relative Path for Drivers File in Selenium MCQ

 MCQs on Relative Path for Drivers File in Selenium

What is a relative path in the context of Selenium WebDriver? 

a) A path that starts from the root directory

b) A path that is relative to the current working directory of the project

c) A path that starts from the home directory of the user

d) A path that includes the full directory structure from the root


Answer: b) A path that is relative to the current working directory of the project


Which of the following is an example of a relative path to a driver file? 

a) C:/drivers/chromedriver.exe

b) /usr/local/bin/chromedriver

c) drivers/chromedriver.exe

d) D:/selenium/drivers/chromedriver.exe


Answer: c) drivers/chromedriver.exe


Why is using a relative path for the WebDriver executable advantageous? 

a) It makes the script platform-dependent

b) It makes the script easier to share and run on different machines without modification

c) It reduces the execution time of tests

d) It provides a direct link to the WebDriver executable


Answer: b) It makes the script easier to share and run on different machines without modification


How would you specify a relative path to the ChromeDriver in Selenium? 

a) System.setProperty("webdriver.chrome.driver", "C:\\drivers\\chromedriver.exe");

b) System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe");

c) System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");

d) System.setProperty("webdriver.chrome.driver", "D:\\selenium\\drivers\\chromedriver.exe");


Answer: b) System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe");


In Selenium, which symbol represents the current working directory when using a relative path? 

a) /

b) \

c) .

d) ..


Answer: c) .


If your WebDriver executables are stored in a folder named webdrivers within your project directory, how would you set the path for geckodriver in Selenium? 

a) System.setProperty("webdriver.gecko.driver", "C:/webdrivers/geckodriver.exe");

b) System.setProperty("webdriver.gecko.driver", "../webdrivers/geckodriver.exe");

c) System.setProperty("webdriver.gecko.driver", "./webdrivers/geckodriver.exe");

d) System.setProperty("webdriver.gecko.driver", "webdrivers/geckodriver.exe");


Answer: c) System.setProperty("webdriver.gecko.driver", "./webdrivers/geckodriver.exe");


What does the .. symbol represent in a relative path? 

a) The root directory

b) The home directory

c) The parent directory

d) The current directory


Answer: c) The parent directory


Which of the following correctly sets the relative path for the EdgeDriver executable in Selenium? 

a) System.setProperty("webdriver.edge.driver", "D:\\drivers\\msedgedriver.exe");

b) System.setProperty("webdriver.edge.driver", "./drivers/msedgedriver.exe");

c) System.setProperty("webdriver.edge.driver", "/drivers/msedgedriver.exe");

d) System.setProperty("webdriver.edge.driver", "C:/selenium/msedgedriver.exe");


Answer: b) System.setProperty("webdriver.edge.driver", "./drivers/msedgedriver.exe");


When using a relative path for WebDriver executables, what could cause a "File not found" exception? 

a) The WebDriver executable is corrupted

b) The path to the WebDriver executable is incorrect or the file is missing

c) The WebDriver version is incompatible with the browser

d) The WebDriver executable is not set in system properties


Answer: b) The path to the WebDriver executable is incorrect or the file is missing


What does ./drivers/chromedriver.exe signify in a Selenium project setup? 

a) The chromedriver.exe file is located in the root directory

b) The chromedriver.exe file is located in a subdirectory named drivers of the current project directory

c) The chromedriver.exe file is located two levels up from the current directory

d) The chromedriver.exe file is located in the system's drivers directory


Answer: b) The chromedriver.exe file is located in a subdirectory named drivers of the current project directory


If a project is moved from one computer to another, which path type is recommended for WebDriver executables to avoid path issues? 

a) Absolute path

b) Relative path

c) Network path

d) URL path

Answer: b) Relative path



In Java-based Selenium tests, why might a developer prefer ./drivers/chromedriver over C:/selenium/drivers/chromedriver? 

a) For clarity and simplicity in code

b) To ensure the script works on any machine regardless of directory structure

c) Because absolute paths are faster to resolve

d) To make the script dependent on the specific machine setup

Answer: b) To ensure the script works on any machine regardless of directory structure


How can relative paths improve collaboration in a team working on Selenium tests? 

a) By making each team member set their own paths

b) By making scripts portable across different environments without modification

c) By enforcing the use of default WebDriver locations

d) By reducing the codebase size

Answer: b) By making scripts portable across different environments without modification




To execute tests on different browsers using WebDriver, which path is generally considered best practice for locating drivers? 

a) Hard-coded absolute path

b) Relative path within the project directory

c) Path to system-wide installed drivers

d) Network path to shared drivers

Answer: b) Relative path within the project directory



Which symbol is used to denote the root of the current project directory in relative paths? 

a) ~

b) .

c) /

d) *

Answer: b) .

Handling different browsers (Chrome, Edge, Firefox, and IE) using Selenium Java MCQ

 Here are multiple-choice questions (MCQs) focused on important classes in Selenium and handling different browsers (Chrome, Edge, Firefox, and IE) using Selenium Java:


MCQs on Important Classes in Selenium and Browser Handling


Which class is used to manage the Chrome browser in Selenium WebDriver? 

a) ChromeManager

b) ChromeBrowser

c) ChromeDriver

d) ChromeController


Answer: c) ChromeDriver


What is the purpose of the WebDriver interface in Selenium? 

a) To perform actions on the browser

b) To interact with the HTML DOM of a webpage

c) To handle cookies in the browser

d) To manage test data


Answer: a) To perform actions on the browser



Handling Chrome, Edge, Firefox, and IE Browsers MCQ


To handle Chrome browser in Selenium, which of the following WebDriver classes is used? 

a) WebDriver

b) ChromeDriver

c) ChromeWebDriver

d) WebDriver.Chrome

Answer: b) ChromeDriver


What is the default path for the ChromeDriver executable that Selenium WebDriver looks for? 

a) C:\Program Files\ChromeDriver\

b) C:\WebDriver\chromedriver.exe

c) It does not have a default path; it must be set explicitly

d) /usr/bin/chromedriver

Answer: c) It does not have a default path; it must be set explicitly


Which of the following classes is used to handle the Firefox browser in Selenium WebDriver? 

a) FirefoxBrowser

b) FirefoxDriver

c) WebDriver.Firefox

d) MozillaDriver

Answer: b) FirefoxDriver




Which WebDriver class is used to automate Microsoft Edge browser? 

a) EdgeWebDriver

b) EdgeDriver

c) WebDriver.Edge

d) MicrosoftEdgeDriver

Answer: b) EdgeDriver


What is the necessary condition to run tests on the Edge browser using Selenium WebDriver? 

a) Edge browser must be installed and path set in PATH

b) Only EdgeDriver must be downloaded

c) Both EdgeDriver and Edge browser must be installed

d) Use of Internet Explorer driver executable

Answer: c) Both EdgeDriver and Edge browser must be installed


Which class is used to automate Internet Explorer (IE) using Selenium WebDriver? 

a) ExplorerDriver

b) InternetExplorerDriver

c) IEDriver

d) MicrosoftDriver

Answer: b) InternetExplorerDriver


To run Selenium WebDriver tests on Firefox, which driver executable must be downloaded? 

a) chromedriver.exe

b) iedriver.exe

c) geckodriver.exe

d) edgedriver.exe

Answer: c) geckodriver.exe



MCQs on Opening Chrome, Edge, Firefox, and Safari Browsers Using Selenium

Which Selenium WebDriver class is used to open the Chrome browser? 

a) ChromeWebDriver

b) ChromeDriver

c) WebDriver.Chrome

d) GoogleDriver


Answer: b) ChromeDriver


To open the Firefox browser using Selenium WebDriver, which class should be instantiated? 

a) FirefoxWebDriver

b) GeckoDriver

c) FirefoxDriver

d) MozillaDriver


Answer: c) FirefoxDriver


What is the executable file required to run tests on the Chrome browser using Selenium WebDriver?

 a) chromedriver.exe

b) geckodriver.exe

c) edgedriver.exe

d) safaridriver


Answer: a) chromedriver.exe


Which driver must be downloaded to run Selenium WebDriver tests on Microsoft Edge browser? 

a) edgedriver.exe

b) microsoftedgedriver.exe

c) safaridriver

d) chromedriver.exe


Answer: a) edgedriver.exe


When running Selenium WebDriver on Firefox, what is the name of the driver executable needed? 

a) chromedriver.exe

b) geckodriver.exe

c) firefoxdriver.exe

d) edgedriver.exe


Answer: b) geckodriver.exe


How do you start a Chrome browser instance using Selenium WebDriver in Java?

 a) WebDriver driver = new ChromeWebDriver();

b) WebDriver driver = new ChromeDriver();

c) WebDriver driver = new Chrome();

d) WebDriver driver = new WebDriver.Chrome();


Answer: b) WebDriver driver = new ChromeDriver();



To open Safari browser using Selenium WebDriver, which class is used? 

a) SafariDriver

b) WebDriver.Safari

c) SafariBrowser

d) AppleDriver


Answer: a) SafariDriver




What is the correct syntax to initialize the Firefox browser with Selenium WebDriver?

a) WebDriver driver = new WebDriver.Firefox();

b) WebDriver driver = new FirefoxWebDriver();

c) WebDriver driver = new FirefoxDriver();

d) WebDriver driver = new GeckoDriver();


Answer: c) WebDriver driver = new FirefoxDriver();


Before running Selenium tests on Chrome, which system property must be set in Java? 

a) System.setProperty("webdriver.chrome.driver", "path/to/chromedriver.exe");

b) System.setProperty("webdriver.chrome", "path/to/chromedriver.exe");

c) System.setProperty("chrome.driver", "path/to/chromedriver.exe");

d) System.setProperty("webdriver.chrome.executable", "path/to/chromedriver.exe");


Answer: a) System.setProperty("webdriver.chrome.driver", "path/to/chromedriver.exe");



How do you set the system property for Edge browser before running a test? 

a) System.setProperty("webdriver.edge.driver", "path/to/edgedriver.exe");

b) System.setProperty("webdriver.msedge.driver", "path/to/edgedriver.exe");

c) System.setProperty("webdriver.microsoftedge.driver", "path/to/edgedriver.exe");

d) System.setProperty("edge.driver", "path/to/edgedriver.exe");


Answer: a) System.setProperty("webdriver.edge.driver", "path/to/edgedriver.exe");


Which WebDriver command is used to maximize the browser window? 

a) driver.maximize();

b) driver.manage().window().maximize();

c) driver.window().maximize();

d) driver.manage().maximize();

Answer: b) driver.manage().window().maximize();


For Selenium WebDriver to control Firefox, which version of GeckoDriver is required? 

a) The latest version matching the Firefox version

b) Only version 0.23.0

c) Version 1.0 or above

d) Version 0.9 or below

Answer: a) The latest version matching the Firefox version


Which of the following is not required when setting up Selenium WebDriver for Edge browser automation? 

a) Edge browser installed on the system

b) EdgeDriver executable

c) Installing GeckoDriver

d) Selenium WebDriver library

Answer: c) Installing GeckoDriver


What is the command to initialize WebDriver for Safari in Selenium? 

a) WebDriver driver = new WebDriver.Safari();

b) WebDriver driver = new SafariWebDriver();

c) WebDriver driver = new SafariDriver();

d) WebDriver driver = new WebKitDriver();

Answer: c) WebDriver driver = new SafariDriver();


How do you add the path to chromedriver in a Selenium test? 

a) Using the method setDriverPath()

b) Using System.setProperty()

c) Setting a Chrome option

d) By specifying in the capabilities

Answer: b) Using System.setProperty()



Introduction to Selenium MCQ

 Here are some multiple-choice questions (MCQs) on the introduction to Selenium:


1. What is Selenium?

a) A programming language

b) A web browser

c) An automation testing tool for web applications

d) A database management system


Answer: c) An automation testing tool for web applications


2. Which of the following is NOT a component of Selenium?

a) Selenium WebDriver

b) Selenium IDE

c) Selenium Grid

d) Selenium Server


Answer: d) Selenium Server


3. Selenium primarily supports automation of which type of applications?

a) Desktop applications

b) Web applications

c) Mobile applications

d) Database applications


Answer: b) Web applications


4. Which programming language is NOT supported by Selenium?

a) Java

b) Python

c) C++

d) Ruby


Answer: c) C++


5. Which Selenium component is a record-and-playback tool?

a) Selenium WebDriver

b) Selenium Grid

c) Selenium IDE

d) Selenium RC


Answer: c) Selenium IDE


6. What is the purpose of Selenium Grid?

a) To record user interactions with a browser

b) To automate mobile application testing

c) To distribute tests across multiple machines and browsers

d) To create advanced test scripts using programming languages


Answer: c) To distribute tests across multiple machines and browsers


7. Which of the following browsers is NOT supported by Selenium WebDriver?

a) Google Chrome

b) Mozilla Firefox

c) Safari

d) Internet Explorer

e) Opera


Answer: e) Opera


8. Who developed Selenium?

a) Facebook

b) Google

c) ThoughtWorks

d) Microsoft


Answer: c) ThoughtWorks


9. Which Selenium component was deprecated and is no longer used in the latest versions?

a) Selenium Grid

b) Selenium RC

c) Selenium IDE

d) Selenium WebDriver


Answer: b) Selenium RC


10. What is the main advantage of using Selenium WebDriver over Selenium IDE?

a) Easier to use

b) Supports multiple browsers

c) Supports multiple programming languages

d) Allows running tests on remote machines


Answer: c) Supports multiple programming languages




Automation Testing Tools

Which of the following is an automation testing tool for web applications?

a) JUnit

b) Selenium

c) MySQL

d) Apache JMeter


Answer: b) Selenium


Which automation tool is best suited for load testing?

a) Selenium

b) QTP (UFT)

c) Apache JMeter

d) TestNG


Answer: c) Apache JMeter


Which of the following automation testing tools supports both web and mobile application testing?

a) Selenium

b) Appium

c) LoadRunner

d) Jenkins


Answer: b) Appium


Which tool is known for its record-and-playback feature in test automation?

a) Selenium WebDriver

b) QTP (UFT)

c) TestNG

d) JUnit


Answer: b) QTP (UFT)



What is one of the main advantages of Selenium over other automation testing tools?

a) It supports only one programming language

b) It is a paid tool

c) It supports multiple browsers and operating systems

d) It requires minimal configuration


Answer: c) It supports multiple browsers and operating systems


Which feature makes Selenium highly popular among developers and testers?

a) It's an open-source tool

b) It requires high licensing costs

c) It only supports Chrome browser

d) It can only be used on Windows OS


Answer: a) It's an open-source tool


Selenium WebDriver supports testing on which type of applications?

a) Desktop applications

b) Web applications

c) Mobile applications

d) Database applications


Answer: b) Web applications


What all OS, Browsers, and Programming Languages does Selenium Support?

Which operating system is NOT supported by Selenium?

a) Windows

b) Linux

c) macOS

d) Android OS


Answer: d) Android OS


Which browsers are supported by Selenium WebDriver?

a) Google Chrome, Mozilla Firefox, Safari, Internet Explorer

b) Google Chrome, Opera, Safari, Microsoft Edge

c) Mozilla Firefox, Internet Explorer, Safari, Opera

d) Google Chrome, Mozilla Firefox, Opera Mini


Answer: a) Google Chrome, Mozilla Firefox, Safari, Internet Explorer


Which of the following programming languages is NOT supported by Selenium WebDriver?

a) Java

b) Python

c) Ruby

d) Swift


Answer: d) Swift



Which of the following is a disadvantage of Selenium?

a) It supports mobile testing

b) It requires a commercial license

c) It does not support testing of desktop applications

d) It only works with Chrome browser

Answer: c) It does not support testing of desktop applications



Selenium WebDriver lacks built-in support for which type of testing?

a) Regression testing

b) Performance testing

c) Functional testing

d) UI testing

Answer: b) Performance testing


Why might Selenium not be suitable for testing a Visual GUI?

a) It is a paid tool

b) It lacks support for image-based testing

c) It only supports Internet Explorer

d) It requires a specific operating system

Answer: b) It lacks support for image-based testing


Which of the following is a challenge when using Selenium for automation testing?

a) Easy integration with other tools

b) Limited technical support

c) High licensing costs

d) Supports only Windows operating system

Answer: b) Limited technical support

git commands MCQ

 Here are some multiple-choice questions (MCQs) on Git commands relevant for Selenium: 1. Which Git command is used to clone a remote reposi...