Best selenium interview questions with answers to proceed interview with HR. Here are questions about automation and tools. Tips and Tricks for cracking selenium interview.
If there is any new Selenium interview question that have been asked to you, kindly post it in the the comment section.
Ans:
Automation testing or Test Automation is a process of automating the manual process to test the application/system under test. Automation testing involves the use of a separate testing tool which lets you create test scripts which can be executed repeatedly and doesn’t require any manual intervention.
Ans:
Benefits of Automation testing are:
Ans:
Selenium
Ans:
Selenium is one of the most popular automated testing suites. Selenium is designed in a way to support and encourage automation testing of functional aspects of web-based applications and a wide range of browsers and platforms. Due to its existence in the open source community, it has become one of the most accepted tools amongst the testing professionals.
Selenium is not just a single tool or a utility, rather a package of several testing tools and for the same reason, it is referred to as a Suite. Each of these tools is designed to cater different testing and test environment requirements.
The suite package constitutes of the following sets of tools:
Ans:
Following are the limitations of Selenium:
Ans:
Feature | Selenium IDE | Selenium RC | WebDriver |
Browser Compatibility | Selenium IDE comes as a Firefox plugin, thus it supports only Firefox | Selenium RC supports a varied range of versions of Mozilla Firefox, Google Chrome, Internet Explorer and Opera | WebDriver supports a varied range of versions of Mozilla Firefox, Google Chrome, Internet Explorer and Opera. Also supports HtmlUnitDriver which is a GUI less or headless browser. |
Record and Playback | Selenium IDE supports record and playback feature | Selenium RC doesn’t supports record and playback feature | WebDriver doesn’t support record and playback feature |
Server Requirement | Selenium IDE doesn’t require any server to be started before executing the test scripts | Selenium RC requires server to be started before executing the test scripts | WebDriver doesn’t require any server to be started before executing the test scripts |
Architecture | Selenium IDE is a Javascript based framework | Selenium RC is a JavaScript based Framework | WebDriver uses the browser’s native compatibility to automation |
Object Oriented | Selenium IDE is not an object oriented tool | Selenium RC is semi object oriented tool | WebDriver is a purely object oriented tool |
Dynamic Finders (for locating web elements on a webpage) | Selenium IDE doesn’t support dynamic finders | Selenium RC doesn’t support dynamic finders | WebDriver supports dynamic finders |
Handling Alerts, Navigations, Dropdowns | Selenium IDE doesn’t explicitly provides aids to handle alerts, navigations, dropdowns | Selenium RC doesn’t explicitly provides aids to handle alerts, navigations, dropdowns | WebDriver offers a wide range of utilities and classes that helps in handling alerts, navigations, and dropdowns efficiently and effectively. |
WAP (iPhone/Android) Testing | Selenium IDE doesn’t support testing of iPhone/Andriod applications | Selenium RC doesn’t support testing of iPhone/Andriod applications | WebDriver is designed in a way to efficiently support testing of iPhone/Android applications. The tool comes with a large range of drivers for WAP based testing. For example, AndroidDriver, iPhoneDriver |
Listener Support | Selenium IDE doesn’t support listeners | Selenium RC doesn’t support listeners | WebDriver supports the implementation of Listeners |
Speed | Selenium IDE is fast as it is plugged in with the web-browser that launches the test. Thus, the IDE and browser communicates directly | Selenium RC is slower than WebDriver as it doesn’t communicates directly with the browser; rather it sends selenese commands over to Selenium Core which in turn communicates with the browser. | WebDriver communicates directly with the web browsers. Thus making it much faster. |
Ans:
Selenium IDE is the simplest and easiest of all the tools within the Selenium Package. Its record and playback feature make it exceptionally easy to learn with minimal acquaintances to any programming language. Selenium IDE is an ideal tool for a naïve user.
Ans:
The locator can be termed as an address that identifies a web element uniquely within the webpage. Thus, to identify web elements accurately and precisely we have different types of locators in Selenium:
Ans:
Assert: Assert command checks whether the given condition is true or false. Let’s say we assert whether the given element is present on the web page or not. If the condition is true then the program control will execute the next test step but if the condition is false, the execution would stop and no further test would be executed.
Verify: Verify command also checks whether the given condition is true or false. Irrespective of the condition being true or false, the program execution doesn’t halt i.e. any failure during verification would not stop the execution and all the test steps would be executed.
Ans:
XPath is used to locate a web element based on its XML path. XML stands for Extensible Markup Language and is used to store, organize and transport arbitrary data. It stores data in a key-value pair which is very much similar to HTML tags. Both being markup languages and since they fall under the same umbrella, XPath can be used to locate HTML elements.
The fundamental behind locating elements using XPath is the traversing between various elements across the entire page and thus enabling a user to find an element with the reference of another element.
Ans:
Single Slash “/” – Single slash is used to create Xpath with absolute path i.e. the xpath would be created to start selection from the document node/start node.
Double Slash “//” – Double slash is used to create Xpath with relative path i.e. the xpath would be created to start selection from anywhere within the document.
Ans:
The problem of same origin policy disallows to access the DOM of a document from an origin that is different from the origin we are trying to access the document.
Origin is a sequential combination of scheme, host, and port of the URL. For example, for a URL http://www.softwaretestinghelp.com/resources/, the origin is a combination of http, softwaretestinghelp.com, 80 correspondingly.
Thus the Selenium Core (JavaScript Program) cannot access the elements from an origin that is different from where it was launched. For Example, if I have launched the JavaScript Program from “http://www.softwaretestinghelp.com”, then I would be able to access the pages within the same domain such as “http://www.softwaretestinghelp.com/resources” or “http://www.softwaretestinghelp.com/istqb-free-updates/”. The other domains like google.com, seleniumhq.org would no more be accessible.
So, In order to handle same origin policy, Selenium Remote Control was introduced.
Ans:
Selenium Grid can be used to execute same or different test scripts on multiple platforms and browsers concurrently so as to achieve distributed test execution, testing under different environments and saving execution time remarkably.
Ans:
Selenium RC and WebDriver, in a combination, are popularly known as Selenium 2.
Selenium RC alone is also referred as Selenium 1.
Ans:
WebDriver
Ans:
The following syntax can be used to launch Browser:
Ans:
The different drivers available in WebDriver are:
Ans:
There are two types of waits available in WebDriver:
Implicit Wait: Implicit waits are used to provide a default waiting time (say 30 seconds) between each consecutive test step/command across the entire test script. Thus, subsequent test step would only execute when the 30 seconds have elapsed after executing the previous test step/command.
Explicit Wait: Explicit waits are used to halt the execution till the time a particular condition is met or the maximum time has elapsed. Unlike Implicit waits, explicit waits are applied for a particular instance only.
Ans:
The user can use sendKeys(“String to be entered”) to enter the string in the textbox.
Syntax:
WebElement username = drv.findElement(By.id(“Email”));
// entering username
username.sendKeys(“sth”);
Ans:
WebDriver facilitates the user with the following methods to check the visibility of the web elements. These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels etc.
Syntax:
isDisplayed():
boolean buttonPresence = driver.findElement(By.id(“gbqfba”)).isDisplayed();
isSelected():
boolean buttonSelected = driver.findElement(By.id(“gbqfba”)).isDisplayed();
isEnabled():
boolean searchIconEnabled = driver.findElement(By.id(“gbqfb”)).isEnabled();
Ans:
Get command is used to retrieve the inner text of the specified web element. The command doesn’t require any parameter but returns a string value. It is also one of the extensively used commands for verification of messages, labels, errors etc displayed on the web pages.
Syntax:
String Text = driver.findElement(By.id(“Text”)).getText();
Ans:
The value in the dropdown can be selected using WebDriver’s Select class.
Syntax:
selectByValue:
Select selectByValue = new Select(driver.findElement(By.id(“SelectID_One”)));
selectByValue.selectByValue(“greenvalue”);
selectByVisibleText:
Select selectByVisibleText = new Select (driver.findElement(By.id(“SelectID_Two”)));
selectByVisibleText.selectByVisibleText(“Lime”);
selectByIndex:
Select selectByIndex = new Select(driver.findElement(By.id(“SelectID_Three”)));
selectByIndex.selectByIndex(2);
Ans:
Following are the navigation commands:
navigate().back() – The above command requires no parameters and takes back the user to the previous webpage in the web browser’s history.
Sample code:
driver.navigate().back();
navigate().forward() – This command lets the user to navigate to the next web page with reference to the browser’s history.
Sample code:
driver.navigate().forward();
navigate().refresh() – This command lets the user to refresh the current web page there by reloading all the web elements.
Sample code:
driver.navigate().refresh();
navigate().to() – This command lets the user to launch a new web browser window and navigate to the specified URL.
Sample code:
driver.navigate().to(“https://google.com”);
Ans:
driver.findElement(By.linkText(“Google”)).click();
The command finds the element using link text and then click on that element and thus the user would be re-directed to the corresponding page.
The above-mentioned link can also be accessed by using the following command.
driver.findElement(By.partialLinkText(“Goo”)).click();
The above command finds the element based on the substring of the link provided in the parenthesis and thus partialLinkText() finds the web element with the specified substring and then clicks on it.
Ans:
An inline frame acronym as iframe is used to insert another document within the current HTML document or simply a web page into a web page by enabling nesting.
Select iframe by id
driver.switchTo().frame(“ID of the frame“);
Locating iframe using tagName
driver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0));
Locating iframe using index
frame(index)
driver.switchTo().frame(0);
frame(Name of Frame)
driver.switchTo().frame(“name of the frame”);
frame(WebElement element)
Select Parent Window
driver.switchTo().defaultContent();
Ans:
findElement(): findElement() is used to find the first element in the current web page matching to the specified locator value. Take a note that only first matching element would be fetched.
Syntax:
WebElement element = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));
findElements(): findElements() is used to find all the elements in the current web page matching to the specified locator value. Take a note that all the matching elements would be fetched and stored in the list of WebElements.
Syntax:
List elementList = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));
Ans:
At times, we may come across elements of same type like multiple hyperlinks, images etc arranged in an ordered or unordered list. Thus, it makes absolute sense to deal with such elements by a single piece of code and this can be done using WebElement List.
Sample Code
// Storing the list
List elementList = driver.findElements(By.xpath("//div[@id='example']//ul//li"));
// Fetching the size of the list
int listSize = elementList.size();
for (int i=0; i<listSize; i++)
{
// Clicking on each service provider link
serviceProviderLinks.get(i).click();
// Navigating back to the previous page that stores link to service providers
driver.navigate().back();
}
Ans:
close(): WebDriver’s close() method closes the web browser window that the user is currently working on or we can also say the window that is being currently accessed by the WebDriver. The command neither requires any parameter nor does it return any value.
quit(): Unlike close() method, quit() method closes down all the windows that the program has opened. Same as close() method, the command neither requires any parameter nor does is return any value.
Ans:
Selenium is an automation testing tool which supports only web application testing. Therefore, windows pop up cannot be handled using Selenium.
Ans:
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();
Ans:
Selenium is an automation testing tool which supports only web application testing, that means, it doesn’t support testing of windows based applications. However Selenium alone can’t help the situation but along with some third-party intervention, this problem can be overcome. There are several third-party tools available for handling window based pop-ups along with the selenium like AutoIT, Robot class etc.
Ans:
//verify the title of the web page
assertTrue(“The title of the window is incorrect.”,driver.getTitle().equals(“Title of the page”));
Ans:
WebDriver offers a wide range of interaction utilities that the user can exploit to automate mouse and keyboard events. Action Interface is one such utility which simulates the single user interactions.
Thus, In the following scenario, we have used Action Interface to mouse hover on a drop down which then opens a list of options.
Sample Code:
// Instantiating Action Interface
Actions actions=new Actions(driver);
// howering on the dropdown
actions.moveToElement(driver.findElement(By.id("id of the dropdown"))).perform();
// Clicking on one of the items in the list options
WebElement subLinkOption=driver.findElement(By.id("id of the sub link"));
subLinkOption.click();
Ans:
The values of the css properties can be retrieved using a get() method:
Syntax:
driver.findElement(By.id(“id“)).getCssValue(“name of css attribute”);
driver.findElement(By.id(“id“)).getCssValue(“font-size”);
Ans:
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class CaptureScreenshot {
WebDriver driver;
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
driver.get("https://google.com");
}
@After
public void tearDown() throws Exception {
driver.quit();
}
@Test
public void test() throws IOException {
// Code to capture the screenshot
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Code to copy the screenshot in the desired location
FileUtils.copyFile(scrFile, new File("C:\\CaptureScreenshot\\google.jpg"))
}
}
Ans:
Junit is a unit testing framework introduced by Apache. Junit is based on Java.
Ans:
Following are the JUnit Annotations:
@Test: Annotation lets the system know that the method annotated as @Test is a test method. There can be multiple test methods in a single test script.
@Before: Method annotated as @Before lets the system know that this method shall be executed every time before each of the test methods.
@After: Method annotated as @After lets the system know that this method shall be executed every time after each of the test method.
@BeforeClass: Method annotated as @BeforeClass lets the system know that this method shall be executed once before any of the test methods.
@AfterClass: Method annotated as @AfterClass lets the system know that this method shall be executed once after any of the test methods.
@Ignore: Method annotated as @Ignore lets the system know that this method shall not be executed.
Ans:
TestNG is an advanced framework designed in a way to leverage the benefits by both the developers and testers. With the commencement of the frameworks, JUnit gained an enormous popularity across the Java applications, Java developers and Java testers with remarkably increasing the code quality. Despite being easy to use and straightforward, JUnit has its own limitations which give rise to the need of bringing TestNG into the picture. TestNG is an open source framework which is distributed under the Apache Software License and is readily available for download.
TestNG with WebDriver provides an efficient and effective test result format that can, in turn, be shared with the stakeholders to have a glimpse on the product’s/application’s health thereby eliminating the drawback of WebDriver’s incapability to generate test reports. TestNG has an inbuilt exception handling mechanism which lets the program to run without terminating unexpectedly.
There are various advantages that make TestNG superior to JUnit. Some of them are:
Ans:
Setting Priority in TestNG
Code Snippet
package TestNG;
import org.testng.annotations.*;
public class SettingPriority {
@Test(priority=0)
public void method1() {
}
@Test(priority=1)
public void method2() {
}
@Test(priority=2)
public void method3() {
}
}
Test Execution Sequence:
Method1
Method2
Method3
Ans:
The framework is a constructive blend of various guidelines, coding standards, concepts, processes, practices, project hierarchies, modularity, reporting mechanism, test data injections etc. to pillar automation testing.
Ans:
The advantage of Test Automation framework
Ans:
Below are the different types of frameworks:
Module Based Testing Framework: The framework divides the entire “Application Under Test” into the number of logical and isolated modules. For each module, we create a separate and independent test script. Thus, when these test scripts taken together builds a larger test script representing more than one module.
Library Architecture Testing Framework: The basic fundamental behind the framework is to determine the common steps and group them into functions under a library and call those functions in the test scripts whenever required.
Data Driven Testing Framework: Data Driven Testing Framework helps the user segregate the test script logic and the test data from each other. It lets the user store the test data into an external database. The data is conventionally stored in “Key-Value” pairs. Thus, the key can be used to access and populate the data within the test scripts.
Keyword Driven Testing Framework: The Keyword Driven testing framework is an extension to Data-driven Testing Framework in a sense that it not only segregates the test data from the scripts, it also keeps the certain set of code belonging to the test script into an external data file.
Hybrid Testing Framework: Hybrid Testing Framework is a combination of more than one above mentioned frameworks. The best thing about such a setup is that it leverages the benefits of all kinds of associated frameworks.
Behavior Driven Development Framework: Behavior Driven Development framework allows automation of functional validations in easily readable and understandable format to Business Analysts, Developers, Testers, etc.
Ans:
Test data can efficiently be read from excel using JXL or POI API. See detailed tutorial here.
Ans:
WebDriver cannot test Mobile applications. WebDriver is a web-based testing tool, therefore applications on the mobile browsers can be tested.
Ans:
No, captcha and barcode reader cannot be automated.
Ans:
Object Repository is a term used to refer to the collection of web elements belonging to Application Under Test (AUT) along with their locator values. Thus, whenever the element is required within the script, the locator value can be populated from the Object Repository. Object Repository is used to store locators in a centralized location instead of hardcoding them within the scripts.
In Selenium, objects can be stored in an excel sheet which can be populated inside the script whenever required.
That’s all for now.
Ans:
Selenium is a suite of tools for automated web testing. It is composed of
Selenium IDE (Integrated Development Environment) : It is a tool for recording and playing back. It is a firefox plugin
WebDriver and RC: It provide the APIs for a variety of languages like Java, .NET, PHP, etc. With most of the browsers Webdriver and RC works.
Grid: With the help of Grid you can distribute tests on multiple machines so that test can be run parallel which helps in cutting down the time required for running in browser test suites
Ans:
Selenium 3.0 is the latest version of Selenium. It has released 2 beta versions of selenium 3.0 with few of the below changes:
Here are few new features added to Selenium 3.0
Beta 1 updates | Beta 2 updates (Only for Java) |
|
|
|
|
|
|
Ans:
In Selenium every object or control in a web page is referred as an elements, there are different ways to find an element in a web page they are
Ans:
For web based application testing selenium can be used
The test types can be supported are
For post release validation with continuous integration automation tool could be used
Ans:
Assertion is used as a verification point. It verifies that the state of the application conforms to what is expected. The types of assertion are “assert” , “verify” and “waifFor”.
Ans:
X-Path is used to find the WebElement in web pages. It is also useful in identifying the dynamic elements.
Refer Complete Guide on XPath
Ans:
Single slash ( / ) start selection from the document node
It allows you to create ‘absolute’ path expressions
Double Slash ‘// ’
Double slash ( // ) start selection matching anywhere in the document
It enables to create ‘relative’ path expressions
Ans:
Selenium supports only web based applications
It does not support the Bitmap comparison
For any reporting related capabilities have to depend on third party tools
No vendor support for tool compared to commercial tools like HP UFT
As there is no object repository concept in Selenium, maintainability of objects becomes difficult
Ans:
TypeKeys() will trigger JavaScript event in most of the cases whereas .type() won’t. Type key populates the value attribute using JavaScript whereas .typekeys() emulates like actual user typing
Ans:
Assert: 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. In other words, the test will terminated at the point where check fails.
Verify: 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.
Ans:
In JAVA a special form of syntactic meta-data can be added to Java source code, this is know as Annotations. Variables, parameters, packages, methods and classes are annotated some of the Junit annotations which can be useful are
Ans:
To click on specific part of element, you would need to use clickAT command. ClickAt command accepts element locator and x, y co-ordinates as arguments- clickAt (locator, cordString)
Ans:
It supports C#, PHP, Java, Perl, Phython
It supports different OS like Windows, Linux and Mac OS
It has got powerful methods to locate elements (Xpath, DOM , CSS)
It has highly developer community supported by Google
Ans:
Selenium is an open source whereas QTP is a commercial tool
Selenium is used specially for testing web based applications while QTP can be used for testing client server application also
Selenium supports Firefox, IE, Opera, Safari on operating systems like Windows, Mac, Linux etc. however QTP is limited to Internet Explorer on Windows.
Selenium supports many programming languages like Ruby, Perl, Python whereas QTP supports only VB script
Ans:
Ans:
Both will delay the speed of execution.
Thread.sleep () : It will stop the current (java) thread for the specified period of time. Its done only once
It takes a single argument in integer format
Ex: thread.sleep(2000)- It will wait for 2 seconds
It waits only once at the command given at sleep
SetSpeed () : For specific amount of time it will stop the execution for every selenium command.
It takes a single argument in integer format
Ex: selenium.setSpeed(“2000”)- It will wait for 2 seconds
Runs each command after setSpeed delay by the number of milliseconds mentioned in set Speed
This command is useful for demonstration purpose or if you are using a slow web application
Ans:
The “Same Origin Policy” is introduced for security reason, and it ensures that content of your site will never be accessible by a script from another site. As per the policy, any code loaded within the browser can only operate within that website’s domain.
To avoid “Same Origin Policy” proxy injection method is used, in proxy injection mode the Selenium Server acts as a client configured HTTP proxy , which sits between the browser and application under test and then masks the AUT under a fictional URL
Ans:
The purpose of heightened privileges is similar to Proxy Injection, allows websites to do something that are not commonly permitted. The key difference is that the browsers are launced in a special mode called heightened privileges. By using these browser mode, Selenium core can open the AUT directly and also read/write its content without passing the whole AUT through the Selenium RC server.
Ans:
You can use “submit” method on element to submit form-
element.submit () ;
Alternatively you can use click method on the element which does form submission
Ans:
TestNG is a testing framework based on JUnit and NUnit to simplify a broad range of testing needs, from Unit Testing to Integration Testing. And the functionality which makes it efficient testing framework are
Ans:
Implicit Wait: Sets a timeout for all successive Web Element searches. For the specified amount of time it will try looking for element again and again before throwing a NoSuchElementException. It waits for elements to show up.
Explicit Wait : It is a one-timer, used for a particular search.
Ans:
You can use…..driver.findElements(By.xpath(“//iframe”))….
This will return list of frames.
You will ned to switch to each and every frame and search for locator which we want.
Then break the loop
Ans:
find element (): It finds the first element within the current page using the given “locating mechanism”. It returns a single WebElement
findElements () : Using the given “locating mechanism” find all the elements within the current page. It returns a list of web elements.
Ans:
The JUnits annotation linked with Selenium are
@Before public void method() – It will perform the method () before each test, this method can prepare the test
@Test public void method() – Annotations @Test identifies that this method is a test method environment
@After public void method()– To execute a method before this annotation is used, test method must start with test@Before
Ans:
Datadriven framework: In this framework, the test data is separated and kept outside the Test Scripts, while Test Case logic resides in Test Scripts. Test data is read from the external files ( Excel Files) and are loaded into the variables inside the Test Script. Variables are used for both for input values and for verification values.
Keyworddriven framework: The keyword driven frameworks requires the development of data tables and keywords, independent of the test automation. In a keyword driven test, the functionality of the application under test is documented in a table as well as step by step instructions for each test.
Ans:
Pass the username and password with url
Syntax-http://username:password@url
ex- http://creyate:tom@www.gmail.com
Ans:
WebElement el = driver.findElement(By.id(“ElementID”))
//get test from element and stored in text variable
String text = el.getText();
//assert text from expected
Assert.assertEquals(“Element Text”, text);
Ans:
Silk Test Tool
Borland Silk test is not a free testing tool
Silk test supports only Internet Explorer and Firefox
Silk test uses test scripting language
Silk test can be used for client server applications
Selenium Test Tool
Selenium is completely free test automation tool
Selenium supports many browsers like Internet Explorer, Firefox, Safari, Opera and so on
Selenium suite has the flexibility to use many languages like Java, Ruby,Perl and so on
Selenium can be used for only web application
Ans:
Selenium Grid sent the tests to the hub. These tests are redirected to Selenium Webdriver, which launch the browser and run the test. With entire test suite, it allows for running tests in parallel.
Ans:
Yes. But not as effectively as a dedicated Performance Testing tool like Loadrunner.
Ans:
If you are using Selenium-WebDriver, you don’t need the Selenium Server as it is using totally different technology
Selenium Server provides Selenium RC functionality which is used for Selenium 1.0 backwards compatibility
Selenium Web driver makes direct calls to browser using each browsers native support for automation, while Selenium RC requires selenium server to inject Javascript into the browser
Ans:
WebDriver should be used when requiring improvement support for
Handling multiple frames, pop ups , multiple browser windows and alerts
Page navigation and drag & drop
Ajax based UI elements
Multi browser testing including improved functionality for browser not well supported by Selenium 1.0
Ans:
Major limitation of injecting capabilities is that “findElement” command may not work as expected.
Ans:
To find the broken images in a page using Selenium web driver is
Ans:
To handle colors in web driver you can use
Use getCssValue(arg0) function to get the colors by sending ‘color’ string as an argument
Ans:
You can use following command to store a value which is text box using web driver
driver.findElement(By.id(“your Textbox”)).sendKeys(“your keyword”);
Ans:
To switch between frames webdrivers [ driver.switchTo().frame() ] method takes one of the three possible arguments
A number: It selects the number by its (zero-based) index
A number or ID: Select a frame by its name or ID
Previously found WebElement: Using its previously located WebElement select a frame
Ans:
The 5 different exceptions you had in Selenium web drivers are
Ans:
You can perform double click by using
Syntax- Actions act = new Actions (driver);
act.doubleClick(webelement);
Ans:
You can use “type”command to type in a file input box of upload file. Then, you have to use “Robot” class in JAVA to make file upload work.
Ans:
HTMLUnit Driver implementation is fastest, HTMLUnitDriver does not execute tests on browser but plain http request, which is far quick than launching a browser and executing tests
Ans:
To bring control on HTML frame you can use “SwitchTo” frame method-
driver.switchTo().frame(“frameName”);
To specify a frame you can use index number
driver.switchTo().frame(“parentFrame.4.frameName”);
This would bring control on frame named- “frameName” of the 4th sub frame names “parentFrame”
Ans:
getwindowhandles(): It is used to get the address of all the open browser and its return type is Set
getwindowhandle(): It is used to get the address of the current browser where the control is and return type is string
Ans:
To switch back from a frame use method defaultContent()
Syntax-driver.switchTo().defaultContent();
Ans:
Different types of locators are
Ans:
In order to display a constant string, command can be used is echo
If order to display the value of a variable you can use command like echo ${variable name>>
Above is using PHP. If you are using Java, replace echo with System.out.println
Ans:
Recovery scenarios depends upon the programming language you use. If you are using Java then you can use exception handling to overcome same. By using “Try Catch Block” within your Selenium WebDriver Java tests
Ans:
To iterate through options in test script you can loop features of the programming language, for example to type different test data in a text box you can use “for” loop in Java
// test data collection in an array
String[ ] testData = { “test1” , “test2” , “test3” } ;
// iterate through each test data
For (string s: test data) { selenium.type ( “elementLocator”, testData) ; }
Ans:
There are three ways
Junit: With the help of ANT
TestNG: Using inbuilt default.html to get the HTML report. Also XST reports from ANT, Selenium, Testng combinations
Using our own customized reports using XSL jar for converting XML content to HTML
Ans:
To create html test report there are three ways
TestNG: Using inbuilt default.html to get the HTML report. Also XLST reports from ANT, Selenium, TestNG combination
JUnit: With the help of ANT
Using our own customized reports using XSL jar for converting XML content to HTML
Ans:
In Selenium IDE to insert a break point
Select “Toggle break point” by right click on the command in Selenium IDE
Press “B” on the keyboard and select the command in Selenium IDE
Multiple break points can be set in Selenium IDE
Ans:
Selenese is a selenium set of command which are used for running the test
There are three types of Selenese
Actions: It is used for performing the operations and interactions with the target elements
Assertions: It is used as a check points
Accessors: It is used for storing the values in a variable
Ans:
The limitations of Selenium IDE
Ans:
Either Selenium IDE can be opened as a pop up window or in side bar
Ans:
In selenium there are mainly 4 locators that are used
Ans:
In Selenium IDE you can generate random numbers by using Java Script
type
css=input#s
javascript{Math.random()}
And for
type
css=input#s
javascript{new Date()}
Ans:
You can use the format option of Selenium IDE to convert tests into another programming language
Ans:
You can use the “storeTable” command
Example store text from cell 0,2 from an html table
storeTable
Css=#table 0.2
textFromCell
Ans:
When a locator has changed and Selenium IDE cannot locate the element
When element Selenium IDE waiting to access did not appear on the web page and the operation timed out
When element Selenium IDE was trying to access was not created
Ans:
Insert a break point from the location where you want to execute step by step
Run the test case
At the given break point execution will be paused
To continues with the next step click on the Blue button
To run commands at a time click on run button
Ans:
From Selenium IDE single line command can be executed in two ways
Ans:
In Selenium IDE source view shows your script in XML format
Ans:
In two ways selenium IDE can be set
Press “S” key on the keyboard and select the command in Selenium IDE
In Seleniun IDE right click on the command and the select “Set / Clear Start Point”
Ans:
To test the locator one can use “Find Button” of Selenium IDE, as you click on it, you would see on screen an element being highlighted provided your element locator is right or or else an error message will be displayed
Ans:
A regular expression is a special text string used for describing a search pattern. In Selenium IDE regular expression can be used with the keyword- regexp: as a prefix to the value and patterns needs to be included for the expected values.
Ans:
If you want to “extend” the defualt functionality provided by Selenium Function Library , you can create a Core Extension. They are also called “User Extension”. You can even download ready-made Core Extension created by other Selenium enthusiats.
Ans:
You can use verifyElementPositionLeft & verifyElementPositionTop. It does a pixel comparison of the position of the element from the Left and Top of page respectively
Ans:
You can use the storeAlert command which will fetch the message of the alert pop up and store it in a variable.
Ans:
Selenium IDE have limitations in terms of browser support and language support. By using Selenium RC limitation can be diminished.
On different platforms and different web browser for automating web application selenium RC is used with languages like Java, C#, Perl, Python
Selenium RC is a java based and using any language it can interact with the web application
Using server you can bypass the restriction and run your automation script running against any web application
Ans:
Selenium IDE does not directly support many functions like condition statements, Iteration, logging and reporting of test results, unexpected error handling and so on as IDE supports only HTML language. To handle such issues Selenium RC is used it supports the language like Perl, Ruby, Python, PHP using these languages we can write the program to achieve the IDE issues.
Ans:
The main difference between Selenium RC and Webdriver is that, selenium RC injects javascript function into browsers when the page is loaded. On the other hand, Selenium Webdriver drives the browser using browsers built in support
Ans:
Advantages of RC are
Ans:
A collection of libraries and classes is known as Framework and they are helpful when testers has to automate test cases. NUnit, JUnit, TestNG, Bromine, RSpec, unittest are some of the frameworks available in RC .
Ans:
To handle pop-ups in RC , using selectWindow method, pop-up window will be selected and windowFocus method will let the control from current window to pop-up windows and perform actions according to script
Ans:
Apart from “same origin policy” restriction from js, Selenium is also restricted from exercising anything that is outside browser.
Ans:
Yes, it is possible when you are not using JAVA testing framework. Instead of using Java testing framework if you are using java client driver of selenium then TestNG allows you to do this. By using “parallel=test” attribute you can set tests to be executed in parallel and can define two different tests, each using different browser.
Ans:
If you want full automation against different server and client platforms, You need a way to invoke the tests from a command line process, reports that tells you what happened and flexibility in how you create your test suites. TestNG gives that flexibility.
Ans:
To capture server side log in Selenium Server, you can use command
java –jar .jar –log selenium.log
Ans:
You can run Selenium server on java-jar selenium-server.jar-port other than its default port
Ans:
At predefined time selenium grid hub keeps polling all RC slaves to make sure it is available for testing. The deciding parameter is called “remoteControlPollingIntervalSeconds” and is defined in “grid_configuration.yml”file
Ans:
To handle network latency you can use driver.manage.pageloadingtime for network latency
Ans:
To enter values onto text boxes we can use command sendkeys()
Ans:
To identify an object using Selenium you can use
isElementPresent(String locator)
isElementPresent takes a locator as the argument and if found returns a Boolean
Ans:
Breakpoints: When you implement a breakpoint in your code, the execution will stop right there. This helps you to verify that your code is working as expected.
StartpointsStartpoint indicates the point from where the execution should begin. Startpoint can be used when you want to run the testscript from the middle of the code or a breakpoint.
Ans:
Few points that favor Python over Java to use with Selenium is,
Ans:
The challenges faced in Handling Ajax Call in Selenium Webdriver are
Ans:
Intellij is an IDE that helps you to write better and faster code for Selenium. Intellij can be used in the option to Java bean and Eclipse.
Ans:
You can customize TestNG report in two ways,
Ans:
To generate pdf reports, you need Java API IText.
Ans:
In Selenium WebDriver, Listeners “listen” to the event defined in the selenium script and behave accordingly. It allows customizing TestNG reports or logs. There are two main listeners i.e. WebDriver Listeners and TestNG Listeners.
Ans:
The types of Listeners in TestNG are,
Ans:
The desired capability is a series of key/value pairs that stores the browser properties like browser name, browser version, the path of the browser driver in the system, etc. to determine the behavior of the browser at run time.
For Selenium,
It can be used to configure the driver instance of Selenium WebDriver.
When you want to run the test cases on a different browser with different operating systems and versions.
Ans:
For Database Testing in Selenium Webdriver, you need JDBC (Java Database Connectivity) API. It allows you to execute SQL statements.
Ans:
Selenium is designed to automate web-based applications on different browsers. But to handle window GUI and non-HTML popups in the application you need AutoIT. know more about How to use AutoIT with Selenium
Ans:
While working with Selenium, you need Session Handling. This is because, during test execution, the Selenium WebDriver has to interact with the browser all the time to execute given commands. At the time of execution, it is also possible that, before current execution completes, someone else starts execution of another script, in the same machine and in the same type of browser. So to avoid such situation you need Session Handling.
Ans:
The advantages of Using Git Hub for Selenium are
In this software era doesn't matter you are working on php,java or .net, everywhere there…
Here we have mentioned most frequently asked IT Fresher Interview Questions and Answers specially for…
Here we have mentioned most frequently asked Github Interview Questions and Answers specially for freshers…
In this software era doesn't matter you are working on php,java or .net, everywhere there is demand frontend software (such…
Here we have mentioned most frequently asked IT Fresher Interview Questions and Answers specially for freshers and experienced. 1. What…
Here we have mentioned most frequently asked Github Interview Questions and Answers specially for freshers and experienced. 1. What is…
Here we have mentioned most frequently asked HTML5 Interview Questions and Answers specially for freshers and experienced. 1. What is…
Here we have mentioned most frequently asked Geography Interview Questions and Answers specially for freshers and experienced. 1. What is…
Here we have mentioned most frequently asked JSP Interview Questions and Answers specially for freshers and experienced. 1. Explain JSP…
This website uses cookies.