MCQs > IT & Programming > Selenium Automation MCQs > Basic Selenium Automation MCQs

Basic Selenium Automation MCQ

1. Which two of the following Selenium functions never throw an exception?

Answer

Correct Answer: runScript (script)
El storeAlertPresent (variableName)
storeConfirmationPresent (variableName)
captureEntirePageScreenshot (f‌ilename.kwargs)

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

2. Which of the following methods are available on the interface of the LodableComponent class?

Answer

Correct Answer: geto
isLoaded
load()
texto

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

3. Which two of the following location strategies can be used if you want to locate an element with respect to another element on a page?

Answer

Correct Answer: Element‘s lD
XPath statement

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

4. Which two of the following commands can be used if you want to verify the presence Of an image on a web page?

Answer

Correct Answer: verinylementPresent
assertElementPrese

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

5. The clear() method of WebElement interface works on which of the following type of elements?

Answer

Correct Answer: textbox
text area

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

6. Suppose you are using the record feature of Selenium IDE and you want to check the properties of a web page. Which of the following commands will be used to do so?

Answer

Correct Answer: assert
verify

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

7. What is the default port used by hub for listening to new requests in Selenium-Grid?

Answer

Correct Answer: 4444

Note: This Question is unanswered, help us to find answer for this one

8. TestNG doesn't make it mandatory to declare @BeforeClass and @AfterClass, which is present in JUnit. Is it true or false?

Answer

Correct Answer: TRUE

Note: This Question is unanswered, help us to find answer for this one

9. Which of the following statements is false in the context of TestNG framework?

Answer

Correct Answer: TestNG permits to define the dependent test cases. Each test case is independent of other test Cases.

Note: This Question is unanswered, help us to find answer for this one

10. Which of the following Options will select all the table elements irrespective of their position in the document?

Answer

Correct Answer: //table

Note: This Question is unanswered, help us to find answer for this one

11. Which of the following syntax would you use to locate an element using inner text?

Answer

