0% found this document useful (0 votes)
50 views32 pages

Automation Test

Automation testing notes

Uploaded by

wakarsheetal88
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views32 pages

Automation Test

Automation testing notes

Uploaded by

wakarsheetal88
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 32

Selenium : Selenium is a free (open source) Test automation library.

It is used
to automate Web and Mobile environments. It consists of

->Selenium IDE (Browser Addon – Record and Playback Tool)


->SeleniumWebDriver
->Selenium Grid (Distributed Testing)

Selenium supports scripting in languages like Java, C#, Python, Ruby, PHP, Perl,
Javascript

14) Tell me about QTP?

QTP (Quick Test Professional) is now known as HP UFT. It is a commercial


automation tool and supports a very wide range of test environments Web,
Desktop, SAP, Delphi, Net, ActiveX, Flex, Java, Oracle, Mobile, PeopleSoft,
PowerBuilder, Siebel, Stingray, Visual Basic amongst others.The scripting language is
VBScript. The tool gels well with HP ALM (Test Management Tool) and HP
LoadRunner (Performance Testing Tool).

Salient features of QTP include Business Process Testing, keyword driven


framework, XML support, robust checkpoints, test results.

Q.What are selenium commands and types?

Selenium Commands called as selenese:

 Actions: Click this link,Open,ClickandWait,WaitForPageToLoad,WaitForElementPresent

 Accessors:StoreTitle,StoreAllButtons,StoreAllFields,StoreAllLinks,StoreAllWindowTitles,
StoreAllWindowNames,StoreText,Store Value

 Assertions or Asserts:

➢ Assert: If fail aborted

➢ VerifyText:If verify fail continue

➢ Wait :Wait for condition to true


Q. Verify Commands:

Verify title,Assert title,VerifyTextPresent,VerifyElementPresent,VerifyText,VerifyTable,

Wait ForPageToLoad,WaitForElementPresent.

1. What is automation testing?


Automation testing is the process of automating the manual testing of the application under test
(AUT) or the system under test (SUT). It includes the involvement of testing tools that help us
create test scripts, which can be used repeatedly without any human intervention.

3. Mention some of the popular tools used for automation testing.


Selenium ,Rational Robot,HP Unified Functional Testing (UFT),IBM Rational Functional Tester.

4. What is a locator? How can you find elements in Selenium?


Selenium uses locators to find and match the elements of a web page that it needs to interact
with. here are different types of Selenium locators to identify various web elements on a web
page:
ID,Name,Class,Partial Link,X path,CSS Selector,Link Text
Locators locate GUI elements by selenium IDE means Selenium IDE uses locators to locate GUI
elements
1.ID 2.Name 3.Link Text 4.CSS selector 5.Tag&ID 6.Tag&Class 7.TagAndAttribute
8.DOM-GetElementById 9.DOM-GetElementByName 10.DOM-Name 11.DOM-Index 12.Xpath

5. What are the test types supported by Selenium?


For testing web-based applications, Selenium can be used.The test types supported by Selenium
are:
Functional testing: It verifies if each function of a software application performs in accordance
with specific requirements. This testing primarily involves black-box testing, and it is not
concerned about the source code of the application.
Regression testing: It is nothing but a full or partial selection of the already executed test cases to
be re-executed to ensure whether the existing functionalities work fine.

6. What is Xpath?
While DOM is the recognized standard way for navigating through an HTML element tree, XPath is
the navigation tool used to locate a web element based on its XML path.
XML stands for ‘Extensible Markup Language’ and is used to store, organize, and transport
arbitrary data. It stores data in a key–value pair that is very much similar to HTML tags. Both being
markup languages and falling under the same umbrella, XPath can be used to locate HTML
elements.
The fundamental concept behind locating elements using XPath is traversing between various
elements across the entire page and thus enabling a user to find an element with the reference of
another element.

7. Explain the difference between single slash and double slash in Xpath.
Single slash (/): Single slash is used to create an XPath with an absolute path. In this case, the
XPath would start selection from the document’s start node.

