Reader small image

You're reading from  Selenium WebDriver 3 Practical Guide - Second Edition

Product typeBook
Published inJul 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781788999762
Edition2nd Edition
Languages
Right arrow
Authors (3):
Pallavi Sharma
Pallavi Sharma
author image
Pallavi Sharma

Pallavi Sharma is a founder of 5 Elements Learning. She has 12 years professional experience. She has worked in varied roles as a product/project manager, in presales team, marketing team, and test automation coach in the software testing domain. Being an avid learner, she also likes to keep herself up to date with the latest trends and technologies. She is a firm believer that there is no shortcut to success.
Read more about Pallavi Sharma

UNMESH GUNDECHA
UNMESH GUNDECHA
author image
UNMESH GUNDECHA

Unmesh Gundecha has over 16 years, experience in Agile software development, test automation, and DevOps methodologies. He is an Agile, open source, and DevOps evangelist with extensive experience in a diverse set of tools and technologies. He has extensive hands-on experience in building sustainable and repeatable test automation solutions for web and mobile platforms, APIs, and CLI apps with continuous integration and delivery pipelines, using best-of-breed open source and commercial tools to do so. He is the author of Selenium Testing Tools Cookbook and Learning Selenium Testing Tools with Python, both by Packt Publishing.
Read more about UNMESH GUNDECHA

Satya Avasarala
Satya Avasarala
author image
Satya Avasarala

Satya Avasarala has rich experience in Java development and automation testing. He is an engineer in computer science. He has used WebDriver for many years now and has created several good automation frameworks. He has worked at various large software enterprises such as Oracle Corp, Yahoo! Inc., VMware Inc., and the REA Group. In addition, he is also interested in Service Oriented Architectural design and Business Intelligence. He is an Oracle-certified Service Oriented Architecture Infrastructure Implementation Expert and a Business Intelligence Foundation Suite Implementation Specialist.
Read more about Satya Avasarala

View More author details
Right arrow

Assessments

Chapter 1

  1. True or false: Selenium is a browser automation library.

True.

  1. What are the different types of locator mechanisms provided by Selenium?

The different types of locator mechanisms are ID, Name, ClassName, TagName, Link, LinkText, CSS Selector, and XPATH.

  1. True or false: With the getAttribute() method, we can read CSS attributes as well?

False. The getCssValue() method is used to read CSS attributes.

  1. What actions can be performed on a WebElement?

The actions performed are click, type (sendKeys), and submit.

  1. How can we determine whether the checkbox is checked or unchecked?

By using the isSelected() method.

Chapter 2

  1. What is the significance of WebDriver becoming a W3C specification?

WebDriver is now a W3C specification. This means browsers have to be fully compliant with WebDriver spec set by the World Wide Web Consortium (W3C for short) and will be supported natively by the browser vendor the HTML5 and CSS are other prominent W3C specifications.

  1. True or false: WebDriver is an interface.

True.

  1. Which browsers support headless testing?

Google Chrome and Mozilla Firefox.

  1. How can we test mobile websites with Chrome?

By using the Mobile Emulation feature.

Chapter 3

  1. Which version of Java Streams API is introduced?

Java 8.

  1. Explain the filter function of Streams API.

Java Stream API provides a filter() method to filter stream elements on the basis of the given predicate. Suppose we want to get all the link elements that are visible on the page, we can use the filter() method to return the list in the following way:

List<WebElement> visibleLinks = links.stream()
.filter(item -> item.isDisplayed())
.collect(Collectors.toList());
  1. Which method of Streams API will return the number of matching elements from the filter() function?

count().

  1. We can use the map() function to filter a list of WebElements by attribute values: True or false?

False.

Chapter 4

  1. Which are the different formats we can use to output a screenshot?

The OutputType interface support screenshot types in BASE64, BYTES, and FILE formats.

  1. How can we switch to another browser tab with Selenium?

We can switch to another browser tab using the driver.switchTo().window() method.

  1. True or false: The defaultContent() method will switch to the previously selected frame.

False. The defaultContent() method will switch to the page.

  1. What navigation methods are available with Selenium?

The Navigate interface provides to() , back() , forward() , and refresh() methods.

  1. How can we add a cookie using Selenium?

We can add a cookie using the driver.manage().addCookie(Cookie cookie) method.

  1. Explain the difference between an implicit wait and an explicit wait.

An implicit wait once set will be available for the entire life of the WebDriver instance. It will wait...

Chapter 5

  1. True or false – the drag and drop action requires the source element and the target element.

True.

  1. List the keyboard methods that we can perform using the actions API.

sendKeys(), keyUp(), and keyDown().

  1. Which method of the actions API will help in performing a double-click operation?

doubleClick(WebElement target).

  1. Using the actions API, how can we perform a save option (that is to say, Ctrl + S)?

new Actions(driver) .sendKeys(Keys.chord(Keys.CONTROL, "s")) .perform();.

  1. How can we open a context menu using the actions API?

By calling the contextClick() method.

Chapter 6

  1. You can listen to WebDriver events using WebDriverEventListener interface: True or False?

True.

  1. How you can automatically clear an input field before calling the sendKeys method using WebDriverEventListener?

