Automation Engineer: Selenium

Ace your homework & exams now with Quizwiz!

What are the benefits of Automation Testing?

- Fast Test Execution (manual is time comsuming) - Re-usability Of Test Cases (prepare one time and run many time) - Testing Cost Reduction (Reduce human efford) - Better Test Coverage In Each Version Release (can execute all release) - Easy For Compatibility Testing (easy to run same test on different environtment)

What is a Framework?

A framework defines a set of rules or best practices which we can follow in a systematic way to achieve the desired results

Stale Element Reference Exception:

A stale element reference exception is thrown in one of two cases, the first being more common than the second. The two reasons for Stale element reference are The element has been deleted entirely. The element is no longer attached to the DOM. We face this stale element reference exception when the element we are interacting is destroyed and then recreated again. When this happens the reference of the element in the DOM becomes stale. Hence we are not able to get the reference to the element. Some other exceptions we usually face are as follows: WebDriverException IllegalStateException TimeoutException NoAlertPresentException NoSuchWindowException NoSuchElementException

What is the difference between Absolute Path and Relative Path?

Absolute XPath starts from the root node and ends with desired descendant element's node. It starts with top HTML node and ends with input node. It starts with a single forward slash(/) Relative XPath starts from any node in between the HTML page to the current element's node(last node of the element). It starts with a double forward slash(//)

What is the alternative to driver.get() method to open an URL using Selenium WebDriver?

Alternative method to driver.get("url") method is driver.navigate.to("url")

What happens if I run this command. driver.get("www.softwaretestingmaterial.com") ;

An exception is thrown. We need to pass HTTP protocol within driver.get() method.

What is the difference between Assert and Verify in Selenium?

Assert: In simple words, 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: In simple words, there won't be any halt in the test execution even though the verify condition is true or false.

What is Automation Testing?

Automation testing is the process of testing a software or application using an automation testing tool to find the defects. In this process, executing the test scripts and generating the results are performed automatically by automation tools. It is required when we have huge amount of regression test cases. Some most popular tools to do automation testing are HP QTP/UFT, Selenium WebDriver, etc.,

How to Download a file in Selenium WebDriver?

By using AutoIT script, we could download a file in Selenium WebDriver.

How to read a JavaScript variable in Selenium WebDriver?

By using JavascriptExecutor

How to select a value in a dropdown?

By using Select class WebElement mySelectElement = driver.findElement(By.name("dropdown")); Select dropdown = new Select(mySelectElement); dropdown.selectByVisibleText(Text); dropdown.selectByIndex(Index); dropdown.selectByValue(Value);

How to clear the text in the text box using Selenium WebDriver?

By using clear() method

How to get an attribute value using Selenium WebDriver?

By using getAttribute(value); It returns the value of the attribute passed as a parameter.

How to get a text of a web element?

By using getText() method

How to pause a test execution for 5 seconds at a specific point?

By using java.lang.Thread.sleep(long milliseconds) method we could pause the execution for a specific time. To pause 5 seconds, we need to pass parameter as 5000 (5 seconds)

How to input text in the text box using Selenium WebDriver?

By using sendKeys() method

What are the advantages of Page Object Model Framework?

Code reusability - We could achieve code reusability by writing the code once and use it in different tests. Code maintainability - There is a clean separation between test code and page specific code such as locators and layout which becomes very easy to maintain code. Code changes only on Page Object Classes when a UI change occurs. It enhances test maintenance and reduces code duplication. Object Repository - Each page will be defined as a java class. All the fields in the page will be defined in an interface as members. The class will then implement the interface. Readability - Improves readability due to clean separation between test code and page specific code

What is Continuous Integration?

Continuous Integration is a development practice which aims to make sure the correctness of a software. After each commit, a suite of tests run automatically and test the software to ensure whether the software is running without any breaks. If any test fails, we will get immediate feedback say "build is broken". In simple words, continuous integration is a process of verifying the correctness of a software. Some of the continuous integration tools are Jenkins, TeamCity, Bamboo, Travis, Circle Ci, Bitbucket. We can schedule the test suite execution using these CI Tools.

Is the FirefoxDriver a Class or an Interface?

FirefoxDriver is a Java class, and it implements the WebDriver interface.

What is Fluent Wait In Selenium WebDriver?

FluentWait can define the maximum amount of time to wait for a specific condition and frequency with which to check the condition before throwing an "ElementNotVisibleException" exception.

Why do you prefer Selenium Automation Tool?

Free and open source Have large user base and helping communities Cross-browser compatibility Platform compatibility Multiple programming languages support such as Java, Perl, Phyton, Php, C# etc.,

What are the Locators available in Selenium?

In Selenium WebDriver, there are 8 different types of locators: ID ClassName Name TagName LinkText PartialLinkText XPath CSS Selector

How to switch over the elements in iframes using Web Driver commands:

In Selenium we can switch to frames using switchTo () method then perform the action on that element. Basically, we can switch over the elements in frames using 3 ways. • By Index • By Name or Id • By Web Element

What are the types of waits available in Selenium WebDriver?

In Selenium we could see three types of waits such as Implicit Waits, Explicit Waits and Fluent Waits. Implicit Waits Explicit Waits Fluent Waits

What are the advantages of Selenium Grid?

It allows running test cases in parallel thereby saving test execution time. It allows multi-browser testing It allows us to execute test cases on multi-platform

What are the Open-source Frameworks supported by Selenium WebDriver?

JUnit TestNG

How To Scroll Web Page Down Or UP Using Selenium WebDriver?

JavaScript scrollBy() method scrolls the document by the specified number of pixels.

Have you created any Framework?

No, I didn't get a chance to create framework from the scratch. I have used the framework which is already available. My contribution is mostly in creating test cases by using the existing framework. I have involved in developing framework along with other automation tester in my company.

What is Page Object Model in Selenium?

Page Object Model is a Design Pattern which has become popular in Selenium Test Automation. It is widely used design pattern in Selenium for enhancing test maintenance and reducing code duplication. Page object model (POM) can be used in any kind of framework such as modular, data-driven, keyword driven, hybrid framework etc. A page object is an object-oriented class that serves as an interface to a page of your Application Under Test(AUT). The tests then use the methods of this page object class whenever they need to interact with the User Interface (UI) of that page. The benefit is that if the UI changes for the page, the tests themselves don't need to change, only the code within the page object needs to change. Subsequently, all changes to support that new UI is located in one place.

What is the difference between Page Object Model (POM) and Page Factory?

Page Object is a class that represents a web page and hold the functionality and members. Page Factory is a way to initialize the web elements you want to interact with within the page object when you create an instance of it.

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

Purpose of these two methods (driver.close and driver.quit) is almost same. Both allow us to close a browser but still, there is a difference. driver.close(): To close current WebDriver instance driver.quit(): To close all the opened WebDriver instances

What type of tests have you automated?

Regression testing, Smoke testing, and Sanity testing

What is Selenium Grid?

Selenium Grid is specialized in running the test scripts in multiple test environments across different browsers, Operating Systems (OS) and machines in parallel. • The system where we execute the scripts is called as a hub, and the execution that takes place in different machines are called as nodes. • Mostly it helps to execute performance testing.

What is Selenium IDE?

Selenium IDE (Integrated Development Environment) is a Firefox plugin. It is the simplest framework in the Selenium Suite. It allows us to record and playback the scripts. Even though we can create scripts using Selenium IDE, we need to use Selenium RC or Selenium WebDriver to write more advanced and robust test cases. Selenese is the language which is used to write test scripts in Selenium IDE. Firefox is the only browser that supports Selenium IDE

What is Selenium WebDriver?

Selenium WebDriver helps to create and execute the test cases using Element locators/Object locators. Since it is interacting directly with a web browser without any external server.

What is selenium?

Selenium is an open source (free) automated testing suite to test web applications. It supports different platforms and browsers. Selenium is a set of different software tools. Each tool has a different approach in supporting web based automation testing. It has four components namely, Selenium IDE (Selenium Integrated Development Environment) Selenium RC (Selenium Remote Control) Selenium WebDriver Selenium Grid

What is Selenium RC?

Slenium RC (Selenium Remote control) Selenium Remote Control was the main Selenium project for a long time before the Selenium WebDriver

What are Soft Assert and Hard Assert in Selenium?

Soft Assert: Soft Assert collects errors during @Test Soft Assert does not throw an exception when an assert fails and would continue with the next step after the assert statement. Hard Assert: Hard Assert throws an AssertException immediately when an assert statement fails and test suite continues with next @Test

What are the different exceptions you have faced in Selenium WebDriver?

Some of the exceptions I have faced in my current project are ElementNotVisibleException StaleElementReferenceException

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

The difference between driver.findElement() and driver.findElements() commands is- findElement() returns a single WebElement (found first) based on the locator passed as parameter. Whereas findElements() returns a list of WebElements, all satisfying the locator value passed. Another difference between the two is- if no element is found then findElement() throws NoSuchElementException whereas findElements() returns a list of 0 elements.

22. Which WebDriver implementation claims to be the fastest?

The fastest implementation of WebDriver is the HTMLUnitDriver. It is because the HTMLUnitDriver does not execute tests in the browser. (browsers with no visual representation )

What are the ways to refresh a browser using Selenium WebDriver?

There are multiple ways to refresh a page in selenium Using driver.navigate().refresh() command as mentioned in the question 45 Using driver.get("URL") on the current URL or using driver.getCurrentUrl() Using driver.navigate().to("URL") on the current URL or driver.navigate().to(driver.getCurrentUrl()); Using sendKeys(Keys.F5) on any textbox on the webpage

How to Upload a file in Selenium WebDriver?

There are two cases which are majorly used to upload a file in Selenium WebDriver such as using SendKeys Method and using AutoIT Script.

Element Not visible Exception:

This exception will be thrown when you are trying to locate a particular element on webpage that is not currently visible eventhough it is present in the DOM. Also sometimes, if you are trying to locate an element with the xpath which associates with two or more element.

How to delete cookies in Selenium?

To delete cookies we use deleteAllCookies() method

How to fetch the current page URL in Selenium?

To fetch the current page URL, we use getCurrentURL()

How can we maximize browser window in Selenium?

To maximize browser window in selenium we use maximize() method. This method maximizes the current window if it is not already maximized

How to press ENTER key on text box In Selenium WebDriver?

To press ENTER key using Selenium WebDriver, We need to use Selenium Enum Keys with its constant ENTER.

How To Resize Browser Window Using Selenium WebDriver?

To resize the browser window to particular dimensions, we use 'Dimension' class to resize the browser window.

How to handle hidden elements in Selenium WebDriver?

We can handle hidden elements by using javaScript executor

What are the challenges and limitations of Selenium WebDriver?

We cannot test windows application We cannot test mobile apps Limited reporting Handling dynamic Elements Handling page load Handling pop up windows Handling captcha

What is Page Factory?

We have seen that 'Page Object Model' is a way of representing an application in a test framework. For every 'page' in the application, we create a Page Object to reference the 'page' whereas a 'Page Factory' is one way of implementing the 'Page Object Model'.

How to submit a form using Selenium WebDriver?

We use "submit" method on element to submit a form

How To Perform Double Click Action In Selenium WebDriver?

We use Actions class to do Double click action in selenium.

Can I navigate back and forth in a browser in Selenium WebDriver?

We use Navigate interface to do navigate back and forth in a browser. It has methods to move back, forward as well as to refresh a page. driver.navigate().forward(); - to navigate to the next web page with reference to the browser's history driver.navigate().back(); - takes back to the previous webpage with reference to the browser's history driver.navigate().refresh(); - to refresh the current web page thereby reloading all the web elements driver.navigate().to("url"); - to launch a new web browser window and navigate to the specified URL

How to click on a hyperlink using Selenium WebDriver?

We use click() method in Selenium to click on the hyperlink

How to launch a browser using Selenium WebDriver?

WebDriver is an Interface. We create an Object of a required driver class such as FirefoxDriver, ChromeDriver, InternetExplorerDriver etc., To launch Chrome Driver: WebDriver driver = new ChromeDriver();

How can we handle web-based pop up?

WebDriver offers the users with a very efficient way to handle these pop-ups using Alert interface. There are the four methods that we would be using along with the Alert interface. void dismiss() - The accept() method clicks on the "Cancel" button as soon as the pop-up window appears. void accept() - The accept() method clicks on the "Ok" button as soon as the pop-up window appears. String getText() - The getText() method returns the text displayed on the alert box. void sendKeys(String stringToSend) - The sendKeys() method enters the specified string pattern into the alert box. Syntax: // accepting javascript alert Alert alert = driver.switchTo().alert(); alert.accept();

What is WebDriver Wait In Selenium WebDriver?

WebDriverWait is applied on a certain element with defined expected condition and time. This wait is only applied to the specified element. This wait can also throw an exception when an element is not found

What are the Operating Systems supported by Selenium WebDriver?

Windows Linux Apple

What is an XPath?

XPath is used to locate the elements. Using XPath, we could navigate through elements and attributes in an XML document to locate web elements

What is the difference between driver.get() and driver.navigate.to("url")?

driver.get(): To open an URL and it will wait till the whole page gets loaded driver.navigate.to(): To navigate to an URL and It will not wait till the whole page gets loaded

How to switch between frames in Selenium?

driver.switchTo().frame();

How To Perform Right Click Action (Context Click) In Selenium WebDriver?

https://www.softwaretestingmaterial.com/selenium-right-click-action/

How to find whether an element is displayed on the web page?

isDisplayed() isSelected() isEnabled()

What is Implicit Wait In Selenium WebDriver?

mplicit waits tell to the WebDriver to wait for a certain amount of time before it throws an exception. Once we set the time, WebDriver will wait for the element based on the time we set before it throws an exception


Related study sets

Napoleon Video Questions Parts 3 and 4

View Set

AP Lit Unit 7: Explain the function of character. Quiz

View Set

Chapter 14- Digestive System- Honors Anatomy & Physiology

View Set

The Outsiders by S. E. Hinton HH chapter analysis

View Set

INFO 320 - Exam 1 Prep (Chapters 1-3)

View Set

Psychological Disorders (Chapter 12- Substance-Related and Addictive Disorders)

View Set

Unit 2 1003: Pharm- Genitourinary Practice Questions

View Set

System Analysis & Design - Chapter 7

View Set

Дни недели и цифры

View Set