Double slash (//): Double slash is used to create an XPath with a relative path. In this case, the
XPath would start selection from anywhere within the document.
8. Why should you use Selenium for test automation?
=>Selenium should be used for test automation as it:
Is a free and open-source tool
Has a large user base and community support
Has cross-browser compatibility (Firefox, Chrome, Internet Explorer, Safari, etc.)
Has great platform compatibility (Windows, Mac OS, Linux, etc.)
Supports multiple programming languages (Java, C#, Ruby, Python, Perl, etc.)
Has fresh and regular repository developments
Supports distributed testing.

9. Does Selenium have any technical limitations? If so, what are those
limitations?
Yes, Selenium has a few limitations:
Testing of only web applications is possible using Selenium.
Testing of mobile applications or desktop applications is not possible.
Captcha and barcode readers cannot be tested using Selenium.
A third-party tool like TestNG or JUnit should be used to generate reports.
As Selenium is a free tool, there is no ready vendor support through which users can find various
helping communities.Prior programming language knowledge is expected from users.

10. What is an object repository?


An object repository allows testers to accumulate web elements of the application under test
(AUT), along with their locator values, in one or more centralized locations as restricted to hard-
coding them within the test scripts.

11. What is the difference between type keys and type commands?
TypeKeys() will trigger JavaScript events, while type() won’t. TypesKeys collects different value
attributes using JavaScript. Whereas, the type commands imitate an actual user typing.

12. What are the advantages of Selenium?


Selenium is a purely open-source and portable automation testing tool.
It supports different languages such as C#, PHP, Java, Perl, Python, JS, and Groovy.
It also supports different OS, including Windows, Linux, UNIX, and Mac OS.
It provides powerful methods such as Xpath, DOM, and CSS to locate elements.
Since it is an open-source tool, developers can customize the code. Also, the developer community
is supported by Google.

13. Define automation testing, and list down its advantages.


Automation testing or test automation is the process of automating the testing process by using
tools to write and execute test cases without any human intervention. It allows us to create scripts
that can be executed frequently and generate detailed test reports of the application.
Its advantages are as given below:
It helps in the performance and functional testing of an application.
It makes the execution of repeated test cases easy.
It supports the parallel execution of multiple test cases.
It boosts the accuracy and efficiency of the application by cutting down the chances of human
error.
It easily performs testing on a large-scale test matrix.
It saves time and money by reducing the burden of arbitrary tasks.

15. How many types of WebDriver APIs are available in Selenium?


The following is the list of WebDriver APIs:
AndroidDriver,ChromeDriver,EventFiringWebDriver,FirefoxDriver,HTMLUnitDriver,InternetExplore
rDriver,iPhoneDriver,iPhoneSimulatorDriver,RemoteWebDriver

16. What is an exception test in Selenium?


An exception test is a test that looks forward to an exception to be thrown inside a test class. It
anticipates the @Test annotation followed by the expected exception name. For example,
@Test(expectedException = NoSuchElementException.class) is an exception test for missing
elements in Selenium.

17. What is POM (Page Object Model)? What are its advantages?
Page Object Model is a design pattern used to create object repositories for the web UI elements.
Every web page of an application has a corresponding page class that is responsible for locating
the web elements and performing actions on them.
Its advantages are as follows:
It provides support to separate operations and flows on the UI from verification, hence improving
code readability.
As the object repository is independent of test cases, multiple tests can use the same object
repository.It increases the reusability of the code

18. What are the different types of annotations used in Selenium?


Explain the JUnit annotation linked with Selenium
In Java, a special form of syntactic metadata can be added to Java source code, which is known as
‘annotations’. Variables, parameters, packages, methods, and classes are annotated. Some of the
JUnit annotations are:
Test,Before,After,Ignore,BeforeClass,AfterClass,RunWith

JUnit annotations linked with Selenium are:

@Test: The @Test annotation finds a method to be a test method. When used before a test
method, it is mentioned as ‘@Test’; it informs the JUnit framework that the following method is a
test method.

@Before: The @Before annotation is used to find the method that is executed before executing
the test method. This method can be used to set up the test environment.

@After: The @After annotation is a method that is executed after executing the test method. This
method can be used to do a teardown, i.e., it is a method used to delete all temporary data, set up
default values, clean up the test environment, etc.

@BeforeClass: The @BeforeClass method is used only once before the start of all tests. Basically,
this is used to perform cumbersome activities, like connecting to a database.

@AfterClass: The @AfterClass method is used only once after executing all tests. This is used to
carry out clean-up activities, like disconnecting from a database.

19. Why do testers choose Selenium over QTP?


Selenium is more widely used than QTP since:
Selenium is an open-source tool, whereas QTP is a profitable tool.
Selenium is used specifically for testing web-based applications, while QTP can be used for testing
client–server applications too.Selenium supports multiple browsers like Firefox, IE, Opera, Safari,
etc. and has multiple operating systems compatibility too. Selenium-supported OS platforms are
Windows, Mac, Linux, etc. On the other hand, QTP is limited to Internet Explorer on Windows
Selenium supports multi-programming language compatibility. Languages supported by Selenium
are Python, Ruby, Perl, etc. But, QTP supports only VBScript

20. What are the four elements that you have to pass in Selenium?
Four parameters that need to be passed in Selenium are:
Host, Port number ,Browser ,URL

22. What are data-driven framework and keyword-driven framework?


A data-driven framework in Selenium is an approach of separating a ‘dataset’ from the actual ‘test
case’ (code). This framework is completely dependent on the input test data. The test data is
inserted from external sources, such as from an Excel file, a CSV file, or from any database. It also
allows us to easily control how much data needs to be tested. We can easily increase the number
of test parameters by adding more username and password fields to the Excel file (or other
sources).
A keyword-driven framework is an extension to the data-driven testing framework in the sense
that it not only isolates the test data from the scripts but also keeps the particular section of the
code belonging to the test script in an external data file. These sets of code are known as
keywords, and hence the framework is so named. Keywords are self-guiding and work based on
what actions need to be performed on the application.

23. How will you use Selenium to upload a file?


If the file is on the same machine or in a mapped network drive, it is really straightforward: We
have to just type the ‘path’ of the file in the FileUpload control.

Example:
driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")
element.send_keys("C:\myfile.txt")

24. What is the difference between getwindowhandles() and


getwindowhandle()?
getwindowhandles(): It is used to get the address of all open browsers, and its return data type is
Set<String>.
getwindowhandle(): It is used to get the address of the current browser where the control is, and
its return type is a string data type.
25. What is Selenese, and what are the three types of Selenese?
Selenese is a set of commands in Selenium used for running a test.
Three types of Selenese are as follows:
Actions: They are used for performing interactions and operations with the target elements.
Accessors: They are used for storing values in a variable.
Assertions: They are used as a checkpoint.

26. If you want to insert a breakpoint in Selenium IDE, how can you do
that?
To insert a breakpoint:
First, select ‘Toggle Breakpoint’ by right-clicking on the command in Selenium IDE
Then, press ‘B’ on the keyboard and select the command
The same step should be repeated for deselecting a breakpoint

27. How do you launch the web browser using WebDriver?


The following syntax can be used to launch the browser corresponding to the system’s operating
system:
WebDriver driver = new FirefoxDriver();
Or
WebDriver driver = new InternetExplorerDriver();
Or
WebDriver driver = new ChromeDriver();

28. List down some of the technical challenges with Selenium .

• Testing a Windows application: Selenium is just a web-based driver. It does not support
Windows-based apps and only supports web apps.

• Testing mobile apps: With the help of Selenium, we can test web apps on any OS and
browser that run on desktops. But, we cannot test mobile apps with Selenium because it
does not work with OS such as Android and iOS. However, there is an alternative for this,
i.e., Appium. It is an open-source automation testing tool that uses the WebDriver protocol
to drive native, hybrid, and iOS and Android, which is built specifically for testing mobile
apps.

• Limited reporting: It is one of the key challenges. In Selenium, we cannot generate efficient
and accurate reports. Accurate reports help developers fix all bugs and errors. We can
create reports using TestNG or ExtentReports.

• Handling dynamic elements: With the surge in the use of web apps, the management of
dynamic elements should be as much efficient as possible. When a web page loads, the
content present on the page changes depending on the user, location, and other factors.
Most of today’s web apps are dynamic in nature for better user experience, e.g., e-
commerce websites. In Selenium automation, the handling of dynamic web content is a
major challenge. However, Selenium provides an explicit wait feature, where we can set a
time interval for the automation testing process to hold the process for the new content to
load. Also, another alternative is to utilize the implicit wait feature.

• Handling page load: Some of the web pages in a web app are user-specific. They load
elements depending on the user. Also, some elements may be loaded depending on the
user’s previous activities. During background processes, the Selenium script might not be
able to identify a specific element. To overcome this, we can use explicit waits to provide
sufficient time to load and discover the element.

• Handling pop-up windows: Whenever any simple, prompt, or confirmation alert pops up, it
is difficult to automate it. Windows-based OS alerts are beyond Selenium’s capabilities as
they are part of the OS instead of the browser. However, Selenium WebDriver can utilize
multiple windows, and the web-based alerts can easily be handled with the help of the
switchTo method. It manages the OS-based pop-ups while keeping the browser running in
the background.

29. What is the difference between setSpeed() and sleep() methods?


Both setSpeed() and Sleep() in Selenium are used to delay the speed of execution.
setSpeed: Sets the execution speed with a delay of milliseconds, followed by the Selenium
operation. By default, the delay is 0 milliseconds.
sleep: Causes the suspension of execution of the current thread for a specified period.

30. What are the different types of waits available in WebDriver?


There are two types of waits available in WebDriver:
Implicit wait: These waits are used to provide a default waiting time (say, 30 seconds) between
the consecutive test steps across the entire test script. Hence, the subsequent test step would only
be executed when the 30 seconds are over after executing the previous test step.

Explicit wait: These waits are used to halt the execution until a particular condition is met or the
maximum time has elapsed.
31. How do you handle a frame in WebDriver?
An iframe (an acronym for ‘inline frame’) is used to insert another document within the current
HTML document.
Selecting iframe by ID:
driver.switchTo().frame(“ID of the frame“);

Locating iframe using the tagName:


driver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0));

