Selenium Flash Cards

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What is the difference between Absolute Path and Relative Path?

A single slash "/" is used to create XPath with absolute path. For example: the XPath would be created to start selection from the document node/start node and it is called Absolute XPath. While Double slash "//" is used to create XPath with relative path. For Example: the XPath would be created to start selection from anywhere within the document.And it is called Relative XPath

You have finished the Selenium Flash Cards (flip over)

If you would like to review the code to some of the questions, they are located in the SeleniumIQ slides on Canvas. Happy Memorizing!

What are the types of waits available in Selenium Web Driver?

Implicit Wait: The implicit wait will tell the web driver to wait for a certain amount of time before it throws a "No Such Element Exception". The default setting is 0. Once we set the time, the web driver will wait for that time before throwing an exception Explicit Wait: The explicit wait is used to tell the Web Driver to wait for certain conditions (Expected Conditions) or the maximum time exceeded before throwing an "ElementNotVisibleException" exception. The explicit wait is an intelligent kind of wait, but it can be applied only for specified elements Fluent Wait: The fluent wait is used to tell the web driver to wait for a condition, as well as the frequency with which we want to check the condition before throwing an "ElementNotVisibleException" exception. Frequency: Setting up a repeat cycle with the time frame to verify/check the condition at the regular interval of time

How to select a value in a dropdown?

We can use Select class: Select dropdown = new Select(driver.findElement(By.id("designation")));

What are the different exceptions you have faced in Selenium Web Driver? And how would you handle if you encounter a problem?

-ElementNotVisibleException -NoSuchElementException -NoSuchFrameException -NoAlertPresentException -NoSuchWindowException -StaleElementReferenceException -One of the worst Exceptions for an automation engineer. Web Driver throws this exception when element is in the DOM and even visible on the screen but you can't access the element as DOM reference change. This can happen if a DOM operation happening on the page is temporarily causing the element to be inaccessible. The Solution: We could refresh the page and try again for the same element. or Wait for the element till it gets available wait.until(ExpectedConditions.presenceOfElementLocated(By.id("table")))

What is the difference between Assert and Verify in Selenium?

Assert: If the assert condition is true then the program control will execute the next test step but if the condition is false, the execution will stop and further test step will not be executed Verify: Whether verified condition is true or false test script execution will continue

What are some scenarios we cannot automate using Selenium Web Driver?

Automating Captcha is not possible, We can not read bar code using Selenium Web Driver Windows based pop ups, Image validation and comparison, PDF validation and comparison

Which one is better, CSS or XPath?

Both CSS and XPath are better in the Selenium Automation when we want to automate the test Case on Internet Explorer then CSS selector is best and for the rest (Browser i.e. Firefox, Chrome and Safari) Xpath is better feasible

Is the FirefoxDriver a Class or an Interface?

FirefoxDriver is a class that has extended RemoteWebDriver. And Remote RemoteWebDriver class implements WebDriver

How to handle hidden elements in Selenium Web Driver? Is there a way to click hidden LINK in Web Driver?

First store that element in a object, let's say the element and then write following code to click on that hidden element Clicking a hidden link: WebElement element="property of element";JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("arguments[0].click();", element);

What are the types of Web Driver APIs available in Selenium?

Gecko Driver, Internet Explorer Driver, Chrome Driver, Safari Driver, HTMLUnit Driver

Which Web Driver implementation claims to be the fastest?

HTMLUnitDriver, it is a headless browser which has less User Interface

What are the Open-source Frameworks supported by Selenium Web Driver?

JUnit ● TestNG ● Cucumber ● JBehave

What is Selenese?

Selenese is the language which is used to write test scripts in Selenium IDE

What is Selenium IDE?

Selenium IDE is an integrated development environment for Selenium scripts, It is add-in for Firefox browser, It allows tester to record, edit, playback and debug tests

What is Selenium? What is it used for?

Selenium is a suite of software tools to automate Web Browsers, It is an open source suite of tools mainly used for Functional and Regression Test Automation

What are Soft Assert and Hard Assert in Selenium?

Soft assertion: Doesn't throw an exception on failure instead it collects all the errors until it finishes. And that's how we could manage to run all the steps of a test @Test Hard assertion: Breaks a test immediately with an AssertException after the assert method reports failure. If one of the many test cases fails, then the execution continues with the remaining tests

How can you find Broken Links/Images in a page using Selenium Web Driver?

Steps to find broken links: •Collect all the links from the webpage. All the links are associated with the Tag 'a' •Create a list of type WebElement to store all the Link elements in to it •Now Create a Connection using URL object( i.e ., link) •Connect using Connect Method •Use getResponseCode() to get response code. eg 200

What locators are available in Selenium?

There are eight locators in selenium to identify the web elements on the web page : ID, ClassName, Name, TagName, LinkText, PartialLinkText, XPath, CSS Selector

