Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Selenium Automation
1. SELENIUM AUTOMATION
SELENIUM IS AN OPEN-SOURCE TOOL THAT IS USED FOR TEST
AUTOMATION. IT IS LICENSED UNDER APACHE LICENSE 2.0. SELENIUM IS A
SUITE OF TOOLS THAT HELPS IN AUTOMATING WEB APPLICATIONS.
PRATYUSH MAJUMDAR
ASSOCIATE PROJECT MANAGER
2. PREREQUISITES
Before proceeding with this tutorial, you should have
• a basic understanding of Java or any other object-oriented programming language
• you should be well-versed with the fundamentals of testing concepts.
3. OVERVIEW
• Selenium IDE - Selenium Integrated Development Environment (IDE) is a Firefox plugin that lets testers
to record and play their actions.
• Selenium RC - Selenium Remote Control (RC) makes use of the full power of programming languages
such as Java, C#, PHP, Python, Ruby and PERL to create more complex tests.
• Selenium WebDriver - Selenium WebDriver is the successor to Selenium RC which sends commands
directly to the browser and retrieves results.
• Selenium Grid - Selenium Grid is a tool used to run parallel tests across different machines and different
browsers simultaneously which results in minimized execution time.
4. ENVIRONMENT SETUP
• Download and Install JDK (7 or 8)
• Download and Install Eclipse (Latest Version)
• Install Firebug in Mozilla to capture x-path
• Download Selenium Jars
• Additional required Jars [TestNG, ReportNG, Apache POI etc]
5. WEBDRIVER
• WebDriver is a tool for automating testing web applications.
• It is popularly known as Selenium 2.0.
• WebDriver interacts directly with the browser without any intermediary, unlike Selenium RC that
depends on a server.
• Locating elements in Selenium WebDriver is performed with the help of findElement() and
findElements() methods provided by WebDriver and WebElement class.
• driver.findElement(By.id(<element ID>))
• driver.findElement(By.name(<element name>))
• driver.findElement(By.linkText(<linktext>))
• driver.findElement(By.xpath(<xpath>))
6. USER INTERACTIONS
• Text Box Interaction [Inputs using sendKeys()]
• Radio Button Selection [Selection using click()]
• Check Box Selection [Selection using click()]
• Drop Down Item Selection ['selectByVisibleText' or 'selectByIndex' or 'selectByValue']
• Synchronization
• Thread.Sleep [Sleep the running Thread]
• Explicit Waits [It is mainly used when we want to click or act on an object once it is visible.]
• Implicit Wait [Will wait for a hardcoded vale of time]
• Drag & Drop [clickAndHold]
• Keyboard Actions [pressKey, releaseKey]
• Mouse Actions [click, doubleClick, mouseMove]
• Multi Select
• Find All Links
7. TESTING FRAMEWORK
• Module Based Testing
• Keyword Driven Testing [all the operations and instructions are written in Excel, CSV etc.]
• Data Driven Testing [Form Field Validation, test data is read from Excel, CSV etc.]
• Hybrid Testing [Keyword and Data driven combined]
• Multi Browser
• TestNG
• ReportNG
9. TESTNG
• TestNG is a powerful testing framework, an enhanced version of JUnit. NG stands for 'Next Generation'.
• Annotations help us organize the tests easily (@Test, @BeforeXXX and @AfterXXX).
• Flexible test configuration (using @Parameters, @Listeners).
• Support for data-driven testing (with @DataProvider).
• Parallelization of tests can be achieved using TestNG.
• testng.xml (Test Suits, Groups)
• Inbuilt reporting (HTML Reports).
• A test is considered successful if it completed without throwing any exception or if it threw an exception that
was expected.
• A test method will typically be made of calls that can throw an exception, or of various assertions (using the
Java "assert" keyword). An "assert" failing will trigger an AssertionErrorException, which in turn will mark the
method as failed.
Back