Top 40 Jenkins Interview Questions And Answers For Freshers/Experienced
If you are looking for a career in software development, then Jenkins is definitely worth exploring. This widely used …
If you are appearing in a web developer interview then you need to prepare these Selenium Interview Questions. Here we have given you 50 Selenium Interview questions and answers which relate to automation testing of a Web UI. Here is a list of the most frequently asked Selenium interview questions from freshers and experienced, so prepare them for your upcoming job interview. It is a wide language used with all other languages so you need to prepare this topic on a general basis to be prepared for any question asked related to automation testing.
About Selenium: It is an open-source web User Interface (UI) that has a range of tools and libraries which support web browser automation. It was developed by Jason Huggins in 2004 as an internal tool. Selenium helps automation through various browsers, platforms, and programming languages.
Also, prepare for Core Java interview questions, Networking interview questions, and other language interview questions from here.
1. Explain test automation or automation testing?
2. Tell some benefits of automation testing?
3. Tell some frequently used Functional Automation Testing tools
4. Tell some frequently used Non-Functional Automation Testing tools
6. Name different components of Selenium?
7. Tell the programming languages, browsers, and operating systems that Selenium supports?
8. Tell the various changes/upgrades in different Selenium versions?
9. Name different test types supported by Selenium.
12. Name different ways of finding a web element in Selenium?
13. Name the types of WebDriver API in Selenium?
14. Tell some Automation tools that will be integrated with Selenium to attain continuous testing.
15. Explain assertion in Selenium?
16. Explain assert and verify commands?
18. What do you understand with XPath Absolute and XPath attributes?
19. Differentiate between "/" and "//" in XPath?
20. Tell the types of annotations used in Selenium?
21. Name the WebDriver that supports Mobile Testing Drivers?
22. Name some Selenium WebDriver supporting programming languages to write Test Cases?
23. Differentiate between type keys and type commands?
24. Differentiate between "typeAndWait" and "type" commands?
25. Differentiate between findElement() and findElements()?
26. Explain wait and its types?
27. Tell the main disadvantage of implicit wait?
29. Tell the way to launch various browsers in Selenium WebDriver?
30. Make a code snippet to execute right-click an element in WebDriver.
31. Mention a programming code snippet to execute mouse hover in WebDriver.
32. Tell the various methods to refresh a web page in WebDriver?
33. Create a code for navigate back and forward in browser history?
34. Tell the syntax to invoke an application in WebDriver?
35. Tell the way to get a text of a web element?
36. Tell the way to select a value in a dropdown?
37. Tell different types of navigation commands?
38. In WebDriver, How to deal with a frame?
39. Is there an HtmlUnitDriver for .NET?
40. Show an example of redirect browsing from a browser through some proxy?
41. Explain POM (Page Object Model) and its advantages?
42. Tell the instructions to capture screenshot in WebDriver?
43. How to enter the string in a textbox using Selenium?
44. Tell the method to find if an element is shown on the screen?
45. Tell the way to click a hyperlink using link text?
1. Explain test automation or automation testing?
Automation testing uses automation tools to type and perform test cases, no physical involvement is required for running an automated test suite. Testers favor automation tools to type test scripts and test cases and then combine them into test suites.
Automation testing allows the use of special tools to automate the execution of manually designed test cases without any intervention of man. Automation testing tools can use the test data, manage the execution of tests, and relates the actual result with the expected result.
2. Tell some benefits of automation testing?
3. Tell some frequently used Functional Automation Testing tools
4. Tell some frequently used Non-Functional Automation Testing tools
Selenium is a handy framework used for software testing. Selenium tool works as a playback tool for running functional tests without the knowledge or learning of a test scripting language.
It is the most widely used open-source Web User Interface (UI) automation testing tool. Selenium is developed by Jason Huggins in 2004 as an internal tool. Selenium helps automation through various browsers, platforms, and programming languages.
6. Name different components of Selenium?
7. Tell the programming languages, browsers, and operating systems that Selenium supports?
8. Tell the various changes/upgrades in different Selenium versions?
Selenium v1.0:
Selenium v2.0:
Selenium v3:
9. Name different test types supported by Selenium.
Selenium IDE is applied as a Firefox extension that gives record and playback functionality on test scripts. It permits testers to transfer recorded scripts in different programming languages like HTML, Ruby, Java, Python, RSpec, C#, TestNG, and JUnit.
Selenium IDE is limited and the created test scripts are not robust, and portable.
12. Name different ways of finding a web element in Selenium?
13. Name the types of WebDriver API in Selenium?
14. Tell some Automation tools that will be integrated with Selenium to attain continuous testing.
15. Explain assertion in Selenium?
16. Explain assert and verify commands?
Assert: Assert command test whether the given condition is true or false. If the condition is true, the program control will run smoothly to the next phase of testing, and if the condition is false, execution is instantly stopped, and nothing will be executed.
Verify: Verify command also test if the given condition is true or false. It doesn’t stop running the program, it means any failure during verification will not stop the execution, and all the test phases would be executed in a way they are executing.
18. What do you understand with XPath Absolute and XPath attributes?
XPath Absolute:
XPath Absolute allows users to show the complete XPath location from the root HTML tag to the precise elements.
Syntax: //html/body/tag1[index]/tag2[index]/…/tagN[index]
Example: //html/body/div[2]/div/div[2]/div/div/div/fieldset/form/div[1]/input[1]
XPath Attributes:
XPath Attributes are always suggested when you don’t have an appropriate id or name attribute for the element you want to locate.
Syntax: //htmltag[@attribute1='value1’ and @attribute2='value2’]
Example: //input[@id='passwd’ and @placeholder='password’]
19. Differentiate between "/" and "//" in XPath?
Single Slash “/": Single slash creates XPath with absolute path.
Double Slash “//": Double slash creates XPath with the relative path.
20. Tell the types of annotations used in Selenium?
Know the Interview Criteria of these MNCs!!!
21. Name the WebDriver that supports Mobile Testing Drivers?
22. Name some Selenium WebDriver supporting programming languages to write Test Cases?
23. Differentiate between type keys and type commands?
24. Differentiate between "typeAndWait" and "type" commands?
25. Differentiate between findElement() and findElements()?
findElement(): To find the first element within the existing page by using “locating mechanism”. It returns one WebElement.
findElements(): To find all the elements within the existing page by using “locating mechanism”. It returns with a list of all web elements.
26. Explain wait and its types?
27. Tell the main disadvantage of implicit wait?
29. Tell the way to launch various browsers in Selenium WebDriver?
Create an instance of a driver of that specific browser.
WebDriver driver =newFirefoxDriver();
Here, “WebDriver” is an interface, and we are generating a reference variable “driver” of type WebDriver, instantiated using “FireFoxDriver” class.
30. Make a code snippet to execute right-click an element in WebDriver.
By using Action class to generate user event like right-click an element in WebDriver.
Actions action = newActions(driver);
WebElement element = driver.findElement(By.id(“elementId”));
action.contextClick(element).perform();
31. Mention a programming code snippet to execute mouse hover in WebDriver.
Actions action = newActions(driver);
WebElement element = driver.findElement(By.id(“elementId”));
action.moveToElement(element).perform();
32. Tell the various methods to refresh a web page in WebDriver?
1. Using driver.navigate command -
driver.navigate().refresh();
2. Using driver.getCurrentUrl() with driver.get() command -
driver.get(driver.getCurrentUrl());
3. Using driver.getCurrentUrl() with driver.navigate() command -
driver.navigate().to(driver.getCurrentUrl());
4. Pressing an F5 key on any textbox using the sendKeys command -
driver.findElement(By textboxLocator).sendKeys(Keys.F5);
5. Passing ascii value of the F5 key, i.e., “\uE035” using the sendKeys command -
driver.findElement(By textboxLocator).sendKeys("\uE035”);
Navigate back in browser history:
driver.navigate().back();
Navigate forward in browser history:
driver.navigate().forward();
34. Tell the syntax to invoke an application in WebDriver?
driver.get(“url”); or
driver.navigate().to(“url”);
35. Tell the way to get a text of a web element?
Get command helps us in getting the inner text of the defined web element. It doesn’t need any parameter, but it brings a string type value. It is also one of the most used commands used for the verification of labels, messages, and errors, etc. from web pages.
Syntax
String Text = driver.findElement(By.id(“Text”)).getText();
36. Tell the way to select a value in a dropdown?
We use the WebDriver’s Select class to select values in a dropdown.
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”);
Select selectByIndex = new Select(driver.findElement(By.id(“SelectID_Three”)));
selectByIndex.selectByIndex(2);
navigate().back()
This command requires no parameters and returns the user to the previous webpage.
Example
driver.navigate().back();
navigate().forward()
This command permits the user to navigate to the next web page with reference to the browser’s history.
Example
driver.navigate().forward();
navigate().refresh()
This command permits the user to refresh the existing web page by reloading all the web elements.
Example
driver.navigate().refresh();
navigate().to()
This command permits the user to open a new web browser window and navigate to the stated URL.
Example
driver.navigate().to(“https://google.com”);
38. In WebDriver, How to deal with a frame?
An inline frame called iframe is used to add another document within the existing document. This document can be HTML or web page and nested web page.
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();
39. Is there an HtmlUnitDriver for .NET?
To use HtmlUnit first use the RemoteWebDriver and pass it in the anticipated capabilities.
IWebDriver driver
= new RemoteWebDriver(DesiredCapabilities.HtmlUnit())
For the Firefox implementation to run, use
IWebDriver driver
= new RemoteWebDriver(DesiredCapabilities.HtmlUnitWithJavaScript())
40. Show an example of redirect browsing from a browser through some proxy?
Example
String PROXY = “199.201.125.147:8080”;
org.openqa.selenium.Proxy proxy = new.org.openqa.selenium.Proxy();
proxy.setHTTPProxy(Proxy)
.setFtpProxy(Proxy)
.setSslProxy(Proxy)
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new FirefoxDriver(cap);
41. Explain POM (Page Object Model) and its advantages?
Page Object Model (POM) is a design pattern for making an Object directory for web User Interface elements. Every web page is necessary to have its page class. The page class is accountable for finding the WebElements in web pages and then implements operations on WebElements.
The advantages of using POM are.
42. Tell the instructions to capture screenshot in WebDriver?
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 TakeScreenshot {
WebDriver drv;
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
drv.get(“https://google.com”);
}
@After
public void tearDown() throws Exception {
drv.quit();
}
@Test
public void test() throws IOException {
//capture the screenshot
File scrFile = ((TakeScreenshot)drv).getScreenshotAs(OutputType.FILE);
// paste the screenshot in the desired location
FileUtils.copyFile(scrFile, new File(“C:\\Screenshot\\Scr.jpg”))
}
}
43. How to enter the string in a textbox using Selenium?
To enter the string in a textbox The sendKeys(“String to be entered”) is used.
Syntax
WebElement username = drv.findElement(By.id(“Email”));
// entering username
username.sendKeys(“sth”);
44. Tell the method to find if an element is shown on the screen?
WebDriver enables user to test the visibility of the web elements. These elements can be radio buttons, boxes, buttons, checkboxes, drop, labels etc. that can be used with the following methods.
Syntax:
isDisplayed():
boolean buttonPresence = driver.findElement(By.id(“gbqfba”)).isDisplayed();
isSelected():
boolean buttonSelected = driver.findElement(By.id(“gbqfba”)).isSelected();
isEnabled():
boolean searchIconEnabled = driver.findElement(By.id(“gbqfb”)).isEnabled();
45. Tell the way to click a hyperlink using link text?
driver.findElement(By.linkText(“Google”)).click();
The given command searches for the element by using a link text, then clicks on that element, and then the user is redirected to the matching page.
driver.findElement(By.partialLinkText(“Goo”)).click();
The given command looks for the element based on the substring of the link given in the parenthesis. And after that partialLinkText() discovers the web element with the stated substring and then clicks on it.
If you are looking for a career in software development, then Jenkins is definitely worth exploring. This widely used …
In this post, we will cover a few Linux interview questions and their answers. So, let’s get started. In this …