Locating iframe using index:


frame(index)
driver.switchTo().frame(0);
frame(“Name of the Frame”)

driver.switchTo().frame(“name of the frame”);


frame(WebElement element)

Select Parent Window


driver.switchTo().defaultContent();

32. How do you set the test case priority in TestNG?


Setting Priority in TestNG:
Test Execution Sequence:
Method1
Method2
Method3

33. What are the different types of frameworks?


Different types of frameworks are as follows:
Module-based testing framework : This framework divides the entire application under test (AUT)
into a number of logical and isolated modules. For each module, we create a separate and
independent test script. Thus, when these test scripts are taken together, it builds a larger test
script representing more than one module.

Library architecture testing framework: Instead of dividing AUT into test scripts, with this
framework, we segregate the application into functions or rather common functions that can be
used by the other parts of the application as well. Thus, we create a common library constituting
common functions for AUT. Therefore, these libraries can be called from the test scripts whenever
required.

Data-driven testing framework: The data-driven testing framework helps us segregate the test
script logic and the test data from each other. It lets us store the test data into an external
database. The data is conventionally stored in ‘key–value’ pairs. Keys can be used to access and
populate the data within the test scripts.

Keyword-driven testing framework: The keyword-driven testing framework is an extension to the


data-driven testing framework in the sense that it not only segregates the test data from the
scripts but also keeps a certain set of codes belonging to the test script in an external data file.

Hybrid testing framework: A hybrid testing framework is a combination of more than one of the
above-mentioned frameworks. The best thing about such a setup is that it leverages the benefits
of all kinds of associated frameworks.

Behavior-driven development framework: The behavior-driven development framework allows


the automation of functional validations in an easily readable and understandable format for
Business Analysts, Developers, Testers, etc.

34. Describe the difference between Selenium and QTP.

Feature Selenium Quick Test Professional (QTP)


It supports almost all popular QTP supports Internet Explorer, Firefox,
Browser
browsers: Firefox, Chrome, Safari, and Chrome. It only supports Windows
compatibility
Internet Explorer, Opera, etc. operating system
It is distributed as an open-source It is distributed as a licensed tool and is
Distribution
tool and is freely available commercialized
Application under It supports the testing of web-based It supports the testing of both web-
test (AUT) applications only based and Windows-based applications
Object repository needs to be created QTP automatically creates and
Object repository
as a separate entity in Selenium maintains the object repository
It supports multiple programming
Language support languages like Java, C#, Ruby, Python, It supports only VBScript
Perl, etc.
As Selenium is a free tool, users
Users can easily get the vendor’s
Vendor support would not get the vendor’s support in
support if they face any issues
troubleshooting issues

35. In Selenium, what are breakpoints and start points?


Breakpoints: Breakpoints are used to stall the execution of the test. The execution will stop
whenever a breakpoint is implemented, and this will help us check whether the code is working
properly or not.

Start points: Start points are the points from where the execution should begin. Start points can
be used when we want to run the test script from the middle of the code or after a breakpoint.

36. Mention the need for session handling while working with Selenium.
While working with Selenium, we need session handling. This is because, during test execution,
Selenium WebDriver has to interact with the browser all the time to execute the given commands.
It is also possible that, before the current execution completes, someone else starts the execution
of another script in the same machine and in the same type of browser. So, to avoid such a
situation, we need session handling.

37. Mention the types of listeners in TestNG.


The types of listeners in TestNG are:
IannotationTransformer
Iconfigurable
IconfigurationListener
IexecutionListener
Ihookable
IinvokedMethodListener
IInvokedMethodListener2
ImethodInterceptor
Ireporter
IsuiteListener
ItestListener

