Selenium Interview Prep

Description

Coding Flashcards on Selenium Interview Prep, created by Shane Pittman on 15/04/2019.
Shane Pittman
Flashcards by Shane Pittman, updated more than 1 year ago
Shane Pittman
Created by Shane Pittman about 5 years ago
65
0

Resource summary

Question Answer
What are the advantages and disadvantages of Selenium over other testing tools like QTP and TestComplete?
What are the significant changes in upgrades in various Selenium versions? v1 included 3 tools: IDE, RC and Grid. v2 WebDriver was introduced. With the onset of WebDriver, Selenium RC got deprecated and is not in use since. v3 is in use, and it comprises of IDE, WebDriver and Grid.
Explain the different exceptions in Selenium WebDriver. TimeoutException: command performing an operation does not complete in time NoSuchElementException: element with given attributes is not found on a page ElementNotVisibleException: element is present in DOM but not visible on a page StaleElementException: element is deleted or not attached to the DOM
What is exception test in Selenium? Is an exception that you expect will be thrown inside a test class. You can use the @Test annotation and specify which exception you will be expecting by mentioning it in the parameters. Take a example: @Test(expectedException = NoSuchElementException.class)
Why and how will you use an Excel Sheet in your project? Data source, you can store -Application URL for all environments -User name and password credentials of different environments -Test cases to be executed DataDriven Test, you can store the data for different iterations to be performed in the tests.
How can you redirect browsing from a browser through some proxy? Selenium provides a PROXY class to redirect browsing from a proxy. Look at the example below: org.openqa.selenium.Proxy proxy = new.org.openqa.selenium.Proxy();
What is POM (Page Object Model)? What are its advantages? POM is a design pattern for creating an Object Repository for web UI elements The advantages of using POM are: -improves code readability -Multiple tests can use the same Object Repository -Reusability of code
What is Page Factory? Page Factory gives an optimized way to implement Page Object Model. When we say it is optimized, it refers to the fact that the memory utilization is very good and also the implementation is done in an object oriented manner.
What are the different types of WAIT statements in Selenium WebDriver? How do you achieve synchronization in WebDriver? There are two types of wait statements: Implicit Wait and Explicit Wait. Implicit instructs the WebDriver to wait for some time by polling the DOM. Explicit instructs the execution to wait for some condition: elementToBeClickable, elementToBeSelected, presenceOfElementLocated
Write a code to wait for a particular element to be visible on a page. WebDriverWait wait = new WebDriverWait(driver, 20); Element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( “<xpath”)));
Write a code to wait for an alert to appear. WebDriverWait wait = new WebDriverWait(driver, 20); Element = wait.until( ExpectedConditions.alertIsPresent());
What is the use of JavaScriptExecutor? JavaScriptExecutor is an interface which provides a way to execute Javascript through the Selenium WebDriver. JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript(Script,Arguments);
How to scroll down a page using JavaScript in Selenium? ((JavascriptExecutor) driver) .executeScript("window.scrollBy(0,500)");
How to scroll down to a particular element? ((JavascriptExecutor) driver) .executeScript("arguments[0] .scrollIntoView();", element);
How to handle keyboard and mouse actions using Selenium? Advanced User Interactions API. -clickAndHold() -dragAndDrop() -source, target()
What are different types of frameworks? Data Driven Framework: Test data is generated from external files Keyword Driven Framework: Only the instructions and operations are written in a different file like an Excel Hybrid Framework: A combination of both the Data Driven framework Keyword Driven framework.
Which files can be used as data source for different frameworks? Some of the file types of the dataset can be: excel, xml, text, csv, etc.
How can you fetch an attribute from an element? How to retrieve typed text from a textbox? Using the getAttribute() method: WebElement eLogin = driver.findElement(By.name(“Login”); String LoginClassName = eLogin.getAttribute("classname");
How to send ALT/SHIFT/CONTROL key in Selenium WebDriver? keyDown/keyUp(modifier_key) Modifier_key (keys.ALT or Keys.SHIFT or Keys.CONTROL) With a combination of these methods, we can capture the special function of a particular key.
How to take screenshots in Selenium WebDriver? By using the TakeScreenshot function. By using getScreenshotAs() method you can save that screenshot. Example: File scrFile = ((TakeScreenshot)driver) .getScreenshotAs(outputType.FILE);
How to set the size of browser window using Selenium? To maximize the size of browser window: -driver.manage().window().maximize(); To resize the current window: -setSize(); To set the window to a particular size, use -window.resizeTo();
How to handle a dropdown in Selenium WebDriver? How to select a value from dropdown? To identify the ‘select’ html element from the web page, we use findElement(). WebElement mySelectElement = driver.findElement(By.id("mySelect")); Select dropdown = new Select(mySelectElement);
How to switch to a new window (new tab) which opens up after you click on a link? Changing the WebDriver’s focus/ reference to the new window we need to use the switchTo() command. driver.switchTo().window(); If you don't know the name of the window, you can use driver.getWindowHandle();
. How do you upload a file using Selenium WebDriver? To upload a file we can simply use the command element.send_keys(file path). We have to use the html tag: ‘input’ and attribute type should be ‘file’.
Can we enter text without using sendKeys()? Yes. We can enter/ send text without using sendKeys() method. We can do it using JavaScriptExecutor.
Explain how you will login into any site if it is showing any authentication popup for username and password? Since there will be popup for logging in, we need to use the explicit command and verify if the alert is actually present. Only if the alert is present, we need to pass the username and password credentials.
Explain how can you find broken links in a page using Selenium WebDriver? Whenever you use driver.get() method to navigate to a URL, it will respond with a status of 200 – OK. 200 – OK denotes that the link is working and it has been obtained.
Which technique should you consider using throughout the script “if there is neither frame id nor frame name”? If neither frame name nor frame id is available, then we can use frame by index. driver.switchTo().frame(int arg0);
Show full summary Hide full summary

Similar

Code Challenge Flow Chart
Charlotte Hilton
Flvs foundations of programming dba 2
mariaha vassar
psycholgoy as level topic 2 - memory
Talya Hambling
EDEXCEL IGCSE (9-1) COMPUTER SCIENCE
CreativeKai 03
Chapter 10: Medical coding
Kelly Martin
Basic Python - Strings
Rebecca Noel
Our Story
Natalia R
Coding Test!
vapetrop