0% found this document useful (0 votes)
168 views9 pages

Selenuim Training Notes

This document provides an overview of Selenium and its various tools. It discusses Selenium IDE, Selenium RC, Selenium WebDriver, and Selenium Grid. It also covers launching browsers, locators, handling dropdowns, alerts, frames, windows, and taking screenshots. Key points include that Selenium IDE only supports Firefox, WebDriver supports multiple programming languages and browsers, and Grid enables distributed testing on different machines.

Uploaded by

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

Selenuim Training Notes

This document provides an overview of Selenium and its various tools. It discusses Selenium IDE, Selenium RC, Selenium WebDriver, and Selenium Grid. It also covers launching browsers, locators, handling dropdowns, alerts, frames, windows, and taking screenshots. Key points include that Selenium IDE only supports Firefox, WebDriver supports multiple programming languages and browsers, and Grid enables distributed testing on different machines.

Uploaded by

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

20-04-2020:

1. Selenium used to automate only web-based applications not for windows-based client server
applications
2. It’s open source suite of tools, mainly used for functional and regression test automation
3. It will support various operating environments: windows, linux, MacOS etc., but UFT will support
only windows OS.
4. It supports various browser environments (Chrome. IE, Firefox, Safari). To launch different
browsers, we need to use browser drivers.
5. Selenium IDE will support only firefox browser.
6. Selenium supports various programing environments: Java, python, C#, Perl, Ruby, PHP but UFT
supports only VB script.
7. Most of the companies will use java for selenium.

History of selenium:

1. First came into market in 2004 and 2006 selenium web driver launched and In 2008 selenium
team merged all selenium tools to form a powerful tool called selenium 2.0

Selenium1: (Selenium IDE + Selenium RC +Selenium Grid)

Selenium 2: (Selenium IDE + Selenium RC +Selenium webdriver+Selenium Grid)

Selenium’s Tools suite:

Selenium IDE:

1. Record and play back feature


2. Firefox pulg-in
3. To create and execute the test cases

Features of IDE:

1. Create test case and test suites (recording feature or we can manually enter the commands
if you know them)
2. Edit test cases
3. Executing the test cases, test suites
4. Debug the test cases
5. Enhance the test cases
6. Export test cases
7. Default format of selenium ide is .html

Draw backs of IDE:

1. Supports only Firefox browser


2. It deosn’t support the programming features to enhance test case due to this it’s not applicable
for complex applications
3. It doesn’t support the data driven testing
4. No centralized maintenance of objects or elements
Selenium RC:

Selenium Web driver:

1. It’s a programming interface to create and execute the test cases


2. Selenium web driver supports various browsers to create and execute test case/test scripts
3. Available in the form of API
4. Only for web applications/browser-based applications
5. Supports multiple browsers
6. Version of web driver is 3.X i.e. 3.0,1,2

Drawbacks of selenium web driver:

1. It doesn’t generate detailed test report


2. No centralized maintenance of objects

Selenium Grid:

1. Not for test case design only for test case execution
2. Grid is used to execute the test cases across multiple browsers, operating environments and
machines in parallel
3. Selenium grid supports selenium RC tests as well as selenium web driver tests

Launching Firefox browser:

1. By using gecko driver we will launch the firefox. Gecko driver is a class in selenium we must
create object of gecko driver.
2. To launch the gecko driver we have another class called firefox driver and it’s available in
selenium we have to import it.
3. This firefox driver is implementing one interface called web driver.
4. If we are executing with out the driver ‘.exe’ file we will get following error: Exception in
thread "main" java.lang.IllegalStateException: The path to the driver
executable must be set by the webdriver.gecko.driver system property;
5. Same as firefox, chrome also follows the same above steps.

Basic methods:

 get() method is used to launch the specified URL in browser


 getTitle() method us used to get the title of current page
 getCurrentUrl() method is used to get the current url opened in browser
 getPageSource() method is used to get the current page source (contains html and java script
code).

Launching the safari driver: in mac open any browser and search for extension ‘Safari extension for
selenoum’go to downloads download the latest version
And add that extension in preferences.

--- now one more setting needs to be done in safari preferences section: enable ‘allow remote
automation’ preferencesadvanceselect check box show develop menu in menu barnow click on
develop menuyou will find option called ‘allow remote automation’ and select it

Whatever written after angular bracket ‘<’ is called html tag of that element. In selenium everything is
called elements.

 After the tag name it will have the attributes or properties.

Locators in Selenium:

1.Xpath: recommended to use only relative xpath

Absolute xpath: html/body/div[1]/div[5]

Relative xpath: //*[@id="content"]/p

2.id

3.name

4.linkText: only for links, all the links are represented by ‘a’ tag

5.PartialLinkText: we never use partial link text, it will be used when name of the link is long.

6. CSSSelector: For id put ‘#’ -- #input-firstname

If class is there—‘.’(class)

7.Class—but not recommended, class name can be duplicate for other element.

Priorities of locators:

1. ID
2. Xpath/CssSelector
3. Name
4. linkText
5. className