How to input text in the text box without calling the sendKeys()?

Using Java Script Executor: JavascriptExecutor executor = (JavascriptExecutor)driver; executor.executeScript("document.getElementById("email").value='[email protected]';);

How to pause a test execution at any given point?

Using Thread.sleep(amount of seconds);

How To Perform Right Click (Context Click) In Selenium Web Driver? Double Click? Hover over on a web element? Drag And Drop?

Using action class we can perform all of this operations

How would you handle element that is in different frame?

Using switch commands we can switch to different frame to handle elements. We can switch to the frame 3 different ways: 1. Switch to Frame by Name or ID 2. Switch to Frame by WebElement 3. Switch to Frames by Index

What is the difference between CSS and XPath?

Usually CSS is easy to use and readable over XPath. CSS is native to browsers. Speed wise, XPath is not faster than CSS since both can be of equal speed, or either one would be a bit faster than the other. Therefore, speed comparison can be ignored. However, CSS is much faster than XPath in IE Browser

What is the difference between selenium 3 and selenium 2? Which one do you incorporate in your framework? How does Selenium interact with the web browser?

We are using the Selenium 3.0 because of compatibility issues which can support most of the latest browsers any way we are creating maven project any dependency we can easily update in pom.xml file

How do you handle an element in different windows?

We can handle multiple windows in selenium web driver using Switch To methods which will allow us to switch control from one window to another window getWindowHandle() will get the handle of the page the web driver is currently controlling. This handle is a unique identifier for the web page. This is different every time you open a page even if it is the same URL.

How can we handle a web based pop up?

We can handle web based pop-ups using Alert Interface.There are the four methods that we would be using along with the Alert interface: 1) void dismiss() -The dismiss() method clicks on the "Cancel" button as soon as the pop up window appears 2) void accept() -The accept() method clicks on the "Ok" button as soon as the pop up window appears 3) String getText() -The getText() method returns the text displayed on the alert box 4) void sendKeys(String stringToSend) -The sendKeys() method enters the specified string pattern into the alert box Selenium Web Driver cannot handle window based pop up, for that we can use AutoIT

What are operations can you do using actions class?

We can perform following operation using action class: •click(): Simply click on element •doubleClick(): Double clicks on Element •contextClick() : Performs a context-click (right click) on an element •clickAndHold(): Clicks at the present mouse location (without releasing) •dragAndDrop(source, target): Invokes click-and-hold at the source location and moves to the location of the target element before releasing the mouse. source -element to grab, target-element to release

How to capture Screenshot in Selenium Web Driver?

We use TakeScreenShot interface to capture screenshot //Step 1. Convert web driver object to TakeScreenshot //Step 2. Call getScreenshotAs method to create image file //Step 3. Move image file to new destination //Step 4. Copy file at destination

What is XPath?

XPath is a query language for selecting an locating web elements within an XML document

Have you done any cross browser testing within your Project?

Yes I have done cross browser testing in my framework using 3 browser initialization. Chrome , IE and Firefox testing using Web driver.

What is the difference between driver.close() and driver.quit() methods?

close()-It is used to close the browser or page currently which is having the focus quit()-It is used to shut down the web driver instance or destroy the web driver instance(Close all the windows)

What is the difference between driver.findElement() and driver.findElements() commands?

findElement(): Will return only a single WebElement and if that element is not located or we use some wrong selector then it will throw NoSuchElementexception findElements(): will return a List of WebElements-It returns an empty list, when element is not found on current page as per the given element locator mechanism. It doesn't throws NoSuchElementException

How to check the multiple selected value in a dropdown?

isMultiple() Method: isMultiple() method is useful to verify if the targeted select box is a multiple select box or not. Which means we can select multiple options from that select box. It will return a boolean (true or false) value. We can use it with if condition before working with select box

How to Upload a file in Selenium Web Driver?

sendKeys() method on the file-select input field to enter the path to the file to be uploaded WebElement uploadElement = driver.findElement(By.id("uploadfile_0"));// enter the file path onto the file-selection input fielduploadElement.sendKeys("C:\\newhtml.html");

How to input text in the text box using Selenium Web Driver?

we can input text using sendkeys


Ensembles d'études connexes

Algebra II 1st Nine Weeks Exam (10.8.19)

View Set

Lesson 1: Developing a Social Media Strategy

View Set

Public Speaking 1315 Midterm-Final Blinn

View Set

Mgt 301 Connect Questions Chapter 1-3

View Set

9.30.W - Lesson Review: PT: Metalloids & Halogens / PT: Nonmetals & Noble Gases / Want to Know More About the Elements?

View Set

International Business Chapter 2

View Set

Modern Architecture and Urbanism Final Study Guide

View Set