Home / Interview /Top 50 Selenium Int...
Admin
2023-09-07
0 mins read
Similar Blogs
How are the data structures and algorithms useful for SDET?
0 mins read
2023-09-14
How To Use DataProvider in TestNG – Parameterization
0 mins read
2023-09-13
What Are The Skills Required for SDET?
0 mins read
2023-09-13
How can I switch from QA to SDET?
0 mins read
2023-09-14
SDET Demand In Market !!
0 mins read
2023-09-13
Essential Skills Required to Become an SDET
0 mins read
2024-05-02
How can a QA or Test engineer become SDET?
0 mins read
2023-09-12
What is the difference between SDET and TESTER?
0 mins read
2023-09-12
What Is TestNG Annotations-Benefits, Hierarchy
0 mins read
2023-09-13
How to write a Good Test Case in Software Testing
0 mins read
2023-09-14
The following set of frequently asked interview questions have been compiled to help students and professionals preparing for Certified SDET professional courses, SDET Foundation Training, Certified SDET Architect courses. You can see the full set of SDET Interview questions here.
Selenium is an open-source automation testing tool used for testing web applications.
It is an open-source tool means it does not require any licensing cost and can be used with various browsers like Mozilla Firefox, Internet Explorer, Google Chrome, Safari or Opera.
The test scripts for Selenium can be written in various programming languages like Java, Python, C#, PHP, Ruby, Perl and .Net.
The advantages of Selenium are as follows:
The limitations of Selenium are as follows:
Selenese is the language that is used to write test scripts in Selenium IDE.
The various locators in Selenium are as follows:
Assert and Verify both are used to check whether the given condition is true or false.
In Assert command, if any condition fails then the execution will stop, and no further test steps will be executed.
But in Verify command, if any condition fails then the execution will not stop and all further test steps will be executed.
setSpeed() method is used to delay every Selenium operation.
eg. setSpeed(“5000”): It will stop the execution for 5 seconds.
sleep() method is used to delay only a single operation where it is written.
eg. sleep(5000): It will wait for 5 seconds.
Selenium Grid is used to execute the same or different test scripts on various platforms and browsers parallelly. This helps in testing the application in different environments concurrently and hence saving the execution time.
Working of Selenium Grid:
Selenium Grid sent the tests to the hub(central server that controls the execution on different machines). These tests are then redirected to Selenium Web Driver, which launch the browser and run the test.
XPath is called as XML Path. It is a syntax or language that provides a way to locate and process the elements in XML documents.
It is used in Selenium to uniquely identify any element on a webpage using HTML DOM structure
Absolute XPath: It is used to find the XPath directly by giving the exact path of the element as described in the HTML DOM structure.
If any change is done in the path of the element, then XPath will get fail. It begins with a single forward-slash(/), means that you can select the element starting from the root node.
Relative XPath: Relative XPath starts searching the matching element from anywhere in the HTML DOM structure. It begins with a double forward-slash(//), which means it can search the element anywhere in the page
👉Selenium Professional Training
👉Certified SDET Professional Training
//tagName[@attributeName = ‘attributeValue’]
for eg.: //input[@id = ‘txtUserName’]
FindElement() returns only one Web Element.If there are more than 1 matches, then it will return first appearance in DOM.
If there is no such element present in the DOM, then it will throw ElementNotFound exception.
FindElements() returns the list of Web elements present in the webpage. If there is no such element present, then it will return the empty list and will not throw any exception.
Implicit Wait: It is used to tell Web driver to wait for some certain amount of time while trying to find an element in DOM before throwing an exception.
It is applied to all Selenium commands.
Explicit Wait: It is used to tell the Web driver to wait for some extended amount of time for some specific search or till the time some specific condition is met. It is one-timer and is used for a particular search.
The various exceptions in Selenium Webdriver are as follows:
The different ways to refresh the browser are:
The different types of navigation commands are:
The different ways to select a value in a dropdown are:
driver.close() is used to close only the current window that IWebDriver is controlling
driver.quit() is used to close all the windows opened by IWebDriver.
Single Slash is used in Absolute XPath and it instructs the XPath Search Engine to start searching for element starting from the root node.
Double Slash is used in Relative XPath and it instructs the XPath Search Engine to search for matching element anywhere in the XML document.
To click on any specific part of an element, clickAt command is used.
ClickAt command uses element locator and x,y coordinates as arguments-
clickAt(locator, coordString)
submit() method on the element is used to submit a form.
element.submit();
We can login by passing the username and password with URL:
http://username:password@url
Object Repository is used to store all the objects that are used in the scripts in one or more centralized location rather than scattered all over the test script.
The main advantage of using Object repository is to segregate all objects in one place.
If any locator value of any web element changes, then changes need to be done at only one place i.e. object repository rather than making changes in all test cases where that particular locator is used.
We can perform double click by using Actions class.
Actions act= new Actions(driver);
act.doubleClick(webElement);
getText() method is used to get the text of a web element.
string text= driver.findElement(by.id(“Text”)).getText();
Soft Assert does not throw any exception if an assert statement fails and will continue to next step in the test after the assert statement.
Hard Assert throws an AssertException if an assert statement fails and will not continue with the further steps in the test.
Webdriver is an API that is easy to explore and understand and helps us to make tests easier to read and maintain in SDET.
It is an interface that comes under org.openqa.selenium package of Selenium.
Webdriver is an interface and comes under the org.openqa.selenium package of Selenium and a sub-interface of “SearchContext”.
Browser is launched by creating an object of a required driver class such as FirefoxDriver, ChromeDriver, InternetExplorerDriver, etc.
Launching Chrome Driver:
WebDriver driver = new ChromeDriver();
Launching FireFox Driver:
WebDriver driver = new GeckoDriver();
Launching Internet Explorer Driver:
WebDriver driver = new InternetExplorerDriver();
“SearchContext” is the super interface of WebDriver.
The frame is an HTML document which is embedded inside HTML document.
To switch between frame, following Selenium command is used:
driver.switchTo().frame(By.tagName(“iFrame”));
defaultContent() method is used to switch back from a frame.
eg.: driver.switchTo().defaultContent();
The various ways to switch between frames are as follows:
size() method is used to find the total number of frames in a web-page.
Syntax:
List<WebElements> ListItems = driver.findElements(By.tagName(“iFrame”));
No. of Frames = ListItems.size();
Select class is used to select the values in the dropdown or multi-select.
Syntax:
Select abc = new Select(driver.FindElement(By.Id(“ ”)));
abc.SelectByVisibleText(“ “);
To deselect any text from multiselect, deSelectByVisibleText() method is used.
Syntax:
abc.deSelectByVisibleText(“ “);
To move any element, below Actions method is used:
WebElement abc = driver.FindElement(By.Id(“ “));
new Actions(driver).moveToElement(abc).perform;
To capture the screenshot, below code can be written:
File srcFile = ((RemoteWebDriver) driver).getScreenShotAs(OutputType.FILE);
File destFile = new file(“E:/screenshot.png”);
FileUtils.copyFile(srcFile, destFile);
No, captcha and barcode reader can’t be automated using Selenium.
No, Selenium Webdriver can’t test mobile applications.
driver.findElement(By.linkText(“devLabsAlliance”)).click();
sendKeys() method is used to type a string in a textbox.
Syntax:
WebElement user = driver.FindElement(By.Id(“usrName”));
user.sendKeys(“devLabs”);
BreakPoints: BreakPoint will stop the execution of code there only where it is inserted.
StartPoints: StartPoint is used to specify the point from where the execution should begin.
getWindowHandles(): It returns the address of all the open windows initiated by driver.
Its return type is Set<String>.
getWindowHandle(): It returns the address of the current browser where the control is.
Its return type is string.
A framework is a code structure which helps to make code understanding and maintenance easy. With the framework, we can place the code and data separately which makes it easy to read and can be re-used as well.
Can be re-used as well.
There are 3 types of Selenium framework in SDET:
It defines the maximum amount of time to wait for a specific condition and frequency before throwing an ElementNotVisibleException exception.
Fluent Wait has pooling capacity. It means that after this particular time, it can check if the application is loaded and then it can move further without waiting for max time.
To get the text of alert pop-up, below statement is used:
driver.switchTo().alert().getText();
To dismiss the alert pop-up, below statement is used:
driver.switchTo().alert().dismiss();
INQUIRY
By tapping continuing, you agree to our Privacy Policy and Terms & Conditions
SkillAhead Solutions
Gurgaon
USA
1603, Capitol Avenue, Suite 413A, 2659, Cheyenne, WY 82001, USA
`Copyright © DevLabs Alliance. All rights Reserved`
|
Refund & Reschedule Policy
Privacy Policy
Terms of Use