Handling Drop down:

There is class select class in selenium, just create the object of select class. We I must import it from
selenium support.

We don’t perform actions like send keys or click for drop downs. For handling dropdowns, we have few
methods in selenium:
1. selectByVisibleText() – it will select the option based on the visible text. Recommended to use
this method.
2. If we are trying to deselect the single option selected in drop down then we will get below error
Exception in thread "main" java.lang.UnsupportedOperationException: You may
only deselect options of a multi-select
3. getFirstSelectedOption() //to get the first selected option in dropdown it will work for both the
type of dropdowns.
4. getOptions();-- if we want to see all the options available we have to use for loop with size()
condition, if we are using this will get below error:
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 36,
Size: 36
In order to remove this error we need to use size()-1.

Handling java script Alert and pop-up:

In web application some time we came across the pop-up’s.

Alert() method will give alert class object reference of alert class.

We will use alert api to handle the popup’s.

Selenium can’t handle the windows popups. like uploading the file popup

Handling File upload:

For handling file upload it will opens the windows pop-up which cannot be handle by selenium but using
the selenium sendKeys() method we can upload file. For the ‘browse’ button make sure that it’s having
the type as ‘file’

Handling the frames:

Sometimes in page we have elements located inside the frame. If we are following the normal approach
the we will get errors like no element exception or element not found excetion. To handle the elements
present in frame we will use SwitchTo() metod.

Frame is having the two important properties called: index, name.


Handling browser windows:

Create reference for string type set class to store the multiple window id’s and use iterator to switch
between windows. Set will not store the values based on indexing.

Set object: set will not store the values based on the index. To get the value from set object we have to
use iterator () method. This iterator method will give you the iterator of string.

Mouse Movement Concept:

We can handle the mouse actions by using the ‘Actions’ class. For actions class we have to pass the
driver reference.

Actions action = new Actions(driver).

Whenever we are using actions class we need to use ‘build().perform()’

Drag and Drop:

For drag and drop also we need to use Actions class. First we need to click and hold the element and
drop it to the target element by using release method
Implicitwait():

Implicit wait is for all the elements, it is a global wait.

Tread.sleep() is hard wait it will pause for the specified time.

Back and forward simulation:

Method used in this is navigate().to(), navigate().back(), navigate.forward().

If we want to navigate to some external website then we will use navigate.to().

Take screenshot:

1. first take the screenshot using the ‘getScreenshotAs()’ method and type cast the driver
reference to take screenshot interface then it will give us the file object.
2. Now by using the copy file method copy the screenshot into the location where we want to
store it.

Code:
//Take screenshot and store as file format
File src = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);

//now copy the screenshot to desired location using copyfile method


FileUtils.copyFile(src, new File(“c:\\cdrve\\name.pang”))

ExplicitWait(): Explict wait is for specific elements.


Properties file: it’s a simple text file with extension as ‘properties’. Will be created like follows:
newothersgeneralchoose ‘file’.

In properties file data will be stored in key-value pair

Whatever the generic things are there we will declare them here, like URL, username, password etc.,

To read the property file we must create the object of property file. This class is available in java and we
have another class ‘FileInputStream’

Fileinputstream will connect to properties file. It will create an input stream between our java code and
config.properties file.

Then load the file using prop.load() metod by passing file input stream reference variable.

To comment some lines in properties file use ‘#’. Ex: #name=tom

What is HTML DOM (Document Object Model):


W3C – World wide web consortium

DOM is kind a platform—interface available in the form of api’s

Difference between isDisplayed() vs isEnabled() vs isSelected():

1. isDisplayed(): is for all the elements. It is used to check whether the element is available on the
page or not.
2. isEnabled(): if we enter or fill all the required data then only some fields like ‘submit’ , ‘Cancel’
buttons will be enabled. To check these kind of elements we will use this method.
3. isSelected(): this method is used only applicable for checkbox, dropdown, radio button.

WebTable:
TestNG:

--unit test frame work, junit and testing both are unit testing frameworks.

-- developer will use this frame work to develop the unit level test case, but automation developer can
also use this framework with selenium to develop the good test cases

--in other words it is also called as TDD means test driven development

Purpose: design the test cases in a systematic way, it will generate the very good html reports

--it will give different annotations

--we can give priorities to test cases

--dependency feature

--we can group the test cases

--data provider feature--

Open source and freely available in the market. Available in the form of jar files

--and it is also called as java unit testing framework it’s only used for selenium with java. For c# nuinit is
available.

-- no need to select the main method option as testNG automatically executes the main method

Annotations in TestNG:

Annotations will be appended by ‘@’ symbol. Always annotation should be associated with one method.

1. @BeforeClass

Features:

1. Priority = using ‘priority’


2. Grouping = using ‘groups’ keyword
3. Dependent = using ‘dependsOnmethod’ keyword
4. innvocationCount= using ‘innvocationCount’. Whenever if we want to execute the same test
case multiple times we can use this method.
5. Expected exceptions: it will tells the controller to don’t terminate the test case if we come
across the defined exceptions.

You might also like