38. How can we handle Windows-based popups with Selenium?


Selenium solely supports web application testing. It does not support the testing of Windows-
based applications or mobile applications. To handle Windows-based popups, third-party
intervention is required. AutoIt and Robot Class are examples of third-party tools that we can use
alongside Selenium to handle Windows-based popups.

39. For the database testing in Selenium WebDriver, what API is


required?
For the database testing in Selenium WebDriver, we need the JDBC (Java Database Connectivity)
API. It allows us to execute SQL statements.

40. How can you identify an object in Selenium?


We can use isElementPresent (string locator) to find an object in Selenium. It takes a locator as the
argument and, if found, returns a Boolean.

41. Mention the use of XPath in Selenium testing.


XPath is used to define web elements on a web page. The major advantage of XPath is that it helps
us in identifying the elements dynamically.
There are two types of Xpath:
Absolute Xpath
Relative Xpath

42. What is Selenium?


Selenium is a popular open-source software that is used to automate web-based applications. It is
a set of multiple software tools, and each tool has a different approach to automated testing.
Selenium has four major components, namely:

Selenium Integrated Development Environment


Selenium Remote Control
Selenium WebDriver
Selenium Grid

43. Can WebDriver test mobile applications?


No, WebDriver is a testing tool used for web-based applications. So, we cannot test mobile
applications with Selenium WebDriver.
44. Explain how Selenium Grid works.
Selenium Grid creates a test suite that works by forwarding test cases to the hub, and from there,
the test cases are redirected to Selenium Web Driver. Web Driver will then execute them in the
browser. The test suite allows for running tests in parallel.

45. Explain the difference between driver.close() and driver.quit()


commands in Selenium.
The following is the major difference between both commands:
close() command closes the currently active browser window, which is being used by the user or
which is currently accessed by the web driver.
quit() command closes all the windows opened by the program, unlike the driver.close ()
command.

46. Explain the difference between findElement() and findElements() in


Selenium.
The difference between findElement() and findElements() is as follows:
findElement(): It finds one particular element within the current page using the locating
mechanism. It returns the first element located by the locator.
findElements(): It finds all the elements within the current page with the help of the locating
mechanism. Hence, it returns a list of matching web elements found by the locator.

47. Mention the types of navigation commands.


The following are the navigation commands provided by Selenium:
navigate().back(): It takes the user back to the previous or the last-used web page, according to
the history.
navigate().forward(): It takes the user to the next web page, according to the browser history.
navigate().refresh(): It allows the user to refresh the current web page by reloading all the web
elements.
navigate().to(): It takes the user to a new web page in a new window, depending on the URL
specified.

48. How do you find broken links in Selenium WebDriver?


We can detect whether the given links are broken or not by using the following process:First,
accumulate all the links present on a web page using the <a> anchor tag. For each <a> tag, use the
attribute ‘href’ value to obtain the hyperlink
Send HTTP requests for each link and verify the HTTP response code
Based on the HTTP response code, determine if the link is valid or broken. Then, use the
driver.get() method to navigate to a URL, which will respond with a status of 200 – OK (200 – OK
indicates that the link is working). If we get any other status, then it indicates that the link is
broken Repeat the same process for all the links captured.
1) What is Selenium and what is composed of?
Selenium is a suite of tools for automated web testing. It is composed of
Selenium IDE (Integrated Development Environment) : It is a tool for recording and playing back.
It is a Firefox plug-in

Web Driver and RC: It provide the APIs for a variety of languages like Java, .NET, PHP, etc. With
most of the browsers Web driver and RC works.

Grid: With the help of Grid you can distribute tests on multiple machines so that test can be run
parallel which helps in cutting down the time required for running in browser test suites

5) List out the test types that are supported by Selenium?


For web based application testing selenium can be used
The test types can be supported are
a) Functional, Learn More about Functional Testing.
b) Regression
For post release validation with continuous integration automation tool could be used
a) Jenkins
b) Hudson
c) Quick Build
d) CruiseCont

6) Explain what is assertion in Selenium and what are the types of


assertion?
Assertion is used as a verification point. It verifies that the state of the application conforms to
what is expected. The types of assertion are “assert” , “verify” and “waitFor”.

8) Explain the difference between single and double slash in X-path?

Single slash ‘/ ’
Single slash ( / ) start selection from the document node
It allows you to create ‘absolute’ path expressions

Double Slash ‘// ’


Double slash ( // ) start selection matching anywhere in the document
It enables to create ‘relative’ path expressions

9) List out the technical challenges with Selenium?


Technical challenges with Selenium are
Selenium supports only web based applications
It does not support the Bitmap comparison
For any reporting related capabilities have to depend on third party tools
No vendor support for tool compared to commercial tools like HP UFT
As there is no object repository concept in Selenium, maintainability of objects becomes difficult

10) What is the difference between type keys and type commands ?
TypeKeys() will trigger JavaScript event in most of the cases whereas .type() won’t. Type key
populates the value attribute using JavaScript whereas .typekeys() emulates like actual user
typing.

11) What is the difference between verify and assert commands?


Assert: Assert allows to check whether an element is on the page or not. The test will stop on the
step failed, if the asserted element is not available. In other words, the test will terminated at the
point where check fails.
Verify: Verify command will check whether the element is on the page, if it is not then the test will
carry on executing. In verification, all the commands are going to run guaranteed even if any of
test fails.

13) While using click command can you use screen coordinate?
To click on specific part of element, you would need to use clickAT command. ClickAt command
accepts element locator and x, y co-ordinates as arguments-
clickAt (locator, cordString)

20) How you can use “submit” a form using Selenium ?


You can use “submit” method on element to submit form-
element.submit () ;
Alternatively you can use click method on the element which does form submission

21) What are the features of TestNG and list some of the functionality in
TestNG which makes it more effective?
TestNG is a testing framework based on JUnit and NUnit to simplify a broad range of testing needs,
from Unit Testing to Integration Testing. And the functionality which makes it efficient testing
framework are
->Support for annotations
->Support for data-driven testing
->Flexible test configuration
->Ability to re-execute failed test cases
23) Which attribute you should consider throughout the script in frame
for “if no frame Id as well as no frame name”?

