Home > Selenium

Protractor: Script execution using custom command

This article will cover below points:  Use of custom command instead of protractor along with user defined options to control the execution of script. Protractor script execution for different test suites using different configuration files i.e. In regression test suite we will execute all spec files In smoke test suite we execute

This Article is TAGGED in , , , , , , . Read more

Sample script in robot framework

Create new file in project with .robot extension.  Robot file contains below sections:  Setting  Variables  Keywords  Test Cases  In setting section all imports can be defined. In variables section, Test data should be defined. In Keywords section, All operations can be defined by calling predefined keywords. In Test Cases section, All operations can be performed by calling user defined keywords.     Here is the

This Article is TAGGED in , , . Read more

Finding elements of table in selenium

Elements in table can be accessed using xpath. Here is the sample HTML code: [crayon-62b95d6bdf8e9810711597/] To locate first “td” in first “tr” in above HTML code. Below is the xpath:   //table//tr[1]/td[1] To locate second “td” in first “tr”. Below is the xpath. //table//tr[1]/td[2] To locate cells of Pune and Mumbai below is the xpath. //table//tr[1]/td To locate the

This Article is TAGGED in , . Read more

Types of locators and best practices to use locators in selenium

There are 8 locators in selenium. Those are... tagName id name className linkText partialLinkText cssSelector xpath It is confusing to decide which locator to select while identifying the element. To avoid the confusion below are the best practices while selecting the locators. First preference should be given to tagName. If tagName is not unique or not available then next preference should

This Article is TAGGED in , , . Read more

Parallel execution of script in multiple browsers using selenium

Single script can be ran in multiple browsers. To perform that we need to define browser configurations in testng.xml file. [crayon-62b95d6bdfaba689383880/] In class name we can mention script name. We can mention same script name or multiple script names. If you want to run in 3 different browsers then just copy test

This Article is TAGGED in , . Read more

File Upload Using Windows Automation Tool And Selenium

Here are the step to upload file using selenium Click on Select file / Select button (This part could be handled using Selenium) Select file from open dialogue box(This part could not be handled using selenium)  Click on Upload or Upload file button. File Upload for INPUT tag with TYPE ="file" Example Url:  If Select file

This Article is TAGGED in , , . Read more

How to use @Parameters and @Optional annotations in the TestNG

TestNG @Parameters One of the important features of TestNG is parameterization. This annotation allows the user to pass parameter values to test methods through the testng.xml file. @Parameters({"param-name"}) Let's write a simple example of passing parameters to test methods through the XML configuration file. Steps to Perform: Open chrome and enter the Demo

This Article is TAGGED in , , , . Read more

TestNG: Use of Before and After annotations with sample code

Exmaples for @BeforeMethod and @AfterMethod in TestNG. @BeforeMethod allows the method to execute before the execution of each Test methods, whereas @afterMethod is executed after the execution of each Test methods.  [crayon-62b95d6be027c489022509/] Output: First Method: Before Method starts! Test with Default priority After Method starts In the above output, we can observe for every Test first @BeforeMethod is

This Article is TAGGED in , , , , , . Read more

How to use Annotations in TestNG Framework

Annotations in TestNG Annotation is a feature introduced in Java 5 and is used to add a piece of code to the java source code.  Annotations are easy to use, maintain and understand. Annotations provide many useful attributes to use in the code. It is easier to find where the error occurred in the

This Article is TAGGED in , , , , . Read more

TestNG Test Annotation with attributes and sample code

Test Annotation with attributes in detail with example. @Test: The @Test attribute is the most important and commonly used annotation of TestNG. It is used to mark a class or a method as part of the test. We write code/business logic in the @Test method. If we want to automate something, that particular

This Article is TAGGED in , , , . Read more