First Selenium Webdriver Script: JAVA Code Example ( Hard )

AwedExuberance avatar
AwedExuberance
·
·
Download

Start Quiz

Study Flashcards

30 Questions

Which package needs to be imported in order to use the Selenium WebDriver API?

org.openqa.selenium.WebDriver

What method is used to locate elements in WebDriver?

findElement()

Which method is used to navigate forward in WebDriver?

navigate().forward()

What type of exception should be caught when using explicit waits?

TimeoutException

What is the purpose of implicit waits in WebDriver?

To set the waiting time throughout the program

Which driver is currently being used in the code?

FirefoxDriver

What is the expected title of the Mercury Tours homepage?

Welcome: Mercury Tours

What is the actual title of the Mercury Tours homepage?

Welcome: Mercury Tours

What is the value of the 'baseUrl' variable?

What is the purpose of the 'get' method in the code?

To navigate to the base URL

Which method is used to extract the tag name of a specific element in Selenium Webdriver?

getTagName()

Which method is used to find elements based on the value of the 'class' attribute in Selenium Webdriver?

By.className()

Which method is used to locate elements by their tag name in Selenium Webdriver?

By.tagName()

Which method is used to simulate clicking on an element in Selenium Webdriver?

click()

Which method is used to fetch the title of the current page in Selenium Webdriver?

getTitle()

Which method should be used to close all windows, including pop-ups, in Selenium Webdriver?

quit()

Which method should be used to switch to a specific frame in Selenium Webdriver?

switchTo().frame()

Which method should be used to access the message of an alert box in Selenium Webdriver?

getText()

Which kind of wait is usually declared in the instantiation part of the code in Selenium Webdriver?

Implicit wait

Which package needs to be imported to use an implicit wait in Selenium Webdriver?

org.openqa.selenium.support.ui.WebDriverWait

Which package needs to be imported to use the WebDriver class?

org.openqa.selenium.*

What is the purpose of the get() method in WebDriver?

To launch a new browser session and direct it to a specified URL

What does the close() method do in WebDriver?

Closes the browser window

What happens if you use the System.exit(0) command without closing all browser windows first?

The whole Java program will end while leaving the browser window open

What method is used to locate GUI elements in WebDriver?

findElement(By.locator())

Which method will WebDriver throw a NoSuchElementException if called while the element is not existing?

isEnabled()

Which method will WebDriver throw a TimeoutException if called while the element is not existing?

WebDriverWait

What is the difference between driver.get() and driver.navigate() methods?

driver.navigate() maintains browser history and cookies, while driver.get() does not.

Can the forward and backward buttons be used to navigate between pages when driver.get() method is used?

No, they cannot be used.

Can the forward and backward buttons be used to navigate between pages when driver.navigate() method is used?

Yes, they can be used.

Test your knowledge on Selenium Webdriver with this quiz! Learn about the difference between close() and quit() methods in Java code examples.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free
Use Quizgecko on...
Browser
Browser