You can use…..driver.findElements(By.xpath(“//iframe”))….


This will return list of frames.
You will need to switch to each and every frame and search for locator which we want.
Then break the loop

27) Explain how you can login into any site if it’s showing any
authentication popup for password and username?
Pass the username and password with url
Syntax-http://username: password@url
ex- http://creyate:[email protected]

28) Explain how to assert text of webpage using selenium 2.0 ?

WebElement el = driver.findElement(By.id(“ElementID”))
//get test from element and stored in text variable
String text = el.getText();
//assert text from expected
Assert.assertEquals(“Element Text”, text);

36) Explain how you can find broken images in a page using Selenium
Web driver ?
To find the broken images in a page using Selenium web driver is
Get XPath and get all the links in the page using tag name
In the page click on each and every link
Look for 404/500 in the target page title

37) Explain how you can handle colors in web driver?


To handle colors in web driver you can use
Use getCssValue(arg0) function to get the colors by sending ‘color’ string as an argument

38) Using web driver how you can store a value which is text box?

You can use following command to store a value which is text box using web driver
driver.findElement(By.id(“your Textbox”)).sendKeys(“your keyword”);
39) Explain how you can switch between frames?
To switch between frames webdrivers [ driver.switchTo().frame() ] method takes one of the three
possible arguments
A number: It selects the number by its (zero-based) index
A name or ID: Select a frame by its name or ID
Previously found WebElement: Using its previously located WebElement select a frame

40) Mention 5 different exceptions you had in Selenium web driver?


The 5 different exceptions you had in Selenium web drivers are
WebDriverException
NoAlertPresentException
NoSuchWindowException
NoSuchElementException
TimeoutException

41) Explain using Webdriver how you can perform double click ?
You can perform double click by using
Syntax- Actions act = new Actions (driver);
act.doubleClick(webelement);

42) How will you use Selenium to upload a file ?


You can use “type”command to type in a file input box of upload file. Then, you have to use
“Robot” class in JAVA to make file upload work.

43) Which web driver implementation is fastest?

HTMLUnit Driver implementation is fastest, HTMLUnitDriver does not execute tests on browser
but plain http request, which is far quick than launching a browser and executing tests

44) Explain how you can handle frames using Selenium 2.0 ?
To bring control on HTML frame you can use “SwitchTo” frame method-
driver.switchTo().frame(“frameName”);
To specify a frame you can use index number
driver.switchTo().frame(“parentFrame.4.frameName”);
This would bring control on frame named- “frameName” of the 4th sub frame names
“parentFrame”

46) Explain how you can switch back from a frame?

To switch back from a frame use method defaultContent()


Syntax-driver.switchTo().defaultContent();
49) Explain how you can use recovery scenario with Selenium?
Recovery scenarios depends upon the programming language you use. If you are using Java then
you can use exception handling to overcome same. By using “Try Catch Block” within your
Selenium WebDriver Java tests

50) Explain how to iterate through options in test script?


To iterate through options in test script you can loop features of the programming language, for
example to type different test data in a text box you can use “for” loop in Java
// test data collection in an array
String[ ] testData = { “test1” , “test2” , “test3” } ;
// iterate through each test data
For (string s: test data) { selenium.type ( “elementLocator”, testData) ; }

51) How can you prepare customized html report using TestNG in hybrid
framework ? Or how to create Html test report from test script?
There are three ways
Junit: With the help of ANT
TestNG: Using inbuilt default.html to get the HTML report. Also XST reports from ANT, Selenium,
Testng combinations
Using our own customized reports using XSL jar for converting XML content to HTML

67) What if you have written your own element locator and how would you
test it?

To test the locator one can use “Find Button” of Selenium IDE, as you click on it, you would see on
screen an element being highlighted provided your element locator is right or or else an error
message will be displayed.

68) What is regular expressions? How you can use regular expressions in
Selenium?
A regular expression is a special text string used for describing a search pattern. In Selenium IDE
regular expression can be used with the keyword- regexp: as a prefix to the value and patterns
needs to be included for the expected values.

69) What are core extension ?


If you want to “extend” the default functionality provided by Selenium Function Library , you can
create a Core Extension. They are also called “User Extension”. You can even download ready-
made Core Extension created by other Selenium enthusiats.
70) How will you handle working with multiple windows in Selenium ?
We can use the command selectWindow to switch between windows. This command uses the title
of Windows to identify which window to switch to.

71) How will you verify the specific position of an web element?
You can use verifyElementPositionLeft & verifyElementPositionTop. It does a pixel comparison of
the position of the element from the Left and Top of page respectively

72) How can you retrive the message in an alert box ?


You can use the storeAlert command which will fetch the message of the alert pop up and store it
in a variable.

73) What is selenium RC (Remote Control)?


Selenium IDE have limitations in terms of browser support and language support. By using
Selenium RC limitation can be diminished.
On different platforms and different web browser for automating web application selenium RC is
used with languages like Java, C#, Perl, Python.
Selenium RC is a java based and using any language it can interact with the web application.
Using server you can bypass the restriction and run your automation script running against any
web application.

74) Why Selenium RC is used?


Selenium IDE does not directly support many functions like condition statements, Iteration,
logging and reporting of test results, unexpected error handling and so on as IDE supports only
HTML language. To handle such issues Selenium RC is used it supports the language like Perl,
Ruby, Python, PHP using these languages we can write the program to achieve the IDE issues.

75) Explain what is the main difference between web-driver and RC ?


The main difference between Selenium RC and Webdriver is that, selenium RC injects javascript
function into browsers when the page is loaded. On the other hand, Selenium Webdriver drives
the browser using browsers built in support.

76) What are the advantages of RC?


