Trick Software Automation Questions Flashcards
What is the difference between an Assert and a Verify with Selenium Commands?
Assert allows to check whether an element is on the page or not. The test will stop on the step failed, if the asserted element is not available.
Verify command will check whether the element is on the page, if it is not then the test will carry on executing. In verification, all the commands are going to run guaranteed even if any of test fails.
What is one big difference between SilkTest and Selenium?
Selenium supports many browsers like Internet Explorer, Opera, Chrome, Firefox, Safari.
SilkTest supports only Internet Explorer and Firefox
Another difference is Selenium has many language bindings like Java, .Net, Perl, PHP, Python, Ruby under test while SilkTest uses 4Test scripting language to describe the test procedure.
Which browsers can Selenium IDE be run in?
FireFox
How does one get rid of the right-pointing green triangle?
Right click on that line and remove break point.
How can one add vertical white space between sections of a single test?
You can use vertical bars at the beginning of lines to produce blank lines in the output.
What does SIDE stand for?
Selenium Integrated Development Environment.
What regular expression special character(s) means “any character?”
- = star or asterisk
What distinguishes between an absolute and relative URL in SIDE?
Absolute will have Double Slash
Relative will have single slash
An absolute URL contains more information than a relative URL does. Relative URLs are more convenient because they are shorter and often more portable. However, you can use them only to reference links on the same server as the page that contains them.
How would one access a Selenium variable named “count” from within a JavaScript snippet?
${count} = dollar sign curly brackets count
What Selenese command can be used to display the value of a variable in the log file, which can be very valuable for debugging?
We can use echo command to log information in the test result output.
Where did the name Selenium come from?
Actually, Selenium is a chemical element name. But Thoughtworks used it for test automation framework api.
Which Selenium command(s) simulates selecting a link?
For simulating selecting a link, we can use findElement(By.Link(“LinkName”))
Which two commands can be used to check that an alert with a particular message popped up?
Use command VerifyAlertPresent
What command simulates selecting the browser’s Back button?
driver.navigate().back() command
If the Test Case frame contains several test cases, how can one execute just the selected one of those test cases?
Users can use “Play current test case” function of Selenium IDE
What is the generic name for an argument (to a Selenese command) which starts with //?
Xpath
What Selenese command is used to choose an item from a list?
Select command
How can one get SIDE to always record an absolute URL for the open command’s argument?
In the Selenium IDE options, check “Record Absolute URL” option.
What Selenese command and argument can be used to transfer the value of a JavaScript variable into a SIDE variable?
Use “store” command
Explain the different exceptions in Selenium WebDriver.
TimeoutException: This exception is thrown when a command performing an operation does not complete in the stipulated time
NoSuchElementException: This exception is thrown when an element with given attributes is not found on the web page
ElementNotVisibleException: This exception is thrown when the element is present in DOM (Document Object Model), but not visible on the web page.
NoAlertPresentException
StaleElementException: This exception is thrown when the element is either deleted or no longer attached to the DOM.
What is exception test in Selenium?
An exception test is an exception that you expect will be thrown inside a test class.
Why and how will you use an Excel Sheet in your project?
It can be used as data source for tests. An excel sheet can also be used to store the data set while performing DataDriven Testing
What is POM (Page Object Model)? What are its advantages?
Page Object Model is a design pattern for creating an Object Repository for web UI elements. Each web page in the application is required to have it’s own corresponding page class. The page class is thus responsible for finding the WebElements in that page and then perform operations on those WebElements.
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 is the difference between Implicit Wait and Explicit Wait
Implicit wait instructs the WebDriver to wait for some time by polling the DOM. Once you have declared implicit wait, it will be available for the entire life of the WebDriver instance.
Explicit wait instructs the execution to wait for some time until some condition is achieved. Some of those conditions to be attained are:
elementToBeClickable
elementToBeSelected
presenceOfElementLocated
Write a code to wait for a particular element to be visible on a page. Write a code to wait for an alert to appear.
WebDriverWait wait=new WebDriverWait(driver, 20); Element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( “
What is the use of JavaScriptExecutor?
JavaScriptExecutor is an interface which provides a mechanism to execute Javascript through the Selenium WebDriver. It provides “executescript” and “executeAsyncScript” methods, to run JavaScript in the context of the currently selected frame or window.
How to scroll down a page using JavaScript in Selenium?
window.scrollBy() function.
((JavascriptExecutor) driver).executeScript(“window.scrollBy(0,500)”);
How to scroll down to a particular element?
scrollIntoView().
((JavascriptExecutor) driver).executeScript(“arguments[0].scrollIntoView();”, element);
How to handle keyboard and mouse actions using Selenium?
using Advanced User Interactions API
clickAndHold() - Clicks (without releasing) the current mouse location.
dragAndDrop() - Performs click-and-hold at the location of the source element, moves.
source, target() - Moves to the location of the target element, then releases the mouse.
- What are different types of frameworks?
Data Driven Framework:-
When the entire test data is generated from some external files like Excel, CSV, XML or some database table,
Keyword Driven Framework:-
When only the instructions and operations are written in a different file like an Excel worksheet,
Hybrid Framework:-
A combination of both the Data Driven framework and the Keyword Driven framework
How can you fetch an attribute from an element? How to retrieve typed text from a textbox?
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(modifier_key) and keyUp(modifier_key) Parameters: Modifier_key (keys.ALT or Keys.SHIFT or Keys.CONTROL)
.click()
.keyDown(txtUserName, Keys.SHIFT)
.sendKeys(txtUserName, “hello”)
.keyUp(txtUserName, Keys.SHIFT)