CSC – Selenium Interview Questions
Here is the list of Selenium Interview Questions which are recently asked in CSC company. These questions are included for both Freshers and Experienced professionals. Our Selenium Training has Answered all the below Questions.
1. Explain the Framework you used in Selenium.
We need to specify in and out of our Test Automation Framework such as programming language used, Type of framework used, Test Base Class. How we separate Element locators and tests, Utility functions file, Property files, TestNG annotations.
Also, How we parameterize tests using Excel files, How we capture error screenshots, Generating reports (Extent Reports), Emailing reports, Version Control System used and Continues Integration Tool used.
2. Configuration and Execution of testcases using Selenium/Maven/TestNG/Jenkins.
Test cases are defined as an action or event and an expected response to describe an software application feature.
Jenkin’s chief usage is to monitor any job which can be SVN checkout, cron or any application states. It fires pre-configured actions when a particular step occurs in jobs.
Selenium WebDriver is great for browser automation. But, when using it for testing and building a test framework, it feels underpowered.
Additionally, we need add m2eclipse plugin to Eclipse to facilitate the build process and create pom.xml file.
3. How to find the nearest element to a given element using xpath?
The below code is used to find the nearest element to a given element using xpath
Use the below code for find the nearest element to a given element using xpath,
//td[label[@for=’PropertyA’]]/following-sibling::td[1]
4. How will you trigger an event in Selenium?
The below is the code to trigger an event in Selenium,
public class Website extends SeleneseTestBase {
@BeforeMethod
public void eard() throws Exception {
selenium = new DefaultSelenium(“localhost”, 4444, “*chrome”, “http://www.washingtonpost.com/”);
selenium.start();
}
@Test
public void testWebsite() throws Exception {
selenium.open(“/”);
waitFor(“link=Sign In”);
waitSecomd(3);
selenium.click(“link=Sign In”);
selenium.waitForPageToLoad(“60000”);
selenium.type(“name=MemberName”, “adasf@gmail.com”);
selenium.type(“name=Password”, “adfasd”);
selenium.click(“name=submit”);
selenium.waitForPageToLoad(“60000”);
}
@AfterMethod
public void eardown() throws Exception {
selenium.stop();
}
public void waitFor(String locator) throws Exception {
for (int second = 0;; second++) {
if (second >= 60)
fail(“timeout”);
try {
if (selenium.isVisible(locator))
break;
} catch (Exception e) {}
Thread.sleep(1000);
}
}
public void waitSecomd(int n) throws Exception {
for (int second = 0;; second++) {
if (second >= 60)
fail(“timeout”);
try {
if (second > n – 1)
break;
} catch (Exception e) {}
Thread.sleep(1000);
}
}
}
5. How will you parameterize data in Selenium webdriver?
Selenium has no built in support to execute a test case, or collection of test cases, or ability to execute a parameterized test case. Selenium is simply a framework to interact with a web UI. The test execution engine you use to actually kick off your selenium tests varies depending on which language you are using, and even for a specific language there are often multiple competing test execution engines.
For example, with Java some popular choices are Junit and TestNG. For C#, popular choices are Nunit and MSTest. There are other options for ruby, python, etc.
6. TestNG data parameterization using excel.
TestNG data parameterization using excel, When you need to pass complex parameters or parameters that need to be created from in such cases parameters can be passed using Dataproviders. A Data Provider is a method annotated with @DataProvider. A Data Provider returns an array of objects.
7.Format of testng.xml and maven pom.xml.
You have to add the esting dependency instead the junit dependency. So remove the junit dependency and add the esting dependency accordingly to the documentation of the maven-surefire-plugin.
8. How will you take snapshot with Selenium Grid?
The below is the code to take snapshot with Selenium Grid Syntax:
File file = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
String screenshotBase64 = ((TakesScreenshot)driver).getScreenshotAs(OutputType.BASE64);
9. How can we handle window UI elements and window POP ups using selenium?
Below methods are used to handle window elements,
Driver. getWindowHandles();
Driver. getWindowHandle();
10. What is actions class in WebDrive
Selenium has been widely used in automating web applications as it stands out from other testing tools by providing numerous ways to test those applications. No matter how complex the UI is, Selenium provides multiple options to automate it thereby reducing or completely wiping away the manual effort.
When it comes to testing Windows-based applications or any standalone applications, we have different tools like QTP/UFT which perform user actions in the window handles.
11. What is WebDriverBackedSelenium?
One can use WebDriverBackedSelenium for migrating Selenium 1.0(Selenium RC) to webDriver tests.
Steps to be followed for migration:
Execute existing RC script with latest Selenium release to eliminate application/ script issues.
12. Which is the package which is to be imported while working with WebDriver?
13. What is the difference b/w close () and quit ()?
Close() | Quit () |
---|---|
It is best to use driver.close() when we are dealing with multiple browser tabs or windows | The driver.quit() is used to quit the whole browser session along with all the associated browser windows, tabs and pop-ups. |
close() method closes the active WebDriver instance. | quit() method closes all the active WebDriver instances. |
Free PDF : Get our updated Selenium Course Content pdf
14. Consider there are 6 methods in your class, you need to run the first three in sequential order and next three in parallel.How will you do it using testing?�
15. Consider there are two elements in a page with same id.How will you locate it?
16. You need to identify a element inside a frame and then you need to click on the element/link outside the frame.Write a code for this.
WebDriver driver = new ChromeDriver();
driver.get("https:// url containing i-frames/");
//By finding all the web elements using iframe tag
List iframeElements = driver.findElements(By.tagName("iframeResult"));
System.out.println("Total number of iframes are " + iframeElements.size());
//By executing a java script
JavascriptExecutor exe = (JavascriptExecutor) driver;
Integer noOfFrames = Integer.parseInt(exe.executeScript("return window.length").toString());
System.out.println("No. of iframes on the page are " + numberOfFrames);
17. What is Encapsulation?
Encapsulation in Java is a process of wrapping code and data together into a single unit, for example, a capsule which is mixed of several medicines.
It provides you the control over the data. Suppose you want to set the value of id which should be greater than 100 only, you can write the logic inside the setter method. You can write the logic not to store the negative numbers in the setter methods.
18. Difference between overloading and overriding
The difference between overloading and overriding below,Overloading | Overriding |
---|---|
Method overloading is performed within class. | Method overriding occurs in two classes that have IS-A (inheritance) relationship. |
In case of method overloading, parameter must be different. | In case of method overriding, parameter must be same. |
Method overloading is used to increase the readability of the program. | Method overriding is used to provide the specific implementation of the method |
19. How will you prevent a method from overriding?
Method overriding works because of the run-time method binding feature in Java. So, if we force the java compiler to do static binding for a method then we can prevent that method from being overridden in a derived class.
20. Difference between JDK and JRE. Which one of them is platform dependnet?
1. JDK
Java Development Kit aka JDK is the core component of Java Environment and provides all the tools, executables, and binaries required to compile, debug, and execute a Java Program.
JDK is a platform-specific software and that’s why we have separate installers for Windows, Mac, and Unix systems.
We can say that JDK is the superset of JRE since it contains JRE with Java compiler, debugger, and core classes.
2. JVM
JVM is the heart of Java programming language. When we execute a Java program, JVM is responsible for converting the byte code to the machine-specific code.
JVM is also platform-dependent and provides core java functions such as memory management, garbage collection, security, etc.
JVM is customizable and we can use java options to customize it. For example, allocating minimum and maximum memory to JVM.
21. Inheritance with example. – Can secondary subclass can inherits the methods and variables of super class?
// Java program to illustrate the
// concept of inheritance
// base class
class Bicycle {
// the Bicycle class has two fields
public int gear;
public int speed;
// the Bicycle class has one constructor
public Bicycle(int gear, int speed)
{
this.gear = gear;
this.speed = speed;
}
// the Bicycle class has three methods
public void applyBrake(int decrement)
{
speed -= decrement;
}
public void speedUp(int increment)
{
speed += increment;
}
// toString() method to print info of Bicycle
public String toString()
{
return ("No of gears are " + gear + "\n"
+ "speed of bicycle is " + speed);
}
}
// derived class
class MountainBike extends Bicycle {
// the MountainBike subclass adds one more field
public int seatHeight;
// the MountainBike subclass has one constructor
public MountainBike(int gear, int speed,
int startHeight)
{
// invoking base-class(Bicycle) constructor
super(gear, speed);
seatHeight = startHeight;
}
// the MountainBike subclass adds one more method
public void setHeight(int newValue)
{
seatHeight = newValue;
}
// overriding toString() method
// of Bicycle to print more info
@Override public String toString()
{
return (super.toString() + "\nseat height is "
+ seatHeight);
}
}
// driver class
public class Test {
public static void main(String args[])
{
MountainBike mb = new MountainBike(3, 100, 25);
System.out.println(mb.toString());
}
}
22. What are the limitations of Selenium?
- Selenium cannot extend support to the Windows applications, it only works on the web based applications.
- Selenium is not capable of performing mobile automation on its own.
- Selenium does not have any inbuilt reporting feature.
- Selenium is not accurate while dealing with handling dynamic web elements.
- Selenium has challenges handling frames and pop ups.
- Selenium has enormous timeout, sync and page load issues.
- Selenium does not automate captcha.
23. Why should Selenium be selected as a test tool?
There are many reasons that Selenium be selected as a test tool:-
1. Selenium is a pure and open-source, freeware and portable tool.
2. It supports a variety of languages that include Java, Perl, Python, C#, Ruby, Groovy, JavaScript, and VB Script. etc.
3. There are many operating systems which is being supported by Selenium like Windows, Macintosh, Linux, Unix etc.
4. Browsers like Internet Explorer, Chrome, Firefox, Opera, Safari etc are being supported by Selenium
24. What is an Xpath?
XPath uses path expressions to select nodes or node-sets in an XML document.
These path expressions look very much like the path expressions you use with traditional computer file systems:
25. What are the Drawbacks of Selenium IDE
The drawbacks of Selenium IDE are listed below,- Overhead and upkeep
- No data-driven scripts
- No built-in reporting capabilities
- No technical support
26. Why should testers opt for Selenium and not QTP?
The important points to note down to know why testers opt for Selenium and not QTP.
The main advantage of Selenium over QTP is Selenium is a free tool while as QTP is a paid tool and thus organizations are giving more importance to Selenium over QTP . However, there are various other differences as well between the two
Book a Free Mock Interviews and Test your Selenium skills with our Experts
TOP MNC's SELENIUM INTERVIEW QUESTIONS & ANSWERS
Here we listed all Selenium Interview Questions and Answers which are asked in Top MNCs. Periodically we update this page with recently asked Questions, please do visit our page often and be updated in Selenium.
Related Blogs
To become a Selenium Certified professional and join in your dream company, Enroll now for our Best Selenium Training. We help you to crack any levels of Selenium Interviews and We offering Selenium Training with Placement Assistance.