Advantages of RC are
Can read or write data from/ to .xls, .txt, etc
It can handle dynamic objects and Ajax based UI elements
Loops and conditions can be used for better performance and flexibility
Support many Programming languages and Operating Systems
For any JAVA script enabled browser Selenium RC can be used
77) Explain what is framework and what are the frameworks available in RC?
A collection of libraries and classes is known as Framework and they are helpful when testers has
to automate test cases. NUnit, JUnit, TestNG, Bromine, RSpec, unittest are some of the
frameworks available in RC .

78) How can we handle pop-ups in RC ?


To handle pop-ups in RC , using selectWindow method, pop-up window will be selected and
windowFocus method will let the control from current window to pop-up windows and perform
actions according to script.

80) Can we use Selenium RC to drive tests on two different browsers on one operating
system without Selenium Grid?
Yes, it is possible when you are not using JAVA testing framework. Instead of using Java testing
framework if you are using java client driver of selenium then TestNG allows you to do this. By
using “parallel=test” attribute you can set tests to be executed in parallel and can define two
different tests, each using different browser.

81) Why to use TestNG with Selenium RC ?


If you want full automation against different server and client platforms, You need a way to invoke
the tests from a command line process, reports that tells you what happened and flexibility in how
you create your test suites. TestNG gives that flexibility.

82) Explain how you can capture server side log Selenium Server?
To capture server side log in Selenium Server, you can use command
java –jar .jar –log selenium.log

83) Other than the default port 4444 how you can run Selenium Server?
You can run Selenium server on java-jar selenium-server.jar-port other than its default port

84) How Selenium grid hub keeps in touch with RC slave machine?
At predefined time selenium grid hub keeps polling all RC slaves to make sure it is available for
testing. The deciding parameter is called “remoteControlPollingIntervalSeconds” and is defined in
“grid_configuration.yml”file

85) Using Selenium how can you handle network latency ?


To handle network latency you can use driver.manage.pageloadingtime for network latency

86) To enter values onto text boxes what is the command that can be used?
To enter values onto text boxes we can use command sendkeys()
87) How do you identify an object using selenium?
To identify an object using Selenium you can use
isElementPresent(String locator)
isElementPresent takes a locator as the argument and if found returns a Boolean

88) In Selenium what are Breakpoints and Startpoints?

Breakpoints: When you implement a breakpoint in your code, the execution will stop right there.
This helps you to verify that your code is working as expected.
StartpointsStartpoint :indicates the point from where the execution should begin. Startpoint can
be used when you want to run the testscript from the middle of the code or a breakpoint.

89) Mention why to choose Python over Java in Selenium?


Few points that favor Python over Java to use with Selenium is,
Java programs tend to run slower compared to Python programs.
Java uses traditional braces to start and ends blocks, while Python uses indentation.
Java employs static typing, while Python is dynamically typed.
Python is simpler and more compact compared to Java.

90) Mention what are the challenges in Handling Ajax Call in Selenium Webdriver?
The challenges faced in Handling Ajax Call in Selenium Webdriver are Using “pause” command for
handling Ajax call is not completely reliable. Long pause time makes the test unacceptably slow
and increases the testing time. Instead, “waitforcondition” will be more helpful in testing Ajax
applications. It is difficult to assess the risk associated with particular Ajax applications. Given full
freedom to developers to modify Ajax application makes the testing process challenging. Creating
automated test request may be difficult for testing tools as such AJAX application often use
different encoding or serialization technique to submit POST data.

91) Mention what is IntelliJ?


Intellij is an IDE that helps you to write better and faster code for Selenium. Intellij can be used in
the option to Java bean and Eclipse.

92) Mention in what ways you can customize TestNG report?


You can customize TestNG report in two ways,
Using ITestListener Interface
Using IReporter Interface

93) To generate pdf reports mention what Java API is required?


To generate pdf reports, you need Java API Itext.
94) Mention what is Listeners in Selenium WebDriver?
In Selenium WebDriver, Listeners “listen” to the event defined in the selenium script and behave
accordingly. It allows customizing TestNG reports or logs. There are two main listeners i.e.
WebDriver Listeners and TestNG Listeners.

96) Mention what is desired capability? How is it useful in terms of


Selenium?
The desired capability is a series of key/value pairs that stores the browser properties like browser
name, browser version, the path of the browser driver in the system, etc. to determine the
behavior of the browser at run time.
For Selenium,
It can be used to configure the driver instance of Selenium WebDriver.
When you want to run the test cases on a different browser with different operating systems and
versions.

97) For Database Testing in Selenium Webdriver what API is required?


For Database Testing in Selenium Webdriver, you need JDBC (Java Database Connectivity) API. It
allows you to execute SQL statements.

98) Mention when to use AutoIT?


Selenium is designed to automate web-based applications on different browsers. But to handle
window GUI and non-HTML popups in the application you need AutoIT. know more about How to
use AutoIT with Selenium

99) Mention why do you need Session Handling while working with
Selenium?
While working with Selenium, you need Session Handling. This is because, during test execution,
the Selenium WebDriver has to interact with the browser all the time to execute given commands.
At the time of execution, it is also possible that, before current execution completes, someone
else starts execution of another script, in the same machine and in the same type of browser. So
to avoid such situation you need Session Handling.

100) Mention what are the advantages of Using Git Hub For Selenium?
The advantages of Using Git Hub for Selenium are
Multiple people when they work on the same project they can update project details and inform
other team members simultaneously.
Jenkins can help you to build the project from the remote repository regularly. This helps you to
keep track of failed builds.
2) When will you automate a test?
Automation in preferred in following cases
Repetitive Tasks
Smoke and Sanity Tests
Test with multiple data set
Regression test cases

4) What are the steps involved in the Automation Process?


In the automation process, steps involved are
Selecting the Test tool
Define scope of automation
Planning, design, and development
Test execution
Maintenance

5) What are the points that are covered while planning phase of automation?
During planning phase of automation things which must be taken in concern are
Selection the “right” Automation tool
Selection Automation Framework if any
List of In scope and out of scope items for automation
Test Environment Setup
Preparing Grant Chart of Project timelines for test script development & execution.
Identify Test Deliverables

