Selenium Interview Question
Selenium Interview Question
Freshers, you are at the correct place. There is parcel of chances from many presumed
organizations on the planet. Gangboard offers Advanced Selenium Interview Questions and
answers that assist you in splitting your Selenium interview and procure dream vocation
as Selenium Developer.
Do you believe that you have the right stuff to be a section in the advancement of future Selenium,
the GangBoard is here to control you to sustain your vocation. Various fortune 1000 organizations
around the world are utilizing the innovation of Selenium to meet the necessities of their
development in Selenium work, our page furnishes you with nitty-gritty data as Selenium prospective
employee meeting questions and answers. Selenium Interview Questions and answers are prepared
by 10+ years experienced industry experts. Selenium Interview Questions and answers are very
useful to the Fresher or Experienced person who is looking for the new challenging job from the
reputed company. Our Selenium Questions and answers are very simple and have more examples
By this Selenium Interview Questions and answers, many students are got placed in many reputed
companies with high package salary. So utilize our Selenium Interview Questions and answers to
Making Testing process Automated using tools like Selenium or UFT or LoadRunner ect is called
Automation testing.
are getting challenges in Manual testing like repeated tasks we will move for selenium. In manual
test cases, we can convert into Automation Test Cases. It supports multiple languages like Java, C#,
It has generally 4 components. Each component had a different approach to automate. They are:
IDE
RC
WebDriver
Grid
Test engineer writes the Automation code, that code send to the browser driver components, the
browser component executes the tester request, it sends its own request to the browser, the browser
Here using element locators we can create test cases and execute test cases.
It not generate detailed test reports, it generates only a test summary report.
It is not having any default repository.
It doesn’t support desktop applications
Selenium Grid is used to execute test cases in multiple browsers, multiple environment and multiple
It supports parallel execution in a dual environment. Here we can execute webdriver test cases and
id
name
classname
css selector
xpath: Xpath is unique locater in selenium to recognize an object based on tagname.
LinkText: a link having some outer text ie., linktext.
PartialLinktext: link text with unique characters.
TagName: tagName generally we use for to identify a group of objects.
Xpath is a unique locator builder in selenium. Based on html tag position xpath target object location.
XPaths is unique addresses for each and every web object. It can be used with selenium to perform
operations on each object present in the webpage. In the web page, each web-object has a primary
unique XPath.
Absolute xpath
Relative XPath
—>/html/body/child tagname…..(/tagname/tagname/tagname….)
Relative xpath is useful to target object using Attribute names. We use relative xpath when object
driver.findElement(by.xpath(“.//tagname[@property=’property value’]”))
driver.findElement(by.xpath(“.//*[@locator=’locator value’]”))
driver.findElement(by.locator(“locator value”)).click():
driver.findElement(by.locator(“locator value”)).click():
driver.findElement(by.locator(“locator value”)).click():
obj.SelectbyIndex();
obj.selectbyVisibleText(“”);
obj.SelectbyValue(“”);
Obj.get(“url”)
Obj.manage().window().maximize();
Drivder=new chromeDriver();
List all_rows=table.findElements(By.tagName(“tr”));
WebElement selected_row=all_rows.get(index);
int size=all_rows.size();
System.out.println(size);
List selected_coloum=selected_row.findElements(By.tagName(“td”));
int coloum_size=selected_coloum.size();
System.out.println(coloum_size);
WebElement selected_cell=selected_coloum.get(number);
String cell_value=selected_cell.getText();
String Title=driver.getTitle();
String url=driver.getCurrentUrl();
String pagescource=driver.getPagescource();
String text=element.getText();
using this method we can find out selected target html tagname
String tag=element.getTagname();
system.out.println(tag);
Alert alrt=driver.switchTo().alert();
alrt.getText();
Alert alrt=driver.switchTo().alert();
alrt.sendKeys(“Elugu Manojkumar”);
Syntax:–.
driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
Set<String> multiplewindows=driver.getwindowhandles();
driver.findElement(By.xpath(“xpath value”)).click();
driver.switchTo().frame(“packageFrame”);
driver.findElement(By.linkText(“Alert”)).click();
driver.switchTo().defaultContent(); //Clear all switches before applying switch second time onwards
driver.switchTo().frame(“classFrame”);
driver.findElement(By.xpath(“xpath value”)).click();
try {
//Timestamp using java
String time=df.format(d);
File src=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(src,new
File(“E:\\selenium_Workspace_Week20\\screens\\EluguManojkumar”+time+”.png”));
} catch (Exception e)
System.out.println(e.getMessage());
@Test:–>
syntax:–>
@Test
System.out.println(“[email protected]”);
with in class.
syntax:–>
@BeforeClass
System.out.println(“[email protected]”);
within class.
@AfterClass
System.poy.println(“Elugu ManojKumar”);
Before the method is executed before each @Test method with in a class
@Before
System.out.println(“[email protected]”);
After annotation execute after each @Test method execution within a class
@After
public void methodname()
System.out.println(“[email protected]”);
@Ignore
System.out.println(“[email protected]”);
@BeforeSuite: The annotated method will be run before all tests in this suite have run.
@AfterSuite: The annotated method will be run after all tests in this suite have run.
@BeforeTest: The annotated method will be run before any test method belonging to the classes
@AfterTest: The annotated method will be run after all the test methods belonging to the classes
@BeforeClass: The annotated method will be run before the first test method in the current class is
invoked.
@AfterClass: The annotated method will be run after all the test methods in the current class have
been run.
@BeforeMethod: The annotated method will be run before each test method.
@AfterMethod: The annotated method will be run after each test method.
<suite name=”suite1″>
</suite>
@Test(priority=0)
public void testmethod1()
System.out.println(“[email protected]”)
Reporter.log(“method y is executed”);
@Test(enabled=false)
Reporter.log(“method y is executed”);
<test name=”Manojkumar”>
<classes>
<parameter name=”browser”value=”ff”></parameter>
<class name=”packagename.classname”></class>
</classes>
</test>
</suite>
Q65) How to Execute Two are multiple test with in suite with xml
</test>
</test>
</suite>
@Test(dataProvider = “dp”)
public void f(String elugu,String Manojkumar)
Assert.assertTrue(driver.findElement(By.locator(“locator value”)).isDisplayed());
@DataProvider
data[0][0]=”[email protected]”;
data[0][1]=”123456789″;
It supports parallel execution in dual environment. Here we can execute webdriver test cases and
Maven is a management tool it build projects using project object model [POM]
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.13.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Selenium Questions:
driver.manage().window().setPosition(newPoint(200,400))
Q75). How to select all elements in the DOM using CSS selector?
Ex:driver.findElement(By.cssSelector(“*”));
xpath stands for XML path. It is used to find the element in the DOM. Success rate is high finding an
will select the element with attribute1 with value1 and attribute2 with value2
//tagname[number]
Ex: driver.findElement(By.xpath(“//tr[2]/td[2]”))
//input [starts-with(@id,”che”)]
This xpath will select the element with whose tagname is input, attribute is id and value starts with
che
Q81). How many methods present in the SelectElement class for drop-down and multi
select dropdown?
(getOptions(),isMultiple(),selectByVisibleText(),deselectByVisibleText(),selectByValue(),
deselectByValue(),selectByIndex(),deselectByIndex(),getFirstSelectedOption(),
getAllSelectedOptions(),deselectAll())
Advanced keyboard and mouse actions are performed by using the Action class.
If webdriver wait for defined amount of time until webdriver find the element in DOM
Driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS)
Wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className(“ContactUS”)))
When we have multiple window all we need to do is switching from one window to another.
Driver.switchTo().window(newTab.get(1));
Q89). How to take screenshot in selenium?
TakesScreenshot interface method used to take the screenshot of the current page displayed in the
driver instance.
*Normal Approach
*Easy maintain
*Readable format
A listener is defined as an interface that modifies the default TestNG’s behavior. As a name
suggests Listeners “listen” to the event of defined in the selenium script and behave accordingly.
code:
@Runwith(Cucumber.class)
@cucumberOptions(
feature=”Feature name”,
,glue={“stepdef”,”stepdef”},
tags={“@smokesuite”,”@Regrssion”}
Example:
Class GroupTestExample{
@Test(groups = { “checkintest” })
@Test(groups = { “functest” })
TestNG.xml:
<groups>
<run>
</run>
</groups>
<classes>
</classes>
</test>
</suite>
TestNG is capable of running multiple TCs in one Testsuites as well as mutiple test suites also. For
that first we need to create testng.xml file inside our project structure, now inside xml give the below
code (Test name and class name may differes as per your project)
<test name=”test1″>
<classes>
<class name=”com.suite1.test1″/>
</classes>
</test>
<test name=”test2″>
<classes>
<class name=”com.suite2.test2″/>
</classes>
</test>
</suite>
<suite-files>
</suite-files>
</suite>
Q96) How will you find running text in selenium?
Java has included a feature that simplifies the creation of methods that need to take a
variable no. of arguments.
For ex:
// Body
We can make one test method run only after successful execution of dependent test method by
@Test(dependsOnMethods = { “preTests” })
And in the program we should use Runtime class. Likewise so many third party tools are available:
Q103) What is the jar file is used to read and write excel in selenium?
Following:: -> it will give all the tags following by the mentioned tag
Following-sibling:: -> it will give only the same level of element tag followed by the mentioned tag
This is the new feature of Java8 , Interface which allows default accessed method body inside
interface
Q106) How will you handle if 2 interfaces having same signatured method?
Using super keyword..
InterfaceA.super.defaultMethod();
Early testing
Defect clustering
Pesticide Paradox
Q108) What are the difference between “/” and “//” in Xpath?
Single Slash “/” : Create Xpath with absolute path it is used to Single slash
EX : the xpath would be created to start selection from the document node/start node.
Double Slash “//” : Create Xpath with relative path is used to Double slash
EX : the xpath would be created to start selection from anywhere within the document.
Q109) What is the Advantages of Test Automation Framework?
Reusability of code
Easy Reporting
Maximum coverage
Recovery scenario
Low-cost maintenance
Minimal manual intervention
1)Selenium WebDriver
2)Selenium Grid
Syntax:
// entering username
username.sendKeys(“sth”);
Hub is a central point or a server, Hub controls the test execution on different machines.
The user follow the methods to check the visibility of the web elements.
These web elements can be buttons, labels, drop boxes, radio buttons, checkboxes etc.
isDisplayed()
isSelected()
isEnabled()
Syntax:
I sDisplayed():
I sSelected():
boolean buttonSelected = driver.findElement(By.id(“gbqfba”)).isSelected();
isEnabled():
Firefox Driver
Internet Explorer Driver
Gecko Driver
HTML unit Driver
Chrome Driver
Opera Driver
Android Driver
Safari Driver
EventFiring WebDriver
iPhone Driver
Linux
Windows
Apple
Q118) What are the Different type of Programming languages Supported in Selenium
Web Driver?
Java
Python
Php
Perl
C#
Ruby
Q119) What are the Different type of Framework Supported in Selenium Web Driver?
Junit
TestNG
code reusability
code maintainability
object Repository
Readability
Q121) Different keyboard operation that can be performed in Selenium?
sendKey(“Sequence of character”)
pressKey(“non-text keys”)
releaseKey(“non-text keys”)
Collapse
Listener is defined as a interface that modifes the default TestNG’s behavior. As a name suggests
Listeners “listen” to the event of defined in the selenium script and behave accordingly. TestNG is
code:
@Runwith(Cucumber.class)
@cucumberOptions(
feature=”Feature name”,
,glue={“stepdef”,”stepdef”},
tags={“@smokesuite”,”@Regrssion”}
Example:
Class GroupTestExample{
@Test(groups = { “checkintest” })
@Test(groups = { “functest” })
TestNG.xml:
<groups>
<run>
<include name = “functest” />
</run>
</groups>
<classes>
</classes>
</test>
</suite>
Now add @Test(retryAnalyzer = Tests.RetryAnalyzer.class) inside actual class which has @Test
annotation
Java has included a feature that simplifies the creation of methods that need to take a variable no. of
arguments.
For ex:
// Body
This syntax tells the compiler, that fun( ) can be called with zero or more arguments. As a result,
TestNG is capable of running multiple TCs in one Testsuites as well as mutiple test suites also. For
that first we need to create testng.xml file inside our project structure, now inside xml give the below
code (Test name and class name may differes as per your project)
<test name=”test1″>
<classes>
<class name=”com.suite1.test1″/>
</classes>
</test>
<test name=”test2″>
<classes>
<class name=”com.suite2.test2″/>
</classes>
</test>
</suite>
<suite-files>
</suite-files>
</suite>
An object repository is a common storage location for all objects. Selenium WebDriver does not offer
an in-built object repository by default. However, object repositories can be built using the key-value
pair approach wherein the key refers to the name given to the object and value refers to the
The following are the types of object repositories that can be created in Selenium WebDriver.
Java has included a feature that simplifies the creation of methods that need to take a variable no. of
arguments.
For ex:
// Body
File SrcFile=scrShot.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(SrcFile, DestFile);
The same way we can add same thing inside onTestFailure() method inside Listener class also
Q132) How can we make one test method dependent on other using TestNG?
We can make one test method run only after successful execution of dependent test method by
@Test(dependsOnMethods = { “preTests” })
Using AutoIT, third party application which can be of two parts: AutoIT Editor, Element Identifier
And in the program we should use Runtime class. Likewise so many third party tools are available:
Q137) What is the jar file is used to read and write excel in selenium?
Following:: -> it will give all the tags following by the mentioned tag
Following-sibling:: -> it will give only the same level of element tag followed by the mentioned tag
This is the new feature of Java8 , Interface which allows default accessed method body inside
interface
Q141) How will you handle if 2 interfaces having same signatured method?
InterfaceA.super.defaultMethod();
}
}
Early testing
Defect clustering
Pesticide Paradox
Q143) What are the difference between “/” and “//” in Xpath?
Single Slash “/” : Create Xpath with absolute path it is used to Single slash
EX : the xpath would be created to start selection from the document node/start node.
Double Slash “//” : Create Xpath with relative path is used to Double slash
EX : the xpath would be created to start selection from anywhere within the document.
Reusability of code
Easy Reporting
Maximum coverage
Recovery scenario
Low-cost maintenance
Minimal manual intervention
Selenium WebDriver
Selenium Grid
Selenium Remote Control (Selenium RC)
Selenium Integrated Development Environment (Selenium IDE)
User can be use sendKeys(“String to be entered”) to enter the string in the textbox.
Syntax:
// entering username
username.sendKeys(“sth”);
The user follow the methods to check the visibility of the web elements.
These web elements can be buttons, labels, drop boxes, radio buttons, checkboxes etc.
isDisplayed()
isSelected()
isEnabled()
Syntax:
isDisplayed():
isSelected():
isEnabled():
Firefox Driver
Internet Explorer Driver
Gecko Driver
HTML unit Driver
Chrome Driver
Opera Driver
Android Driver
Safari Driver
EventFiring WebDriver
iPhone Driver
Q153) What are the Different type of Programming languages Supported in Selenium
Web Driver?
Java
Python
Php
Perl
C#
Ruby
Q154) What are the Different type of Framework Supported in Selenium Web Driver?
Junit
TestNG
code reusability
code maintainability
object Repository
Readability
.sendKey(“Sequence of character”)
.pressKey(“non-text keys”)
.releaseKey(“non-text keys”)
iter = windows.iterator();
iter.next();
Q162) Write syntax for xpath and css if id and tag are given.
xpath=//tagname[@id=’value’]
css=tagname[id=value]
//tagname[contains(@id,’partialtext’)]
tagname[id*=’substring’]
tagname[id^=’startstring’]
tagname[id$=’endstring’]
Q165) What are the class available in selenium to handle drop downs?
Select
Actions.moveToElement(locator).build().perform();
driver.switchTo.alert().dismiss();
driver.findElements (By.tagName(“a”)).size();
Relative: //div/a
//parent/child
System.setProperty(“webdriver.chrome.driver”, ”path_to_chromedriver”)
visibilityOfElementLocated, invisibilityOfElementLocated
driver.findElement(By.id(“id”)).sendKeys(Keys.ENTER);
Public
Protected
Private
Default
Subclass of Exception
One instance
Helps to modularize
Can be imported
Interface:
Automatically synchronized
Build deployment
Non-functional testing
Complex calculations
Repeated executions
A framework is a set of the structure of the whole automation suite. It is also a guideline, which if
Q192) What are the different types of an automation tool that you are aware of?
Open source tool like Selenium, JMeter etc. Other Automation Tools
Paid tools like QTP, Load Runner, RFT, and Rational Robot.
Q194) When do you prefer manual testing over the Automation testing?
The project is short-term and writing scripts it will be time-consuming and costly when compared to
manual testing.
Flexibility is required. Automated test cases is the programmed and run in a specific way of
configurations.
Usability testing needs to be performed.
Application/module are newly developed is have no previous test cases.
Ad-hoc or exploratory testing needs to be the performed.
Testers are having all the relevant access to front end and backend
When Unit testing is completed and results should be shared to Testing team.
Test cases uploaded and ready for execution in the test management tool.
There can 2 SEv2 defects in open status with low business priority.
There can 5 Sev3 defects in open status with low business priority.
Test Lead.
Summary:-
Defect summary:-
HTTP 404 error means client was able to communicate with server but server could not find what the
response was.
Q199) Among 4 team members 2 members are on sick leave and you need to
complete the testing today and there are 200 test cases with one team member with
given time line you can completed only 80 test case . All other members in your
project are occupied. How do you handle the situation and convince the client?
First Tester should identify critical and high priority scripts. Get in touch with BA, Business and
explain the situation to the project stakeholders. Get sign off from BA on the test case and should
execute only the identified test case. By this process the risk is mitigated and the business is happy.
driver.switchTo().frame([identifier])
Execute the given test cases manually so that we get more clarity on the steps which are to be
automated.
While executing the test cases note down the page elements present on the page & actions to be
After executing all the test cases develop respective ‘Page’ class with elements & methods.
Answer:
Number of POM classes should be same as number of webpages present in the application & POM
Name of the class should be same as respective webpage name & class name should end with
Develop ‘public’ method for all the actions which are to be performed on the page.
Q204) How can we perform “Back” and “Forward” operations using selenium?
System.out.println(binary);
Q206) Write a program to print each word in a new line from the given string “This is
my java world”
Answer:
System.out.print(output1);
12
123
1234
12345
Answer:
System.out.print(j+" ");
System.out.println();
System.out.println("\"Hello World\"");
for(int i=0;i<5;i++)
for(int j=0;j<5-i;j++) //
{
System.out.print(" ");
for(int k=0;k<=i;k++)
System.out.print("$ ");
System.out.println();
Q210) Write a java program to reverse the given string using StringBuffer
System.out.println(sb.reverse());
Answer:
System.out.println(s1);
In the above example, when you print “s1”, it will print “Venkatesh”. This means, if you try to modify
the existing string, it will create a new string instead of modifying the existing string.
Q212) How do you print the message only on the TestNG HTML reports in selenium?
Q213) How do you print the message on the TestNG HTML report and as well as in
console in selenium?
Answer: Reporter.log(“This Prints message on both TestNG html report and console”, true);
Answer :To disable the test method, we have to use enabled = false to the @Test annotation.
@Test(enabled = false)
Answer : To ignore/exclude the test method, we have to use enabled = false to the @Test
In the above case, it will terminate the test method in 5 seconds and the method will be marked as
‘Failed’.
1. Functional Testing.
2. Non-Functional Testing.
Answer: The combination of Top Down Incremental Integration Testing and Bottom Up Incremental
Answer: Testing the application on different software and hardware platforms is called as
compatibility testing.
Note: Testing on different browsers or different versions of the browsers and different operation
Answer: Re-execution of same test cases on different build to ensure that the changes made in the
application has not introduced the defect in the unchanged feature. E.g.: When you get a build for
1st time, execute the test cases which are already written. If new features added to the project, write
new test cases and execute the new test cases + re-execute the old test cases. Here re-executing
Answer: Baselining is used to check whether the automation test cases are working as per the
Answer:The defect which are occurring at irregular intervals of time are called as inconsistence
defect.
Q224) How do you confirm whether the particular web element is visible on the page
or not?
Answer: Selenium Grid can be used to execute same or different scripts on multiple browsers and
Q226) Can you list some exceptions that you have seen in selenium?
Answer:
StaleElementReferenceException
NoSuchWindowException
TimeoutException
NoSuchElementException
NoAlertPresentException
IllegalStateException
ElementNotVisibleException
WebDriverException
1. Implicit Waits
2. Explicit Waits
3. Fluent Waits
4. Custom Waits
Answer: Yes, we can delete cookies using selenium. We use deleteAllCookies() method to delete
cookies.
Answer: Java, C#, Ruby, Python, JavaScript (Node JS), Perl, PHP, Objective-C, JavaScript, Haskell,
R, Dart, TCL.
Answer: Chrome, Firefox, IE, Edge, Opera, Safari, Android browser, I-Phone, I-Pad, Opera Blink,
Answer:
driver.manage().window().maximize();
driver.manage().window().setSize(d);
driver.manage().window().maximize();
driver.manage().window().setPosition(p);
Q234) How do you find X & Y co-ordinates of an element? Write code for this?
To find x-value we use ‘getX()’ & for y-value ‘getY()’.This method is present in ‘WebElement’
E.g.:
int x=userName.getLocation().getX();
int y=userName.getLocation().getY();
Answer:
Iterator ListIterator
We get iterator type object by ‘iterator ()’ method We get list iterator object by ‘listIterator()’ meth
It has methods i.e. hasNext (), next (), remove (), hasPreviou
It has methods i.e. hasNext (), next () & remove ()
().
List Set
It supports for, for-each, Iterator & ListIterator It supports for-each & Iterators only
Answer:
ArrayList LinkedList
Addition & deletion of objects is slow in ArrayList because Addition & deletion of objects is fast in LinkedList because num
number of swaps are more are less
ArrayList consumes more memory because it grows by half
It consumes less memory compared to ArrayList because it gr
of its initial size
Answer:
ArrayList Vector
It consumes less memory compared to Vector because it grows by half of its It consumes more memory because it grows by
initial size initial size
ArrayList class methods are non-synchronized Vector class methods are synchroniz
HashSet LinkedHashSet
HashSet class methods are synchronized LinkedHashSet class methods are not-synchro
Answer:
TreeSet LinkedHashSet
It gives sorted output. It gives ordered output
It can receive any type of objects It can have only one null value
Answer:
Answer:
final:
finally:
finalize:
finalize is used to perform cleanup processing just before object is garbage collected
finalize is a method available in Object class.
Answer:
While overriding, method name, argument list and return type should match.
We can change the visibility in the sub-class but we can’t reduce the visibility in the sub-class.
For overriding, inheritance is must.
We cannot override private, static members and constructors.
Overriding is applicable only for methods.
Q245) What kind of reporting mechanism have you included in your selenium
project?
Answer: We can have different types of reports like Extent report TestNG Surefire report etc.
Answer: (/) Kickoff and relative path to the path path (/) from the path to the full path
Answer:
Web Driver attributes to the desired capabilities. If your local installation does not match the default
settings, there is a common application suite to set the path of the Firefox driver.
Answer: TestNG and Web Drive Listener are various interfaces to implement and invite them. They
both change their behavior. You can use questions that are aware of. FireFoxDriver Drive = New
FireFoxDriver (); This URL provides a comprehensive list of listeners and their interfaces.
Property values are used by XPP for asset values using more complex selectors, and a more flexible
choice strategy, but it is possible to be very slow in IE. In IE 6, 7, or 8, searches through XP, can be
slowly slower than Firefox. The IE provides the default XPath-over-HTML solution, so the program
must use JavaScript enabled and the JavaScript engine in the legacy version of IE is really reluctant.
If you have an object using a complex selector, I usually recommend CSS selectors if possible. The
CSS selector is not quite as flexible as XPath, but XPT can hide many of the same suits, without
Answer: Selenium is the robust test automation suite that is used for the automating web based
Selenium WebDriver – Selenium WebDriver is used to the automate web applications using
Selenium IDE – A firefox plugin that works on the record and play back on principle.
Selenium Grid – Allows selenium tests to run in the parallel across multiple machines.
Selenium is the open source and free to use without any licensing cost.
It has good amount of the resources and helping community over to the internet.
Using selenium IDE component, non-programmers can also write to automation scripts
Using the selenium grid component, distributed testing can be carried out on remote machines is
possible.
For creating robust scripts in the selenium webdriver, programming langauge knowledge are
required.
We have to rely on external libraries and tools for the performing tasks like – logging(log4J), testing
Android – An Selendroid/Appium
IOS – An ios-driver/Appium
Answer: No selenium webdriver uses through browser’s native method to automate on web
applications. Since web services are headless, so we cannot automate web services using to
selenium webdriver.
Answer: Selenium webdriver can be used for the performing automated functional and the
regression testing.
Answer:
Id
XPath
cssSelector
className
tagName
name
linkText
partial LinkText
Answer: Xpath or XML path is the query language for selecting nodes from the XML documents.
Answer: An absolute XPath is a way of the locating an element using an XML expression beginning
from the root node i.e. html node in case of the web pages. The main disadvantage of absolute
xpath is that even with the slightest change in the UI or any element the whole absolute can XPath
fails.
Example – html/body/div/div[2]/div/div/div/div[1]/div/input
Answer: A relative XPath is the way of locating an element using an XML expression beginning from
the anywhere in the HTML document. There are different ways of creating on relative XPaths which
are used for the creating robust XPaths (unaffected by changes in other UI elements).
Example – //input[@id=’username’]
Q262) What is the difference between the single slash(/) and the double slash(//) in
XPath?
Answer: In XPath a single slash is used for the creating XPaths with a absolute paths beginning from
root node.
Answer: Using Firebug or developer tools we can inspect to the specific web elements.
Firebug is a plugin of firefox that provides various of development tools for the debugging
applications. From automation perspective, firebug is used to specifically for inspecting web-
elements in order to get use their attributes like id, class, name etc. in different locators.
Q264) How can we locate an element by the only partially matching its attributes
value in the Xpath?
Answer: Using contains() method we can locate an element by the partially matching its attribute’s
value. This is particularly helpful in the scenarios like where the attributes have dynamic values with
The above that statement will match the all the values of name attribute to containing the word ‘user’
in them.
Answer:
Answer: Using ‘..’ expression in XPath we can move to the parent of an element.
Q267) How can we move to the nth child element using XPath?
Answer:
There are two ways of navigating to the nth element of using XPath-
Using a position()-
Q268) What is the syntax of the finding elements by class using to CSS Selector?
Answer: By .className we can select all the element belonging to the particluar class e.g. ‘.red’ will
Q269) What is the syntax of finding elements by id using the CSS Selector?
Answer: By #idValue we can select all the element belonging to an particluar class e.g. ‘#userId’ will
Q270) How can we select elements by their attribute value using CSS Selector?
Answer: Using [attribute=value] we can select all the element of belonging to the particluar class e.g.
‘[type=small]’ will select to the element having attribute type of value ‘small’.
Q271) How can we move to the nth child element using css selector?
Answer: Using :nth-child(n) we can move to the nth an child element e.g. div:nth-child(2) will locate
Answer: The fundamental difference between the XPath and css selector is using an XPaths we can
traverse up in the document i.e. we can move to the parent elements. Whereas using a CSS
Answer: Both driver.get(“URL”) and driver.navigate().to(“URL”) commands are used to the navigate
Q275) How can we type text in a textbox element using the selenium?
Answer:
search anTextBox.sendKeys(“searchTerm”);
Answer: The same click() method used for the clicking buttons or radio buttons can be used for the
driver.findElement(By.id(“form1”)).submit();
Also, the click() method can be used for the same of purpose.
Answer:
The get WindowHandles() command on the returns a list of ids corresponding to the each window
driver.switchTo().window(handle);
Answer:
Whereas driver.getWindowHandles() returns an set of handles of the all that pages available.
Q282) How can we move to the particular frame in selenium?
Answer: The driver.switchTo() commands can be used for the switching to frames.
driver.switchTo().frame(“{frameIndex/frameId/frameName}”);
For locating an frame we can either use to the index (starting from 0), its name or Id.
Q283) Can we move back and forward in our browser using an selenium?
Answer:
Answer: We can maximize browser on window in selenium using that following command-
driver.manage().window().maximize();
Answer: Using getText() method we can on fetch the text over an element.
String text = driver.findElement(“elementLocator”).getText();
Q287) How can we find the value of the different attributes like name, class, value of
an element?
Answer: Using getAttribute(“{attributeName}”) method we can find to the value of different attrbutes
of an elements e.g.-
String valueAttribute =
Answer: An implicit wait is a type of wait which an waits for the specified time while locating an
element before an throwing NoSuchElementException. By default for selenium tries to find the
elements immediately when required without of any wait. So, it is good to use to implicit wait. This
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
Answer: An explicit wait is a type of the wait which is applied to an particular web element until to the
Answer: Some of the commonly used to expected conditions of an element that can be used with a
An stalenessOf(WebElement element)
An visibilityOf(WebElement element)
An visibilityOfElementLocated(By locator)
An invisibilityOfElementLocated(By locator)
An alertIsPresent()
An titleContains(String title)
An titleIs(String title)
An textToBePresentInElementLocated(By, String)
Answer: A fluent wait is a type of wait in which we can also for specify polling interval(intervals after
which driver will try to find to the element) along with the maximum timeout value.
.withTimeout(20, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring(NoSuchElementException.class);
);
Q293) What are the different keyboard operations that can be performed in the
selenium?
Answer: The different keyboard operations that can be performed in the selenium are-
.pressKey(“non-text keys”) – Used for keys like the control, function keys etc that are non-text.
.releaseKey(“non-text keys”) – Used in the conjuntion with keypress event to the simulate releasing
Q294) What are the different mouse an actions that can be performed?
An click(WebElement element)
An doubleClick(WebElement element)
An contextClick(WebElement element)
An mouseDown(WebElement element)
An mouseUp(WebElement element)
An mouseMove(WebElement element)
WebElement /element=driver.findElement(By.id(“elementId”));
action.doubleClick(element).perform();
WebElement element=driver.findElement(By.id(“elementId”));
action.contextClick(element).perform();
WebElement element=driver.findElement(By.id(“elementId”));
action.moveToElement(element).perform();
Answer: Using getCurrentURL() command we can fetch to the current page URL-
driver.getCurrentUrl();
Answer: Using driver.getTitle(); we can fetch the page title in the selenium. This method returns a
Answer: Using driver.getPageSource(); we can fetch the page source in the selenium. This method
Enroll Now!
Share on FacebookShare on TwitterShare on LinkedinShare on Pinterest
NO COMMENTS
LEAVE A REPLY
Your email address will not be published Required fields are marked *
Comment
You may use these HTML tags and attributes: <a href="" title=""> <abbr title="">
Name *
Email *
Website
Post Comment
Your Name *
Your Email *
Your Message
Talk to Advisor
C Pointers
Pega Interview Questions and Answers
What is Big Data Analytics?
SSIS Interview Questions and Answers
Oracle DBA Interview Questions and Answers
AWS Cognito
What Is Raspberry PI?
Linear Regression
Logistic Regression
Unix Interview Questions and Answers
COMPANY
About Us
Reviews
Why GangBoard?
Blog
WORK WITH US
Become an Instructor
Hire From GangBoard
Corporate Training