Datacert – Selenium Interview Questions
Here is the list of Selenium Interview Questions which are recently asked in Datacert company. These questions are included for both Freshers and Experienced professionals. Our Selenium Training has Answered all the below Questions.
1. How to switch between frames?
2. How to test a canvas in selenium?
Steps to follow:- The canvas element’s toDataURL() method
- Selenium’s execute_script() method
- Image compare
3. Why can’t we test a flash in selenium?
4. How to get all the links?(optimesed way without using linktext)
The steps to follow all the links present within the page are working. This can be conveniently done using a combination of the Java for-each loop, findElements() & By.tagName("a") method.
5. How to find the duplicate letter in a word?
Use the below code:
public class DuplicateWord {
public static void main(String[] args) {
String string = "Big black bug bit a big black dog on his big black nose";
int count;
//Converts the string into lowercase
string = string.toLowerCase();
//Split the string into words using built-in function
String words[] = string.split(" ");
System.out.println("Duplicate words in a given string : ");
for(int i = 0; i < words.length; i++) {
count = 1;
for(int j = i+1; j < words.length; j++) {
if(words[i].equals(words[j])) {
count++;
//Set words[j] to 0 to avoid printing visited word
words[j] = "0";
}
}
//Displays the duplicate word if count is greater than 1
if(count > 1 && words[i] != "0")
System.out.println(words[i]);
}
}
}
6. From which class the thread.sleep is called?
Refer the below code:
package com.journaldev.threads;
public class ThreadSleep {
public static void main(String[] args) throws InterruptedException {
long start = System.currentTimeMillis();
Thread.sleep(2000);
System.out.println("Sleep time in ms = "+(System.currentTimeMillis()-start));
}
}
7. How to upload a file without autoit?
ROBOT API jars is used to upload the file without autoit.
8. Dom and com ?
COM means Component Object Model is a cross-language programming model for the Microsoft Windows platform based on interfaces inheriting from a common ancestor. It providing a way to create, and then dynamically discover and use various software libraries (the components).
COM is a rather complicated technology to learn, full of pitfalls, and heavily based on the Windows registry and GUIDs
11. What is series of errors 200,300,400?(EG 404 page not found error)
- 200 - If something goes wrong while processing GET
- 300 - Multiple Choices redirect status response code
- 400 - Bad Request response status code
12. Have you used macros,vb scripting?
Yes , I used the both for my project, macros having serious of commands, and vb scripting having lightweight scripting language.
13. Jsexecutor is it a class of interface or method and how it works what is its implementation?
JavaScriptExecutor is an Interface.
Within the script, use the document to refer to the current document. Local variables will not be available once the script has finished executing, though global variables will persist.
14. What are the advantages of Automation framework?
Advantages of Automation Framework:- Automation framework reduces the cost as well and lowers risks also.
- Also, It improves test efficiency.
- Most importantly, lowers the cost of maintenance.
- It maximizes the test coverage and functionality of the application.
- It also defines the reusability of code.
15. How to click on a hyper link using linkText?
Refer the below 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 ClickLinkText{
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("https://www.tutorialspoint.com/about/about_careers.htm");
// identify element with link text then apply click()
WebElement p=driver.findElement(By.linkText("Privacy Policy"));
p.click();
System.out.println("Page title after link click : " + driver.getTitle());
driver.close();
}
}
Free PDF : Get our updated Selenium Course Content pdf
16. What does a double slash in a xpath element means?
Relative xpath starts with double slash. In that case you will be first finding unique parent node and path from there to the element.
17. How to sort (Effecient way) – Not bubble sort.?
Steps to follow
1. First of all, Retrieve the List from HTML Table.
2. Store the List in an Array
3. To use swap, sorting the items in array
Swapping is the process of Exchanging the Values.
4. Click on Sort button in the WebPage.
5. TRetrieve the List again.
6. Finally, Compare the Sorted Array generated in Step 3 with the List generated in Step 5.
18. How to find the linux version?
Use the below code for find the linux version find Linux kernel version: uname -r.
19. String reverse.
// Java program to ReverseString using ByteArray.
import java.lang.*;
import java.io.*;
import java.util.*;
// Class of ReverseString
class ReverseString {
public static void main(String[] args)
{
String input = "Credosystemz";
// getBytes() method to convert string
// into bytes[].
byte[] strAsByteArray = input.getBytes();
byte[] result = new byte[strAsByteArray.length];
// Store result in reverse order into the
// result byte[]
for (int i = 0; i < strAsByteArray.length; i++)
result[i] = strAsByteArray[strAsByteArray.length - i - 1];
System.out.println(new String(result));
}
}
Output:
zmetsysoderc
20. Biggest challenge which you have faced in your automation project and how you over came that?
21. Swap the digits in a number (any scripting language)
/ Java Program to Swap Two values using third variable
// using temp variable
// Importing generic libraries
import java.util.*;
class GFG {
// Finction to swap two numbers
// Using temporary variable
static void swapValuesUsingThirdVariable(int m, int n)
{
// Swapping the values
int temp = m;
m = n;
n = temp;
System.out.println("Value of m is " + m
+ " and Value of n is " + n);
}
// Main driver code
public static void main(String[] args)
{
// Random integerslues
int m = 9, n = 5;
// Calling above function to
// reverse the numbers
swapValuesUsingThirdVariable(m, n);
}
}
Output
Value of m is 5 and Value of n is 9
22. What is the use of java script in application developemtn and what is the need of using java script with selenium?
Javascript is used to makes your webpage interactive. Also, it is text based programming language. It is mainly used for client and server side. HTML, CSS give structure and style to a webpage.
JavaScript offers efficiency with its well built and structured patterns and functions, making the script more compact.
23. What are listeners and what is the use of testNG listener where you have used it in the your frame work?
Listener means the interface that modifies the default TestNG's behavior. Also, Listeners "listen" to the event defined in the selenium script and behave accordingly.Types of Listeners are
- IAnnotationTransformer ,
- IAnnotationTransformer2 ,
- IConfigurable ,
- IConfigurationListener ,
- IExecutionListener,
- IHookable ,
- IInvokedMethodListener ,
- IInvokedMethodListener2 ,
- IMethodInterceptor ,
- IReporter,
- ISuiteListener,
- ITestListener .
24. How to automate dynamically changing objects in selenium?
- Absolute Path method.
- Relative XPath method
- Identify by index
- Use Multiple attributes
25. What is your reporting mechanism?
3 methods to Generate Reports in Selenium:- TestNG HTML Report Generation.
- JUnit-Style Report Generation.
- Generating Extent HTML Reports.
26. Is it possible to integrate bugzilla with selenium for reporting and If yes How to do that?
27. What is OOPS concept – explain?
Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism etc in programming.
The primary purpose of object-oriented programming is to increase the flexibility and maintainability of programs.
28. What is the entry and exit criteria for your automation testing?
Entry Criteria - It means prerequisite items Must be completed before testing can begin
Exit Criteria - the items that must be completed before testing can be concluded.
29. How to estimate time for automation of a functionality/module/application?
Steps to follow:- Explore and identify various factors
- Break the applications like smaller modules
- Analyze each module
- To calculate ROI
30. Write xpath to list all the input elements in a page?
Use the below code:
WebElement formElement = driver.findElement(By.name("something"));
List allFormChildElements = formElement.findElements(By.xpath("*"));
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.