We can call the WebElement.clear() method in the beforeChangeValueOf() event handler.

  1. Selenium supports Accessibility Testing: True or false?

False. Selenium does not support Accessibility testing

Chapter 7

  1. True or false: with Selenium, we can execute tests on the remote machine(s)-

True.

  1. Which driver class is used to run tests on a remote machine?

The RemoteWebDriver class.

  1. Explain the DesiredCapabilities class.

The DesiredCapabilities class is used to specify browser capabilities needed by the test script from the RemoteWebDriver. For example, we can specify the name of the browser, operating system, and version in DesiredCapabilities and pass it to RemoteWebDriver. The Selenium Standalone Server will match the configured capabilities with the available nodes and run the test on the matching node.

  1. What protocol is used between the Selenium test and Selenium Standalone Server?

JSON-Wire.

  1. What is the default port used by the Selenium Standalone Server?

Port 4444.

Chapter 8

  1. Which argument can be used to specify how many browser instances can be supported by the node?

maxInstances.

  1. Explain how Selenium Grid can be used to support Cross Browser Testing.

With Selenium Grid, we can set up nodes for various Browser and Operating System combinations and run tests in a distributed architecture. Based on capabilities provided by the test, Selenium Grid selects the appropriate node and executes the test on the selected node. We can add as many nodes as required based on combinations we want to test as per the cross-browser testing matrix required for testing.

  1. What is the URL you need to specify with RemoteWebDriver to run tests on Selenium Grid?

http://gridHostnameOrIp:4444/wd/hub.

  1. Selenium Grid Hub acts as a load balancer: True or False?

True. Selenium Grid Hub distributes tests on multiple nodes based on the availability of the node

...

Chapter 9

  1. How do you initialize a PageObject implemented with PageFactory?

PageFactory.initElements(driver, pageObjectClass).

  1. Using which class can we implement methods to validate whether the page is loaded?

LoadableComponent.

  1. Which By class methods are supported by @FindBy?

ID, Name, ClassName, TagName, Link, PartialLinkText, CSS Selector, and XPATH.

  1. While using PageFactory, if you name the WebElement variable name by the same ID or name attribute, then you don't need to use the @FindBy annotation: True or false?

True. You can declare the WebElement variable with the same name as the value of id or name attribute, PageFactory will resolve it without using the @FindBy annotation

Chapter 10

  1. What are the different types of Mobile Apps?

Native, Hybrid, and Mobile Web Applications.

  1. Which classes does Appium Java Client library provide for testing iOS and Android applications?

AndroidDriver and IOSDriver.

  1. What is the command to list the Android devices connected to a computer via USB ports?

adb devices.

  1. What is the default port used by Appium Server?

Port 4723.

Chapter 11

  1. Explain Data-driven Testing.

Data-driven is a test automation framework approach, where input test data is stored in tabular format or in a spreadsheet format and a single test script reads each row of the data, which can be a unique test case, and executes the steps. This enables reuse of test scripts and increases test coverage with varied test data combinations.

  1. True or False: Selenium supports data-driven testing.

False.

  1. What are two methods in TestNG to create data-driven tests?

TestNG provides two methods for data-driven testing: Suite Parameters and Data Providers.

  1. Explain the DataProvider method in TestNG.

The DataProvider method in TestNG is a special method annotated with the @DataProvider annotation. It returns an array of objects. We can return tabular data reading from any format such as CSV or Excel to test the test case using the data provider...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Selenium WebDriver 3 Practical Guide - Second Edition
Published in: Jul 2018Publisher: PacktISBN-13: 9781788999762
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (3)

author image
Pallavi Sharma

Pallavi Sharma is a founder of 5 Elements Learning. She has 12 years professional experience. She has worked in varied roles as a product/project manager, in presales team, marketing team, and test automation coach in the software testing domain. Being an avid learner, she also likes to keep herself up to date with the latest trends and technologies. She is a firm believer that there is no shortcut to success.
Read more about Pallavi Sharma

author image
UNMESH GUNDECHA

Unmesh Gundecha has over 16 years, experience in Agile software development, test automation, and DevOps methodologies. He is an Agile, open source, and DevOps evangelist with extensive experience in a diverse set of tools and technologies. He has extensive hands-on experience in building sustainable and repeatable test automation solutions for web and mobile platforms, APIs, and CLI apps with continuous integration and delivery pipelines, using best-of-breed open source and commercial tools to do so. He is the author of Selenium Testing Tools Cookbook and Learning Selenium Testing Tools with Python, both by Packt Publishing.
Read more about UNMESH GUNDECHA

author image
Satya Avasarala

Satya Avasarala has rich experience in Java development and automation testing. He is an engineer in computer science. He has used WebDriver for many years now and has created several good automation frameworks. He has worked at various large software enterprises such as Oracle Corp, Yahoo! Inc., VMware Inc., and the REA Group. In addition, he is also interested in Service Oriented Architectural design and Business Intelligence. He is an Oracle-certified Service Oriented Architecture Infrastructure Implementation Expert and a Business Intelligence Foundation Suite Implementation Specialist.
Read more about Satya Avasarala