9) What is the scripting standard while performing automation testing?


While writing the scripts for automation, you must consider following things,
Uniform naming convention.
3 Lines of comments for every 10 lines of code
Adequate indentation.
Robust error handling and recovery scenario
Use of Frameworks wherever possible

12) Can list out some disadvantages of manual testing?


Manual Software Testing requires more time and more resources.
Inaccuracy
Executing same test case repeatedly is error prone and boring.
It is impractical to do manual testing on very large projects and time bounded projects.

-
C# Interview Questions-

Q #1) What is an Object and a Class?


Answer: Class is an encapsulation of properties and methods that are used to represent a real-
time entity. It is a data structure that brings all the instances together in a single unit.
Object is defined as an instance of a Class. Technically, it is just a block of memory allocated that
can be stored in the form of variables, array or a collection.

Q #2) What are the fundamental OOP concepts?


Answer: The four fundamental concepts of Object-Oriented Programming are:
Encapsulation: Here, the internal representation of an object is hidden from the view outside the
object’s definition. Only the required information can be accessed whereas the rest of the data
implementation is hidden.

->Abstraction: It is a process of identifying the critical behavior and data of an object and
eliminating the irrelevant details.

->Inheritance: It is the ability to create new classes from another class. It is done by accessing,
modifying and extending the behavior of objects in the parent class.

->Polymorphism: The name means, one name, many forms. It is achieved by having multiple
methods with the same name but different implementations.

Q #3) What is Managed and Unmanaged code?


Answer: Managed code is a code that is executed by CLR (Common Language Runtime) i.e all
application code is based on .Net platform. It is considered as managed because of the .Net
framework which internally uses the garbage collector to clear up the unused memory.

Unmanaged code is any code that is executed by application runtime of any other framework
apart from .Net. The application runtime will take care of memory, security and other
performance operations.

Q #4) What is an Interface?


Answer: Interface is a class with no implementation. The only thing that it contains is the
declaration of methods, properties, and events.

Q #5) What are the different types of classes in C#?


Answer: The different types of class in C# are:
Partial class: It allows its members to be divided or shared with multiple .cs files. It is denoted by
the keyword Partial.

Sealed class: It is a class that cannot be inherited. To access the members of a sealed class, we
need to create the object of the class. It is denoted by the keyword Sealed.
Abstract class: It is a class whose object cannot be instantiated. The class can only be inherited. It
should contain at least one method. It is denoted by the keyword abstract.

Static class: It is a class that does not allow inheritance. The members of the class are also static.
It is denoted by the keyword static. This keyword tells the compiler to check for any accidental
instances of the static class.

Q #6) Explain code compilation in C#.


Answer: Code compilation in C# includes the following four steps:
Compiling the source code into Managed code by C# compiler.
Combining the newly created code into assemblies.
Loading the Common Language Runtime(CLR).
Executing the assembly by CLR.

Q #7) What are the differences between a Class and a Struct?


Answer: Given below are the differences between a Class and a Struct:

Class Struct
Supports Inheritance Does not support Inheritance

Class is Pass by reference (reference type) Struct is Pass by Copy (Value type)
Members are private by default Members are public by default
Good for larger complex objects Good for Small isolated models
Can use waste collector for memory Cannot use Garbage collector and hence no
management Memory management

Q #8) What is the difference between the Virtual method and the Abstract method?
Answer: The Virtual method must always have a default implementation. However, it can be
overridden in the derived class, although it is not mandatory. It can be overridden using the
override keyword.
An Abstract method does not have an implementation. It resides in the abstract class. It is
mandatory that the derived class implements the abstract method. An override keyword is not
necessary here though it can be used.

Q #9) Explain Namespaces in C#.


Answer: They are used to organize large code projects. “System” is the most widely used
namespace in C#. We can create our own namespace and can also use one namespace in another,
which is called Nested Namespaces.
Q #10) What is “using” statement in C#?
Answer: “Using” keyword denotes that the particular namespace is being used by the program.
For Example, using System
Here, System is a namespace. The class Console is defined under System. So, we can use the
console.writeline (“….”) or readline in our program.

Q #11) Explain Abstraction.


Answer: Abstraction is one of the OOP concepts. It is used to display only the essential features of
the class and hide unnecessary information.
Let us take an example of a Car:

A driver of the car should know the details about the Car such as color, name, mirror, steering,
gear, brake, etc. What he doesn’t have to know is an internal engine, exhaust system.

So, Abstraction helps in knowing what is necessary and hiding the internal details from the outside
world. Hiding of the internal information can be achieved by declaring such parameters as Private
using the private keyword.

Q #12) Explain Polymorphism?


Answer: Programmatically, Polymorphism means the same method but different implementations.
It is of 2 types, Compile-time and Runtime.
Compile-time polymorphism is achieved by operator overloading.
Runtime polymorphism is achieved by overriding. Inheritance and Virtual functions are used
during Runtime polymorphism.
For Example, If a class has a method Void Add(), polymorphism is achieved by overloading the
method, that is, void Add(int a, int b), void Add(int add) are all overloaded methods.

Q #13) How is Exception Handling implemented in C#?


Answer: Exception handling is done using four keywords in C#:
try: Contains a block of code for which an exception will be checked.
catch: It is a program that catches an exception with the help of the exception handler.
finally: It is a block of code written to execute regardless of whether an exception is caught or not.
Throw: Throws an exception when a problem occurs.

Q #14) What are C# I/O classes? What are the commonly used I/O classes?
Answer: C# has System.IO namespace, consisting of classes that are used to perform various
operations on files like creating, deleting, opening, closing, etc.
Some commonly used I/O classes are:
File – Helps in manipulating a file.
StreamWriter – Used for writing characters to a stream.
StreamReader – Used for reading characters to a stream.
StringWriter – Used for reading a string buffer.
StringReader – Used for writing a string buffer.
Path – Used for performing operations related to the path information.
Q #15) What is StreamReader/StreamWriter class?

