Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Selenium
1. Overview of Selenium
Selenium is a set of tools for automating testing activities of web application.
Selenium is highly flexible, allowing many options for locating UI elements and
comparing expected test results against actual application behavior. We can execute
one test in multiple machines.
Selenium Components
Selenium is divided into following major tools.
• Selenium IDE
• Selenium RC
• Selenium webdriver
• Selenium Grid
Selenium-IDE
Selenium is a web automation tool.It is a firefox plugin. It is a record and
playback tool.It will record the scripts automatically based on user's action on a
site.After the recording the tester needs to make small changes in the script based on
the testing flow.It allows to record, edit and debug the generated scripts.
By using this IDE we can create browser based regression test suit. Selenium
IDE provides option to set breakpoint.We can set breakpoint from which line to
which line we need to run.We use selenium IDE for web automation, it helps us to
test field level validation, for example in contact us page if contact no is given then
clicking the submit button, the warning message will appear for contact no is
mandatory then we can capture the warning message using selenium IDE. After
capturing the warning message we execute the script for regression it finds whether
the warning comes or not.
Disadvantage
Selenium IDE works only on firefox plugin. For supporting multiple browsers,
2. we can move to Selenium RC.
Selenium-RC (Remote Control)
Selenium-RC supports multiple browser environment.It also allows to use a highlevel
programming language for maximum flexibility and extensibility in developing test logic. We can
execute the generated testscript from selenium IDE and export it into java, Ruby to any other
language, import the script in eclipse IDE.By using eclipse IDE we can enhance the testscript.
Selenium-RC provides an API (Application Programming Interface) and library for each of its
supported languages: HTML, Java, C#, Perl, PHP, Python, and Ruby. Selenium-RC supports high-
level programming languages to develop automation test cases.
Disadvantage
Currently Selenium RC is not used. Because it doesnt support the latest android
technologies. To overcome this we are moving to web driver.
Selenium Web driver
It has a lot of new features. It supports latest android technologies. It doesn't require the
knowledge of RC. It interacts with html of the application as a real user.It allows to integrate with
Junit, TestNG.It handles the Javascript alerts, prompts and handling multiple frames, multiple
browser windows. Selenium-WebDriver supports multi browsers multi OS, it uses browser’s native
support for automation to make direct calls to the browser. The WebDriver supports multiple
browser like FirefoxDriver, ChromeDriver, InternetExplorerDriver, SafariDriver etc. The direct
calls are made to each browser is depends on which browser you are using.
Selenium-Grid
Selenium-Grid allows the Selenium-RC solution to scale for large test suites or test suites
that must be run in multiple environments. With Selenium-Grid, multiple instances of Selenium-RC
are running on various operating system and browser configurations; Each of these when launching
register with a hub. When tests are sent to the hub they are then redirected to an available Selenium-
RC, which will launch the browser and run the test. This allows for running tests in parallel, with
the entire test suite theoretically taking only as long to run as the longest individual test.
Download Selenium
From the below link you can download the latest selenium components.
http://seleniumhq.org/download/
3. How to install Selenium IDE?
Step 1: Open Mozilla Firefox
Step 2: Enter the link http://seleniumhq.org/download/ and click GO, webpage will be opened,
then Click on 'Download' link for the Selenium IDE project.
Step 3: While downloading it will ask for allow download, so Click ‘Allow’ button on the top-right
side to proceed with the installation
Step 4: Click on the 'Install Now' button, the downloading starts and after download completes it
ask for Restart Firefox
4. Step 5: click 'Restart Firefox' button
Step 6: After restart, Click Tools > Selenium IDE in the firefox
5. Step 7: It opens the new Selenium IDE record/playback window.
6. Selenium IDE Tool
Selenium Concepts
Selenium scripts were generated in the form of
• command
• target
• value
8. Selenium IDE Tools
How to record in Selenium IDE?
1. Open Firefox browser.
2. Click on Tools > Selenium IDE, Selenium IDE window will be opened.
3. Enter the application URL in the firefox browser and press enter, parallelly the Selenium IDE is
still in open.
4. Click on the red icon in the top right of the Selenium IDE to record the actions.
5. After clicking the red icon, minimize the Selenium IDE window and start working on the
application. All the actions which you performed in the application are recorded in Selenium IDE in
the form of script.
6. After you complete all the recording actions, Click the same red icon again (now it is recording
mode) to stop recording.
9. 7. To playback the recorded scripts, click on the green icon('Play entire test suite') which is in the
top left of the window.
8. After clicking the green icon, the test scripts will start execute (play back) line by line. The
resluts are shown in the Log which in the bottom site of the window.
Selenium WebDriver
Selenium 2.0 - is a tool for automated functional testing, which includes two previously
independent projects - Selenium Remote Control (Selenium RC) and webDriver (Selenium WD).
Selenium 2.0 allows you to use all the tools like Selenium WebDriver, and Selenium RC. Selenium
developers recommend to use Selenium webDriver, as Selenium RC was officially deprecated.
While working at Selenium 2.0 they mainly developed Selenium WebDriver and its compatibility
with Selenium RC. Selenium RC itself was not changed much.
There is a number of WebDrivers for the major browsers in the moment, which are in
different readiness stages:
• FirefoxDriver (3.0, 3.5, 3.6, 4.0, 5.0, 6, 7, 8, 9, 10 and beginning with ver. 2.15 partially 11)
• InternetExplorerDriver (6, 7, 8, 9 - 32 and 64-bit where applicable)
• ChromeDriver (12.0.7, 12.0 +); OperaDriver (11.5 +)
• OperaDriver (11.5 +)
• SafariDriver - currently is not available
• HtmlUnitDriver (2.9), cross-platform driver on java, no need to install any browser
• AndriodDriver (2.3 + for phones and tablets (devices & emulators) IphoneDriver)
• iOS 3 + for phones (devices & emulators) and 3.2 + for tablets (devices & emulators)
Languages (bindings) officially supported in Selenium WebDriver are:
C #
Java
Ruby
Python
10. Features of Web driver
No need to start server prior to start executing scripts.
• It allows to simulate the mouse movements.
• It provides the improved reliability between browsers.
• A most awaiting feature added in WebDriver is “Implementation of listeners”.
• For web application testing, it provides standard programming interface.
• It allows to simulate keyboard key press events using different classes.
• It allows to simulate the clicking of browser front and back button.
• Added advantage to support for iPhone and Android testing
• It os similar to QTP, It allows to extract the objects in bulk. In RC this is big pain to
extracting the objects.
• It supports features like Page navigation, Drag-and-drop and AJAX-based UI elements.
• Using WebDriver can easily find the coordinates of any object.
• WebDriver is open source & it allows you to easily integrate with testing framework like
JUnit or TestNG.
Now we will see the demo how selenium web driver works
11. Run a simple test script in Selenium Webdriver with TestNG
Step 1 : Record selenium automation script using Selenium IDE.
Step 2: Export the recorded selenium automation script as a Java / JUnit 4 / Webdriver. Eg. Here
we export a java as “Login.java”
a)Export as java file
22. After import the java file will been seen with error since the classpath not set for selenium webdriver
jars.
23. Step 4 : Download Selenium 2 Web Driver from http://seleniumhq.org/download/
24. You will get the folder in your download path and keep it there and unzip it so that you can use it
in later steps. The files in the folder should look something like this :
25. Step 5: Add External Files (Referenced Libraries ) in to the Eclipse.
a. Right Click the project and go to Properties.
b. Go to Java Build Path -> Library tab -> Add External JARs…
c. Now add all the jar files
d. Check if they are appearing in the Eclipse as below.
26.
27. e. After configure the classpath the error will be cleared automatically.
Step 6: Install TestNG Plug-in in Eclipse.
In Eclipse, go to Help -> Install New Software
Enter http://beust.com/eclipse in the Work with: field
Wait and TestNG will be appeared in the window. Check the box next to TestNG and Click on Next button. Click on
Finish and the Restart the Eclipse.
Step 7: Change the Junit code to TestNG code.(Exported Login.java)
Change the annotation from Junit code to TestNG.
Eg. @Before replace with @BeforeTest
@After replace with @AfterTest
Remove the Junit import header and replace with appropriate TestNG import header .
Eg., import org.junit.*; replace with import org.testng.*; and
import org.testng.annotations.*;
28. • If any junit code is used in then replace with appropriate TestNG code.
• verifyTextPresent in a field may require manual changes
Eg.
try {
assertTrue(driver.findElement(By.cssSelector("BODY")).getText().matches("^[sS]*Homern
rn[sS]*$"));
} catch (Error e) {
verificationErrors.append(e.toString());
}
replace with
try {
assertEquals(“Home”,driver.findElement(By.id("WindowName")).getText());
} catch (Error e) {
verificationErrors.append(e.toString());
}
Step 7 : Run the selenium automation script by right the java file and Run as-> TestNG Test.
Step 8 : Verify the test results in the console.
29. Note: In the exported Java from selenium IDE require manual changes to run the script in
eclipse.