Photon infotech – Selenium Interview Questions
Here is the list of Selenium Interview Questions which are recently asked in Photon infotech company. These questions are included for both Freshers and Experienced professionals. Our Selenium Training has Answered all the below Questions.
1. What is Constructor in Java
You can define constructor in the general class. The name of the constructor and class name should be same. The syntax of the constructor resembles a method. So, it is defined a specialized method. However, it doesn’t have a return type(not even void).
The scope of the main class and general class is different. So, to execute a constructor we have to create a object of the general class into the main class.
2. Method over riding
Method over riding is declaring a method in sub class which is already present in parent class. Overriding is done so here a child class can give its own implementation to a method which is already provided by the parent class.
The method in parent class is called overridden method and the method in child class is called overriding method.
3. Why constructor used?
First of all, Constructor is a block of code that initializes the newly created object. A constructor resembles an instance method in java but it’s not a method as it doesn’t have a return type. In this case constructor and method are different. Everyone often refer constructor as special type of method in Java.
Construtor name and class name are same here,
public class MyClass{
//constructor
MyClass(){
}
..
4. Interface and abstract class
Abstract class | Interface |
---|---|
abstract and non-abstract methods. | only abstract methods. In Java 8, it can have default and static methods also. |
It doesn't support multiple inheritance. | It supports multiple inheritance. |
Can have data fields | Cannot have data fields |
Its very faster than the interface | Interface is slower and requires extra indirection or dereferencing |
Here, Abstract methods only | Both Abstract and concrete methods |
The keyword is extends. | The keyword is implements. |
Abstract class members are private, protected, etc. | Members of a Java interface are public by default. |
5. How to select value in a drop-down?
The two things for Selecting value in drop down,
- Import the package org.openqa.selenium.support.ui.Select
- Instantiate the drop-down box as an object, Select in Selenium WebDriver
6. How to handle frame in WebDriver?
The following methods are used to handle frame in Web driver,
- switchTo().frame( frameNumber)
- switchTo().frame( frameName)
- switchTo().frame( WebElement)
7. What are the different types of frameworks?
Testing Frameworks types are,- Linear Scripting Framework
- Modular Testing Framework
- Library Architecture Testing Framework
- Data-driven Testing Framework
- Keyword Driven Testing Framework
- Hybrid Testing Framework
- Behavior Driven Development Testing Framework
8. When should I use Selenium Grid?
The Selenium Grid is used by executing different versions of browsers simultaneously.Also, the Selenium Grid is used by executing different versions of OS simultaneously.
If we have Selenium enabled machines in 5 such machines and we have 100 test cases the execution time is reduced by 5 times. Hence it increases the batch processing time.
9. Which is the latest Selenium tool?
The latest Selenium tool is Selenium 4.0
Free PDF : Get our updated Selenium Course Content pdf
10. Static methods
Static methods are defined by methods in Java that can be called without creating an object of class. They are referenced by the class name itself or reference to the Object of that class
For Example:
public void AnyClassName(Str name)
{
//Execution Code....
}
11. How failure test cases are handled in selenium?
4 Steps to Follow the test cases are handled in selenium,
- To Create testng. xml file under your project folder
- Right click on the testng. xml - Run As - TestNG suite
- Then, test-output folder - testng-failed. xml file will be created
- Finally Right click on testng-failed
12. Why This is used?
Selenium is used to automate the testing across different web browsers. It supports various browsers like Chrome, Mozilla, Firefox, Safari, and IE.
Also, Selenium web driver is very easy to automate different types of web browsers. A toolbox to make the life of a software tester that much easier.
13. TestNG attributes
TestNG attributes are, you can write tests in TestNG, then you will either mark your whole class with the @Test annotation or attach this annotation to every method you will run tests from. Finally it allows for a bit of customization and differentiation among tests, by adding different values to the test attributes.
Test attributes are @Test specific, and are to be specified right next to the @Test annotation.
- Description
- timeOut
- priority
- dependsOnMethods
- enabled
- groups
14. How to type in a textbox using Selenium?
First of all, we need to apply sendKeys() method.Syntax for type in textbox:
driver.findElement(By.id("text-bx")).sendKeys("CredoSystemz")
Code:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class InputTxt{
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\Credo\\Desktop\\Java\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String url = " https://www.credosystemz.com/";
driver.get(url);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
// identify element and input text inside it
WebElement l =driver.findElement(By.className("gsc-input"));
l.sendKeys("Selenium");
driver.quit();
}
}
15. What are the testing types that can be supported by Selenium?
There are two types of testing is supported by Selenium,
- Functional Testing
- FRegression Testing
16. What is Selenese?
The set of selenium commands that are used to test your web application which is called Selenese. The Selenese are used to find the Software tester can test the broken links, existence of some object on the UI, Ajax functionality, Alerts, window, list options, etc.,
Selenium command tells selenium automation engine to perform certain tasks such as Actions, Accessors, Assertions
17.What is an Xpath?
XPath stands for XML Path Language. It contains over 200 built-in functions. In XSLT standard Xpath is the major element also can be used to navigate through elements and attributes in an XML document.
In XML path expression Xpath syntax “path like” is used to find any element on a XML path expression.
18. How to get the number of frames on a page?
The below code can be used to identify the number of frames on a page:
size = driver. findElements(By. tagName("iframe")). size(); // prints the total number of frames
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.