Correct Answer: css=tagzcontains(“inner text")

Note: This Question is unanswered, help us to find answer for this one

12.

What are the types of exceptions thrown in web driver?

1.ElementNotSelectabIeException

2.8taleElementReferenceException

3.NoElementFoundException

4.NoSuchE|ementException

5.ElementNotVisibleException


Answer

Correct Answer:

All of the Above


Note: This Question is unanswered, help us to find answer for this one

13.

The user is trying to Capture An Element Loading After The Page Load , And have written the Following

Lines of Codes. Will the Code Execute

public void waitForElementPresent(String element, int timeout) throws Exception

{

for (int second = 0 ;; second++)

{

if (second >= timeout)

fail("Timeout.Unable to find the Specified e1ement"+element);

try

{

if (selenium.isElementPresent(element)) break;

}

catch (Exception e) { }

Thread.sleep(1986);

}

}


Answer

Correct Answer:

YES 


Note: This Question is unanswered, help us to find answer for this one

14. The following command is used to add Selenium to which type of programming environment? gem install selenium-webdriver

Answer

Correct Answer: Ruby

Note: This Question is unanswered, help us to find answer for this one

15. Which of the following commands should be run from a command-line for adding Selenium to your Python environment?

Answer

Correct Answer: pip install selenium

Note: This Question is unanswered, help us to find answer for this one

16. Which Of the following is the correct Java syntax for wrapping up the click on a page element and wait for page to load calls in a wrapper function in Selenium?

Answer

Correct Answer: public void clickAndWait(String elementLocator, String waitPeriod) [ selenium.click(elementLocator); selenium.waitForPageToLoad(waitPeriod); ]

Note: This Question is unanswered, help us to find answer for this one

17. Which of the following statement describes the most appropriate way to delete the cookies?

Answer

Correct Answer:

We can delete cookies in 3 ways.
driver.manage().deIeteCookieNamed("CookieName");
driver.manage().deleteCookie(Cookield);
driver.manage().deleteAl|Cookies();   


Note: This Question is unanswered, help us to find answer for this one

18. Which of the following is the correct syntax of CSS partial match that will use the "checkName" part in the middle of the ID of an element "abc_checkName_xyz" to match and find the element in Selenium?

Answer

Correct Answer: input[id'='checkName']

Note: This Question is unanswered, help us to find answer for this one

19. Which of the following is a valid select statement in Webdriver that selects a value from a drop down element?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

20. Which Of the following exceptions occurs when an element is present in the DOM but interactions with that element will hit another element?

Answer

Correct Answer: ElementNotlnteractableException

Note: This Question is unanswered, help us to find answer for this one

21. Which Of the following Selenium commands should be run on command prompt for adding Internet Explorer Selenium Remote Controls to our Grid on Windows Operating System target?

Answer

Correct Answer: java -jar selenium-server-standalone.jar -ro|e node -hub http://Iocalhost:4444lgrid/register -browser browserName="internet explorer", maxlnstances=1, platform=WlNDOWS

Note: This Question is unanswered, help us to find answer for this one

22. While working on Selenium using Java. which of the following commands should be used for starting the test server using the ~userExtensions argument and passing in your example-extension.js file?

Answer

Correct Answer: java -jar selenium-server.jar -userExtensions example-extensions.js

Note: This Question is unanswered, help us to find answer for this one

23. Which of the following Selenium commands is used for retrieving the messages of JavaScript question prompt dialog generated during the previous action?

Answer

Correct Answer: storePrompt(variableName)

Note: This Question is unanswered, help us to find answer for this one

24. Is it possible to enable JavaScript in HTMLUnitDriver during driver initialization? If yes, then how?

Answer

Correct Answer: Yes , HtmlUnitDriver driver = new HtmlUnitDriver(true);

Note: This Question is unanswered, help us to find answer for this one

25. What will happen if you add an empty command and an empty comment in your test script in Selenium IDE?

Answer

Correct Answer: The empty command will cause an error during execution, whereas empty comment will be ignored and will not throw any error.

Note: This Question is unanswered, help us to find answer for this one

26. Which of the following statements is/are correct about Ul mapping in Selenium?

Answer

Correct Answer: Both options b and c are correct.

Note: This Question is unanswered, help us to find answer for this one

27.

Carefully analyze the following anchor tag that def‌ines a static button present in your web page and answer the question that follows it.
<a class="button" id="myTestForm" onclick="return oamSubmitForm(’ myTestForm', 'myTestForm:__lD38');" href="#">View Archived Allocation Events<la>
Which of the following Selenium commands can be used in order to click the button defined above using a test script?

Answer

Correct Answer:

click myTestForm


Note: This Question is unanswered, help us to find answer for this one

28. Which Of the following Selenium commands is used for returning the text from a specif‌ied cell in a table?

Answer

Correct Answer: storeTabIe

Note: This Question is unanswered, help us to find answer for this one

29. Which of the following Selenium actions simulates a user moving the mouse pointer away from a specified element?

Answer

Correct Answer: mouseOut (locator)

Note: This Question is unanswered, help us to find answer for this one

30. Which of the following methods can be used to check whether or not an element supports multi- selection?

Answer

Correct Answer: assertFalse(make.isMuItipIeO);

Note: This Question is unanswered, help us to find answer for this one

31. Which of the following code can be used to create excel automation object using POI excel API?

Answer

Correct Answer: File excelobj = new File 0;

Note: This Question is unanswered, help us to find answer for this one

32. Which of the following Selenium actions simulates a user who pressed a key and hasn't released it yet?

Answer

Correct Answer: keyDown

Note: This Question is unanswered, help us to find answer for this one

33. Suppose while recording test cases in Selenium IDE, you entered some values in a textbox. Which of the following commands must have been used to do so?

Answer

Correct Answer: insert

Note: This Question is unanswered, help us to find answer for this one

34.

What does the following Selenium function do?

storeBOdyText ( variabIeName)


Answer

Correct Answer:

It returns the entire text of the page.


Note: This Question is unanswered, help us to find answer for this one

35.

What is the difference between the following methods of the seleniumwebdriver.common.action_chains.ActionChains class?

A) sen d_keys(keys_to_send)

B) send_keys_to_element(element, keys_to_send)


Answer

Correct Answer:

A sends keys to currently focused element whereas B sends keys to the target element.


Note: This Question is unanswered, help us to find answer for this one

36. Which of the following correctly describes the difference between Thread.Sleep() and Selenium.setSpeed()?

Answer

Correct Answer: SeleniumsetSpeedO - Runs each command after setSpeed delay by the number of milliseconds specif‌ied in setSpeedO. Thread.Sleep() - Waits for only once at the command given at sleep.

Note: This Question is unanswered, help us to find answer for this one

37.

Which of the following Java commands is used for navigating to a webpage, say, http://wwwvabccom, using WebDriver?



Answer

Correct Answer:

driver.get("http:l/www.abc.com");    


Note: This Question is unanswered, help us to find answer for this one

38.