Answer: StreamReader and StreamWriter are classes of namespace System.IO. They are used
when we want to read or write charact90, Reader-based data, respectively.

Some of the members of StreamReader are: Close(), Read(), Readline().

Members of StreamWriter are: Close(), Write(), Writeline().

Class Program1

using(StreamReader sr = new StreamReader(“C:\ReadMe.txt”)

//----------------code to read-------------------//

using(StreamWriter sw = new StreamWriter(“C:\ReadMe.txt”))

{
//-------------code to write-------------------//

}
}

Q #16) What is a Destructor in C#?


Answer: Destructor is used to clean up the memory and free the resources. But in C# this is done
by the garbage collector on its own. System.GC.Collect() is called internally for cleaning up. But
sometimes it may be necessary to implement destructors manually.
For Example:
~Car()
{
Console.writeline(“….”);
}

Q #17) What is an Abstract Class?


Answer: An Abstract class is a class which is denoted by abstract keyword and can be used only as
a Base class. This class should always be inherited. An instance of the class itself cannot be
created. If we do not want any program to create an object of a class, then such classes can be
made abstract.
Any method in the abstract class does not have implementations in the same class. But they must
be implemented in the child class.
For Example:
abstract class AB1
{
Public void Add();
}
Class childClass : AB1
{
childClass cs = new childClass ();
int Sum = cs.Add();
}
All the methods in an abstract class are implicitly virtual methods. Hence, the virtual keyword
should not be used with any methods in the abstract class.

Q #18) What are Boxing and Unboxing?


Answer: Converting a value type to reference type is called Boxing.
For Example:
int Value1 -= 10;
//————Boxing——————//
object boxedValue = Value1;

Explicit conversion of same reference type (created by boxing) back to value type is called
Unboxing.
For Example:
//————UnBoxing——————//
int UnBoxing = int (boxedValue);

Q #19) What is the difference between Continue and Break Statement?


Answer: Break statement breaks the loop. It makes the control of the program to exit the loop.
Continue statement makes the control of the program to exit only the current iteration. It does
not break the loop.

Q #20) What is the difference between finally and finalize block?


Answer: finally block is called after the execution of try and catch block. It is used for exception
handling. Regardless of whether an exception is caught or not, this block of code will be executed.
Usually, this block will have a clean-up code.

Finalize method is called just before garbage collection. It is used to perform clean up operations
of Unmanaged code. It is automatically called when a given instance is not subsequently called.
Q #21) What is an Array? Give the syntax for a single and multi-dimensional array?
Answer: An Array is used to store multiple variables of the same type. It is a collection of variables
stored in a contiguous memory location.
For Example:
double numbers = new double[10];
int[] score = new int[4] {25,24,23,25};
A single dimensional array is a linear array where the variables are stored in a single row. Above
example is a single dimensional array.
Arrays can have more than one dimension. Multidimensional arrays are also called rectangular
arrays.
For Example, int[,] numbers = new int[3,2] { {1,2} ,{2,3},{3,4} };

Q #22) What is a Jagged Array?


Answer: A Jagged array is an array whose elements are arrays. It is also called as the array of
arrays. It can be either single or multiple dimensions.
int[] jaggedArray = new int[4][];

Q #23) Name some properties of Array.


Answer: Properties of an Array include:
Length: Gets the total number of elements in an array.
IsFixedSize: Tells whether the array is fixed in size or not.
IsReadOnly: Tells whether the array is read-only or not.

Q #24) What is an Array Class?


Answer: An Array class is the base class for all arrays. It provides many properties and methods. It
is present in the namespace system.

Q #25) What is a String? What are the properties of a String Class?


Answer: A String is a collection of char objects. We can also declare string variables in c#.
string name = “C# Questions”;
A string class in C# represents a string. The properties of the string class are:
Chars get the Char object in the current String.
Length gets the number of objects in the current String.

Q #26) What is an Escape Sequence? Name some String escape sequences in C#.
Answer: An Escape sequence is denoted by a backslash (\). The backslash indicates that the
character that follows it should be interpreted literally or it is a special character. An escape
sequence is considered as a single character.
String escape sequences are as follows:
\n – Newline character
\b – Backspace
\\ – Backslash
\’ – Single quote
\’’ – Double Quote

Q #27) What are Regular expressions? Search a string using regular expressions?
Answer: Regular expression is a template to match a set of input. The pattern can consist of
operators, constructs or character literals. Regex is used for string parsing and replacing the
character string.
For Example:
* matches the preceding character zero or more times. So, a*b regex is equivalent to b, ab, aab,
aaab and so on.
Searching a string using Regex:
static void Main(string[] args)
{

string[] languages = { "C#", "Python", "Java" };


foreach(string s in languages)
{
if(System.Text.RegularExpressions.Regex.IsMatch(s,"Python"))
{
Console.WriteLine("Match found");
}
}
}

The above example searches for “Python” against the set of inputs from the languages array. It
uses Regex.IsMatch which returns true in case if the pattern is found in the input. The pattern can
be any regular expression representing the input that we want to match.

Q #28) What are the basic String Operations? Explain.


Answer: Some of the basic string operations are:
Concatenate: Two strings can be concatenated either by using a System.String.Concat or by using
+ operator.

Modify: Replace(a,b) is used to replace a string with another string. Trim() is used to trim the string
at the end or at the beginning.

Compare: System.StringComparison() is used to compare two strings, either a case-sensitive


comparison or not case sensitive. Mainly takes two parameters, original string, and string to be
compared with.

Search: StartWith, EndsWith methods are used to search a particular string.


Q #29) What is Parsing? How to Parse a Date Time String?
Answer: Parsing converts a string into another data type.
For Example:
string text = “500”;
int num = int.Parse(text);

500 is an integer. So, the Parse method converts the string 500 into its own base type, i.e int.
Follow the same method to convert a DateTime string.
string dateTime = “Jan 1, 2018”;
DateTime parsedValue = DateTime.Parse(dateTime);

You might also like