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

6. 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

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

8.

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

9.

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

10. 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

11. 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

12. 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

13. 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

14.

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

15. 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

16. 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

17.

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

18.

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

19. 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

20.

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

21. 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

22. 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

23.

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

24.

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

25.

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

26.

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

27.

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

28. 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

29. 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

30.

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

31.

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

32. 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

33. 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

34. 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

35. 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

36. 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

37.

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

38. 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

39. 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

40. 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

41. 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

42.

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

43. 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

44.

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

45. 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

46. 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

47. 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

48. 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

49. 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

50. 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

51.

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

52. 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

53. 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

54. 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

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

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

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

58. 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

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

60. 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

61. 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