Q.1 Which of the following correctly defines a timeout test in TestNG?
A. The time duration for a test to complete execution
B. The time duration for a test suite to complete execution
C. The time duration for a test group to complete execution
D. None of the options
Ans : The time duration for a test to complete execution
Q.2 The TestNG framework enables to generate test reports in both HTML and XML formats.
A. True
B. False
Ans : True
Q.3 TestNG has a more elegant way of handling parameterized tests, by using the data-provider concept.
A. True
B. False
Ans : True
Q.4 Using @DataProvider annotation, the same test method can be run multiple times with different datasets.
A. True
B. False
Ans : True
Q.5 Which of the following is not a valid TestNG annotation?
A. @DataSource
B. @BeforeSuite
C. @DataProvider
D. @AfterSuite
Ans : @DataSource
Q.6 Which of these is not a valid setUp / tearDown level in the TestNG framework?
A. @Before/AfterClass
B. @Before/AfterSuite
C. @Before/AfterTest
D. @Before/AfterGroup
E. All the above
Ans : All the above
Q.7 What is the correct TestNG annotation for a timeout test?
A. @Test(sleep = 5000)
B. @test(sleep = 5000)
C. @Test(TimeOut = 5000)
D. @Test(timeOut = 5000)
Ans : @Test(timeOut = 5000)
Q.8 What is the correct method to exclude a test in TestNG?
A. Using @Test(enabled = false) annotation
B. Using @Test(exclude = true) annotation
C. Using @Test(include = false) annotation
D. None of the options
Ans : Using @Test(enabled = false) annotation
Q.9 Which of the following is false in the context of a TestNG framework?
A. TestNG permits to define dependent test cases. Each test case is independent of other test cases
B. TestNG need not extend any class, while JUnit must
C. The @DataProvider annotation accepts single string attributes, and returns an array of objects
D. None of the options
Ans : None of the options
Q.10 What is the method used to select a value from Listbox?
A. selectByVisibleText(String)
B. selectByIndex(int)
C. selectByValue(String)
D. All the options
Ans : All the options
Q.11 Which of the following is not a ‘wait’ command?
A. waitForTitle
B. waitForAlert
C. waitForActive
D. waitForTextPresent
Ans : waitForActive
Q.12 @test, @Beforeclass, @Afterclass, @Beforemethod, @Aftermethod are basic annotations in TestNG.
A. True
B. False
Ans : False
Q.13 A Hybrid Framework must contain all Selenium concepts.
A. True
B. False
Ans : False
Q.14 ResultSet helps to store data retrieved from a database.
A. True
B. False
Ans : True
Q.15 A JDBC connection helps to connect with a database.
A. True
B. False
Ans : True
Q.16 Which of the following is not unidirectional?
A. select
B. update
C. Insert
D. delete
Ans : select
Q.17 What is the method used to change focus from a frame/iframe/window/alert?
A. changeFocus()
B. setFocus()
C. switchTo()
D. redirectTo()
Ans : switchTo()
Q.18 Data-driven testing can be implemented by using which of the following?
A. EXCEL
B. JSON
C. JSON
D. All the options
Ans : All the options
Q.19 Table-driven testing is also known as?
A. Data-driven Testing Framework
B. Keyword-driven Testing
C. Hybrid Testing Framework
D. Modular Testing Framework
Ans : Keyword-driven Testing
Q.20 Which of the following is the recommended method to handle dynamic elements?
A. Using CSS locators
B. Using regular expressionsU
C. Using relative Xpath locators
D. All the options
Ans : Using relative Xpath locators
Q.21 A BDD Framework can be used with Selenium.
A. True
B. False
Ans : True
Q.22 TestNG covers all testing categories, including unit, functional, end-to-end, integration, and so on.
A. True
B. False
Ans : True
Q.23 What does the getWindowHandle() method do?
A. Handles alerts
B. Gets the handle of the page the Webdriver is currently controlling
C. Helps to get the handle of the parent window
D. None of the options
Ans : Gets the handle of the page the Webdriver is currently controlling
Q.24 Which of the following is not a valid setUp/tearDown level in TestNG framework?
A. @Before/AfterGroup
B. @Before/AfterSuite
C. @Before/AfterTest
D. @Before/AfterClass
Ans : @Before/AfterClass
Q.25 What is the return type of the driver.getTitle() method in Selenium Webdriver?
A. void
B. character
C. null
D. string
Ans : string
Q.26 Which of the following features are not supported by TestNG?
A. Support for parameters
B. Support for powerful execution model
C. Support for dependent methods testing
D. None of the options
Ans : Support for powerful execution model
Q.27 Which of the following WebDriver is used for Headless browser testing?
A. InternetExplorerDriver
B. FireFoxDriver
C. HeadLessDriver
D. HtmlUnitWebDriver
Ans : HtmlUnitWebDriver
Q.28 Which Maven plugin creates a project structure?
A. execution
B. properties
C. archetype
D. dependency
Ans : archetype
Q.29 JUnits can be run as part of a Jenkins job.
A. True
B. False
Ans : True
Q.30 Hard Assert tests fail and stop executing the moment a failure occurs in the assertion.
A. True
B. False
Ans : True
Q.31 Parallel execution of Selenium test cases is possible in TestNG.
A. True
B. False
Ans : True
Q.32 How can we check if a check-box is selected or not?
A. driver.findElement(By.id(<>).isSelected()
B. driver.findElement(By.id(<>).isChecked()
C. driver.findElement(By.id(<>).Selected()
D. All the options
Ans : driver.findElement(By.id(<>).isSelected()
Q.33 What is contextClick() used for?
A. To left-click
B. To right-click
C. To click a hidden element
D. To open the pop-up menu
Ans : To right-click