Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

By: Dharm Dev

Download as pdf or txt
Download as pdf or txt
You are on page 1of 54

By : Dharm Dev

1. What is Selenium?

 Selenium is one of the most popular


automated testing suites. Due to an open
source it has become one of the most
accepted tools amongst the testing
professionals.
 Selenium is a package of several testing
tools, so it is referred to as a Suite.
2. What are the different Selenium
Components?
The suite package constitutes of the following
sets of tools: -
 Selenium IDE
 Selenium RC
 Selenium WebDriver
 Selenium Grid
3. What are the testing types ,can be
supported by Selenium?
Selenium supports the following types of
testing: -
 Functional Testing
 Regression Testing
4. Why should Selenium be selected as a
test tool?
Selenium-
 is free and open source
 have a large user base and helping communities
 have cross Browser compatibility (Firefox, chrome,
Internet Explorer, Safari etc.)
 have great platform compatibility (Windows, Mac
OS, Linux etc.)
 supports multiple programming languages (Java,
C#, Ruby, Python, Pearl etc.)
5. What are the limitations of Selenium?
the limitations of Selenium are: -
 supports testing of only web based applications
 Mobile applications cannot be .
 Captcha and Bar code readers cannot be tested.
 User is expected to possess prior programming
language knowledge.
 Reports can only be generated using third party
tools like TestNG or Junit.
6. What are the different types of locators
in Selenium?
Locator can be termed as an address that
identifies a web element uniquely within the
webpage, Different types of locators are: -
ID ClassName
Name TagName
LinkText PartialLinkText
Xpath CSS Selector
7. What is Automation Testing?

 Automation testing is a process of


automating the manual process to test the
application/system under test.
 Automation testing involves use to a separate
testing tool, which lets you create test scripts,
which can be executed repeatedly and
doesn’t require any manual intervention.
8. What are the benefits of Automation
Testing?
Benefits of Automation testing are:-
 Supports execution of repeated test cases
 Enables parallel execution
 Encourages unattended execution
 Improves accuracy thereby reducing human
generated errors
 Saves time and money
9. What is Selenium IDE?

 Selenium IDE (Integrated Development


Environment) is a record and playback tool.
 It is distributed as a Firefox Plugin.
10. What is Selenese?

Selenese is the language which is used to write


test scripts in Selenium IDE.
11. What is Xpath?

 Xpath is used to find the Web Element in


Web Pages.
 It is also useful in identifying the dynamic
elements.
12. What is the difference between “/” and
“//” in Xpath?
 Single Slash “/” –
 “/” is used to create Xpath with absolute path.
 “/” start selection from the document node /
start node.
 Double Slash “//” –
 “//” is used to create Xpath with relative path.
 “//” start selection from anywhere within the
document.
13. What is difference between assert and
verify commands ?
 Assert: command checks whether the given
condition is true or false.
If condition is true then program control will
execute the next test step, else execution would stop
and no further test would be executed.
 Verify: command also checks whether the given
condition is true or false.
Irrespective of the condition being true or false,
the program execution doesn’t stop and all the test
steps would be executed.
14. What is Same Origin Policy & how it
can be handled?
 Same Origin policy prohibits JavaScript code from
accessing elements from a domain that is different
from where it was launched.
Eg. HTML code in www.facebook.com uses a
JavaScript program "randomfb.js". The same origin
policy will only allow randomfb.js to access pages
within facebook.com such as facebook.com/login,
or facebook.com/signup.
 In order to handle same origin policy, Selenium
Remote Control was introduced.
15. What do you mean by Selenium 1 &
Selenum 2?
 Selenium RC alone is also referred as
Selenium 1.
 Selenium RC and WebDriver, in a
combination are popularly known as
Selenium 2.
16. What is Selenium Grid?

Selenium Grid is a part of the Selenium


Suite that specializes on running multiple
tests across different browsers, operating
systems, and machines in parallel.
17. Which is the latest Selenium Tool ?

Webdriver is the Latest Selenium


tool.
18. How de we launch the browser using
WebDriver ?
The following syntax can be used to launch
Browser: -
WebDriver driver = new FirefoxDriver();
WebDriver driver = new ChromeDriver();
WebDriver driver = new InternetExplorerDriver();
19. What are the different types of
Drivers available in WebDriver ?
The different drivers available in WebDriver are:-
 FirefoxDriver
 InternetExplorerDriver
 ChromeDriver
 SafariDriver
 OperaDriver
 AndroidDriver
 IPhoneDriver
 HtmlUnitDriver
20. What are the different types of
waits available in WebDriver ?

There are two types of waits available in


WebDriver:-
1. Implicit Wait
2. Explicit Wait
21. What is the different between
Implicit wait and Explicit Wait ?
 Implicit Wait: are used to provide a default
waiting time (say 30 seconds) between each
consecutive test step/command across the
entire test script.
 Explicit Wait: are used to halt the execution
till the time a particular condition is met or the
maximum time has elapsed.
Unlike Implicit waits, explicit waits
are applied for a particular instance only.
22. What is the different between
driver.close() & driver.quit() command ?
 close(): WebDriver’s close() method closes the
web browser window that the user is currently
working on .
 quit(): quit() method closes down all the
windows that the program has opened.

Both commands neither requires any


parameter nor does is return any value.
23. How to type in a textbox using
Selenium ?

By using sendkeys(“String”), we can


enter string in textbox.

Syntex:
driver.findElement(By.xpath(".//*[@id='nam
efield']")).sendKeys("Dharm");
24. How can we get text of a web element
in selenium ?

By using gettext(), we can get text of


a Web element.

Syntex:
String address= driver.findElement(By.xpath
(".//*[@id=‘address']")). gettext();
25. How can we submit a form in
selenium ?

The submit() method is used to


submit a form. This is an alternative to
clicking the form's submit button.
Syntex:
driver.findElement(By.xpath(".//*[@id=‘sub
mit']")). submit();
26. What is the different between
setSpeed() & sleep() method ?
Both methods delay the speed of execution.
 Thread.sleep(): will stop current thread for
the specific period of time.
Syntex: Thread.sleep(2000);

 setSpeed(): set execution speed for specific


amount of time, for every selenium command.
Syntex: selenium.setSpeed("2000");
27. How to select value in a dropdown ?
Value in the drop down can be selected
using WebDriver’s Select class.
Value can be selected by-
 selectByValue

 selectByVisibleText

 selectByIndex

Syntex:
Select dropdown=new Select(driver.findElement
(By.xpath(".//*[@id=‘submit']")).selectByIndex(1);
28. What are the different types of
navigation commands?
Different navigation commands are-
 navigate().back() – takes back the user to
the previous webpage in the web browser’s
history.
Syntex: driver.navigate().back();
 navigate().forward() –navigate to next web
page with reference to the browser’s history.
Syntex: driver.navigate().forward();
 navigate().refresh() – This command
refresh the current web page there by
reloading all the web elements.
Syntex: driver.navigate().refresh();
 navigate().to() – This command launch a
new web browser window and navigate to the
specified URL.
Syntex:
driver.navigate().to(“https://google.com”);
29. When do we use findElement() and
findElements() ?
 findElement(): is used to find the first element in the
current web page matching to the specified locator value
Syntax: WebElement element = driver.findElements
(By.xpath(“//div[@id=’list’]//ul//li”));
 findElements(): is used to find all the elements in the
current web page matching to the specified locator
value. all the matching elements would be fetched and
stored in the list of WebElements.
Syntax: List <WebElement> elementList =
driver.findElements(By.xpath(“//div[@id=list’]//ul//li”));
30. Can Selenium handle window based Popup?
windows pop up cannot be handled using
Selenium, because Selenium is an automation
testing tool which supports only web
application testing.
There are several third party tools available
for handling window based pop ups along with
the selenium like AutoIT, Robot class etc.
31. How Can Selenium handle web based Popup?
WebDriver offers a very efficient way to handle these pop
ups using Alert interface. There are the four methods:
 void dismiss() –This method clicks on the “Cancel”
button as soon as the pop up window appears.
 void accept() – method clicks on the “Ok” button as
soon as the pop up window appears.
 String getText() – The getText() method returns the
text displayed on the alert box.
 void sendKeys(String stringToSend) –method enters
the specified string pattern into the alert box.
Syntax: driver.switchTo().alert().accept();
32. How can we find if an element is
displayed on screen?
WebDriver facilitates following methods
to check the visibility of the web elements.
These web elements can be buttons, drop
boxes, checkboxes, radio buttons, labels etc.
 isDisplayed()
 isSelected()
 isEnabled()
Syntax: boolean button = driver.findElement
(By.id(“next”)).isDisplayed();
33. How to click on a hyper link using
linkText?
We can use these element locators for
locating hyperlink text.
 By linkText(“String”);
 By partialLinkText(“String”);
“partialLinkText is accessing links using a
portion of their link text”.
Syntex:
driver.findElement(By.linkText(“google")).click();
34. How to mouse hover on a web
element using WebDriver?
we used Action Interface to mouse hover
on a web element (eg. drop down) which
then opens a list of options.
Syntex:
Actions actions=new Actions(driver);
actions.moveToElement(driver.findElement(By.id(“se
x"))).perform();
driver.findElement(By.id(“male")).click();
35. How to retrieve css properties of an
element?
The values of the css properties can be
retrieved using a get() method:

Syntax:
driver.findElement(By.id(“id”)).getCssValu
e(“font-size”);
36. How to assert title of the web page?

We can verify the title of the web page by


assertTrue

Syntex:
assertTrue(“The title of the window is
incorrect.”,driver.getTitle().equals(“Title of
the page”));
37. How to select a value in dropdown?

Value in the drop down can be selected


using WebDriver’s Select class.
Syntex:
 selectByValue:
Select value = new Select(driver.findElement(By.id
(“Sex”)) .selectByValue(“male”));
 selectByVisibleText:
 selectByIndex:
38. What is Junit ?

Junit is a unit testing framework introduced


by Apache. Junit is based on Java.
39. What are Junit annotations ?
The List of frequently used Junit Annotations are:
 @Test:
 @Before:
 @After:
 @BeforeClass:
 @AfterClass:
 @Ignore:
40. What is TestNG and how is it better
then Junit?
TestNG is a Testing framework that overcomes
the limitations of another popular testing
framework called JUnit. The "NG" means "Next
Generation".
There are three major advantages of TestNG
over JUnit:
 Annotations are easier to understand
 Test cases can be grouped more easily
 Parallel testing is possible
41. What is Test Automation Framework?

Framework is a constructive blend of various


guidelines, coding standards, concepts, processes,
practices, project hierarchies, modularity, reporting
mechanism, test data injections etc. to pillar
automation testing.
42. What are the advantages of Test
Automation Framework?
Advantage of Test Automation framework are:
 Reusability of code
 Maximum coverage
 Recovery scenario
 Low cost maintenance
 Minimal manual intervention
 Easy Reporting
42. What are the different types of
Framework?
the different types of frameworks are:
 Module Based Testing Framework:
 Library Architecture Testing Framework:
 Data Driven Testing Framework:
 Keyword Driven Testing Framework:
 Hybrid Testing Framework:
 Behavior Driven Development
Framework:
43. How can we read test data from
excels?
Test data can efficiently be read from
excel using JXL or POI API.
44. Can WebDriver test mobile
Applications ?
WebDriver cannot test Mobile applications.
WebDriver is a web based testing tool,
therefore applications on the mobile
browsers can be tested.
45. Can Captcha be automated ?

No, captcha and bar code reader cannot


be automated.
46. What is Object Repository?

Object Repository is a term used to refer


to the collection of web elements belonging
to AUT along with their locator values.
Object Repository is used to store
locators in a centralized location instead of
hard coding them within the scripts.
47. How can we create Object Repository in
Selenium?
In Selenium, objects can be stored in an
excel sheet which can be populated inside
the script whenever required.
48. What are the 5 different exceptions we
had in Selenium WebDriver?
5 different exceptions in Selenium WebDriver
are:-
 WebDriverException
 NoAlertPresentException
 NoSuchWindowException
 NoSuchElementException
 TimeoutException
49. What are the Breakpoint and Startpoint
in Selenium?
 Breakpoints: When implement a breakpoint
in code, the execution will stop right there.
This helps us to verify that code is working as
expected.
 Startpoints: Startpoint indicates the point
from where the execution should begin.
Startpoint can be used when we want to run
the testscript from the middle of the code or a
breakpoint.
50. How can we switch back from a frame
in Selenium?
To switch back from a frame, we use
defaultContent() method ,
Syntax :
driver.switchTo().defaultContent();

You might also like