Consider the following HTML:
<div class="container‘">
(div class="title" >
</div> </div>
(div class="container‘ title")
</div>
Using Selenium WebDriver. how would you select only the element with the 2 classes: ‘container' and 'title’? Select all the correct answers.

Answer

Correct Answer:

By.xpath("div[contains(@class. 'container title')");.By.xpath(“//div[contains(@class. 'container') and
contains(@class. 'title‘)]");.


Note: This Question is unanswered, help us to find answer for this one

39. Which Of the following commands is a Selenium accessors command?

Answer

Correct Answer: storeTitIe

Note: This Question is unanswered, help us to find answer for this one

40. Which is not a valid setUp/tearDown level in TestNG framework?

Answer

Correct Answer: @Before/AfterClass

Note: This Question is unanswered, help us to find answer for this one

41. Which Of the following Selenium commands can print a specif‌ied message into the third table cell Of your Selenese table and is also useful for debugging?

Answer

Correct Answer: echo (message)

Note: This Question is unanswered, help us to find answer for this one

42.

Select the Correct Navigation Commands ?

1) navigate0.back0

Sample code:

driver.navigate0.back();

2) navigate0.fon~ard0

Sample code:

driver.navigate0.fon~ard();

3) navigate0.refresh()

Sample code:

drivennavigate0.refresh0;

4) navigateOtoO

Sample code:

driver.navigateO.to("https://goog|e.com");


Answer

Correct Answer:

All of the Above


Note: This Question is unanswered, help us to find answer for this one

43.

Which of the following is a valid difference between and commands?

1.command checks whether an element is on the page or not and stops the test on failure whereas command carries on executing the tests.

2. command checks the visibility of element whereas command tests the condition for true or false.


Answer

Correct Answer:

1


Note: This Question is unanswered, help us to find answer for this one

44. Which ofthe following methods makes an expectation for checking that an element, known to be present on the DOM of a page, is visible?

Answer

Correct Answer: selenium.webdriver.support.expected_conditions.visibility_of(element)

Note: This Question is unanswered, help us to find answer for this one

45.

Select the Correct navigation methods of WebDriver?

1. goto()

2. moveto()

3. forward()

4. back()

5. refresh()

Answer

Correct Answer:

3,4 & 5


Note: This Question is unanswered, help us to find answer for this one

46.

Carefully analyze the following element given in a WebDriver and answer the question that follows it.

Car
bus

Which of the following is the correct Java command that can be used for locating the above—given element by class name?


Answer

Correct Answer:

List vehicle = driver.f‌indElements(By.className("vehicle"));     


Note: This Question is unanswered, help us to find answer for this one

47. Which of the following is the correct Java syntax for retrieving the innerText value contained within an element?

Answer

Correct Answer: WebElement element = driver.findElement(By.id("elementlD")); eIement.getText();

Note: This Question is unanswered, help us to find answer for this one

48.

Which Of the following commands are automatically available when you add a getTextLengthO method?

0 storeTextLength

ii) assertNotTextLength

iii) assertValueRepeated

iv) verifyTextLength


Answer

Correct Answer:

Only options i). ii) and iv) 


Note: This Question is unanswered, help us to find answer for this one

49. ln Selenium, up to how many parameters can be passed to an action method?

Answer

Correct Answer: Two

Note: This Question is unanswered, help us to find answer for this one

50. Which Of the following is correct about tag and attribute name for HtmlUnit Driver?

Answer

Correct Answer: It should be lower-cased

Note: This Question is unanswered, help us to find answer for this one

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

Answer

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

Note: This Question is unanswered, help us to find answer for this one

52.

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.


Answer

Correct Answer:

Only options i), ii) and iii) 


Note: This Question is unanswered, help us to find answer for this one

53.

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.


Answer

Correct Answer:

http://abc:5555/extra/ 


Note: This Question is unanswered, help us to find answer for this one

54. Which of the following is the correct command that causes the Node to be spawned and a new servlet "org.abc.mydemo.AlINodes" to be added to the node?

Answer

Correct Answer: java -cp ”:. org.openqa.grid.selenium.GridLauncher -role node -hub http://localhost:4444 lgrid/register -servIets org.abc.mydemo.AllNodes

Note: This Question is unanswered, help us to find answer for this one

55. 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?

Answer

Correct Answer: assert

Note: This Question is unanswered, help us to find answer for this one

56. 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?

Answer

Correct Answer: getConf‌irmation

Note: This Question is unanswered, help us to find answer for this one

57. 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?

Answer

Correct Answer: drivenswitchToO.defaultContent

Note: This Question is unanswered, help us to find answer for this one

58. Which of the following Selenium methods defines whether an element is visible and enabled?

Answer

Correct Answer: elementToBeClickable(By locator)

Note: This Question is unanswered, help us to find answer for this one

59. 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 ?

Answer

Correct Answer: isSelect()

Note: This Question is unanswered, help us to find answer for this one

60.

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

1.dismiss()

2.accept0

3.ignore()

4.sendKeys(String stringToSend)

5.getText()


Answer

Correct Answer:

1,2,4 & s


Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: driver.switchTo().alert0.accept0;

Note: This Question is unanswered, help us to find answer for this one

62. Which of the following statements is incorrect?

Answer

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

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: switchTol)

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: Implicit Wait

Note: This Question is unanswered, help us to find answer for this one

65. How to import Selenium's TimeoutException in Python?

Answer

Correct Answer: from selenium.common.exceptions import TimeoutException

Note: This Question is unanswered, help us to find answer for this one

66.

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(By.id("id of the dropdown"))).perform();

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

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

subLinkOption.click();


Answer

Correct Answer:

TRUE


Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: Actions builder = new Actions(driver); builder.doubleClickfmessage).perform0;

Note: This Question is unanswered, help us to find answer for this one

68.

Choose True or False.

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


Answer

Correct Answer:

False 


Note: This Question is unanswered, help us to find answer for this one

69. The FluentWait class is implementation of which of the following Selenium WebDriver interfaces?

Answer

Correct Answer: Wait

Note: This Question is unanswered, help us to find answer for this one

70.

What does the below lines of code meant for?

WebDriver driver = new FirefoxDriverO;

Selenium selenium = new WebDriverBackedSelenium(driver,

"http://www.techbeamers.com/");


Answer

Correct Answer:

Will run Selenium 1.0 tests in webdriver. 


Note: This Question is unanswered, help us to find answer for this one

71. Which of the following drivers does/do NOT provide native XPath support?

Answer

Correct Answer: Internet Explorer Driver

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: verifyText

Note: This Question is unanswered, help us to find answer for this one

73. Using Selenium, how can we click on an element at certain coordinates?

Answer

Correct Answer: Using the Actions class‘ method moveToElement (element, xOffset, yOffset)

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: java ~jar selenium-server—standalone-2.44.0.jar -role node -h

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: java -jar selenium-server-standalone-2.44.0.jar -role hub -port 4441

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: contextClick

Note: This Question is unanswered, help us to find answer for this one

77. Which of the following is the correct method for initializing Page Factory in Selenium?

Answer

Correct Answer: PageFactory.initElements();

Note: This Question is unanswered, help us to find answer for this one

78. Which of the following combination of the WebDriver's sendKeysO is not correct?

Answer

Correct Answer: sendKeys(Keys.SPACE) = sendKeys(“\uEOOD”)

Note: This Question is unanswered, help us to find answer for this one

79. 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?

Answer

Correct Answer: Using element's ID

Note: This Question is unanswered, help us to find answer for this one

80. 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?

Answer

Correct Answer: new WebDriverWait(driver. 10).untiI(ExpectedCondtions.alertlsPresent0);

Note: This Question is unanswered, help us to find answer for this one

81. 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?

Answer

Correct Answer: driver.navigate().back();

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer:

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


Note: This Question is unanswered, help us to find answer for this one

83. How to wait until an element is no longer attached to the DOM?

Answer

Correct Answer: None

Note: This Question is unanswered, help us to find answer for this one

84.

Consider the element given below.

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


Answer

Correct Answer:

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


Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: selenium.webdriver.support.expected_conditions.title_contains(title)

Note: This Question is unanswered, help us to find answer for this one

86. Which two commands you can use to validate a button?

Answer

Correct Answer: VerinylementPresent and assertElementPresent

Note: This Question is unanswered, help us to find answer for this one

87. Which of the following WebDriver commands is used to check the presence of a web element?

Answer

Correct Answer: VerifyElementPresent

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: getWindowHandlesO returns handles of all the open browsers whereas getWindowHandleo gets the address of the current browser.

Note: This Question is unanswered, help us to find answer for this one

89. 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?

Answer

Correct Answer: java -jar selenium-server—standalone-2.44.0.jar -role hub

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: netstat -a

Note: This Question is unanswered, help us to find answer for this one

91. 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".

Answer

Correct Answer: FALSE

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: driver.switchT00.window("windowName");

Note: This Question is unanswered, help us to find answer for this one

93. How to select all Options that have a value matching the argument?

Answer

Correct Answer: call select_by_value(value)

Note: This Question is unanswered, help us to find answer for this one

94. 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?

Answer

Correct Answer: driver.manage0.timeoutso.implicitlyWait(15.TimeUnit.SECONDS);

Note: This Question is unanswered, help us to find answer for this one

95. 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?

Answer

Correct Answer: org.openqa.grid.web.servlet.RegistryBasedServlet

Note: This Question is unanswered, help us to find answer for this one

96. Method which selects the option which displays the text matching the parameter passed to it

Answer

Correct Answer: selectByVisibleText

Note: This Question is unanswered, help us to find answer for this one

97. 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?

Answer

Correct Answer: lldiv[contains(@id,‘time_')]

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: selenium.webdriver.support.e xpected_conditions.new_window_is_opened(current_handles)

Note: This Question is unanswered, help us to find answer for this one