LOCATORS
we have three element First and Last name field and a link element with "Partial Link Text" as the Link text. Lets try to create a repository for these three elements. A property file stores information in a Key value ppair.
In our case we have to store three values instead of two. Element Name,Locator Type and Locator value.
- ClassName – A ClassName operator uses a class attribute to identify an object.
- cssSelector – CSS is used to create style rules for webpages and can be used to identify any web element.
- Id – Similar to class, we can also identify elements by using the ‘id’ attribute.
- linkText – Text used in hyperlinks can also locate element
- name – Name attribute can also identify an element
- tagName – We can also use a tag to locate elements
- xpath – Xpath is the language used to query the XML document. The same can uniquely identify the web element on any page.
How to capture the locators
OBJECT REPOSITORY
Reading Object Repository properties file
Java has support or the .properties files. One can easily read a properties file in three simple step
- Create a FileInputStream object on the .properties file
- Creating a Properties object over the File input stream created in step 1
- Simply read the Key-Values by using the getProperty("Property name"); method on Properties class.
For reading an Object Repository we will create a simple class and name it RepositoryParser.java. Here is the code for that
HANDLING MULTIPLE WINDOWS
It is a unique identifier that holds the address of all the windows.In this website when the user clicks a button ,an another window opens that is a child window.
Suppose if there are multiple tabs are opened,If you want to perform some operation in that particular window like capuring the locators for any child-window page,so that window will be active.
At last If I give the command
driver.close();
The child window which is active that one will get closed
In the above code ,Use stored all the child windows in the array list with the command
"driver.getWindowHandles()"
If I execute the program
In the above program it counted how many windows are open.There are two windows open
driver.switchTo().window(tabs.get(1)); driver.close();
Second window is opened and closed
User can switch to any window by using the command
driver.switchTo().window(tabs.get(0));
This one is the current url and print it on the console
HANDLING FRAMES
Here to switch in to another frame we have to use:
driver.switchTo.defaultContent() and then we can switch in to any frame
driver.switchTo.frame(1);
Perform the action
driver.switchTo.frame(1);
driver.findElement(By.id("name")).sendKeys("Tanu);
METHOD OVERLOADING
In the method name stays the same, the compiler picks the right alternative depending on the actual argument values at the invocation point (the best example of overloading is constructors in Java: the name is always the same but the set of arguments is different) or raises a compiler error if none found. For example:
In the above example if we specify the same method name with no arguments then it throws an error, but if other method has passes an argument then it is method overloading
CONSTRUCTOR
Constructor is called when an instance of the class is created. At the time of calling constructor, memory for the object is allocated in the memory.
It has two keywords:
- this keyword
- super keyword
INHERITANCE
This is the common functionality for all the class files. In every test class we no need to specify chromedriver path or capturing screenshot .All you need to is extend this testbase class to another class
- Inheritance is one of the key concepts of object-oriented programming
- Inheritance allows designing extensible and maintainable class hierarchies.
- Inheritance in Java is implemented using subclassing and the extends keyword, followed by the parent class.The subclass inherits all of the public and protected members of its parent class, a subclass inherits the package-private members of the parent class if both reside in the same package.
Child Class / Sub Class : The class that extends the features of another class is known as child class, subclass, or derived class.
Parent Class / Superclass : The class whose properties and functionalities are used(inherited) by another class is known as a parent class, superclass.
So,In the Addcustomer test user is trying to call the functionalities from the Test Base class to AddCustomer Test class by using the extend keyword.
In the below example we have used the constructor overloading concept, and we have created an object of child class and after calling the constructor of child class the first line in it is super(p) which says that call the matching constructor from the parent class, if we do not mention that line, by default it calls the super() with no parameterized constructor from Parent class.
- SciTE
- AutoIT Window Info(64)
- Download sikuli jar file Add jar file
- First,Take a screenshot of File Name by using Snipping tool
- Second ,take a screenshot of Open button Using Snipping tool
What is the Stale Element Exception
You can refresh the page and again try for the same element.
Example
driver.navigate().refersh(); driver.findElement(By.id(“ur element id”)).click();
Alert
a small box that appears on the display screen to give you some kind of information
Some times we use to get some pop-up messages or notification
To avoid the notification, We can use
alert.dismiss;
(or)
After successful signup the page,it will give you confirmation message pop-up
alert.accept
After executing the program,User faces the "no such alert" exception
SELENIUM WAITS
- Implicit waits are used to provide a default waiting time between each consecutive test step/command across the entire test script. Thus, the subsequent test step would only execute when the specified amount of time has elapsed after executing the previous test step/command.
- Explicit waits are used to halt the execution until 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.They allow your code to halt program execution, or freeze the thread, until the condition you pass it resolves.The condition you pass it resolves.The condition is called with a certain frequency until the timeout of the wait is elapsed. Do not mix implicit and explicit waits
- Doing so can cause unpredictable wait times.For example, setting an implicit wait of 10 seconds and an explicit wait for 15 seconds could cause a timeout to occur after 20 seconds.
In Manual Testing we use to write the bug summary,bug description and bug Id manually.We are Automation testers and we have to everything by automation but how:
Yes,Its possible through Selenium Integration with jira
When Selenium executes and script has any error automatically it will raise a bug ticket by using Jira Retention Policy
Now Comes the Actual Automation,So far Selenium knows how to raise a bug ticket whenever failure occurs in the selenium script with all the required fields Bug summary,description and Bug Id
we are calling abstract method ITestListener by using implementing keyword we are getting all the methods from the listener file like "Pass","fail" and "Skip" this process is called the interface.After implementing all the methods we can override that means we can write our own code
Two – dimensional Array (2D-Array)
Two – dimensional array is the simplest form of a multidimensional array. A two – dimensional array can be seen as an array of one – dimensional array for easier understanding.
Indirect Method of Declaration:
- Declaration – Syntax:
data_type[][] array_name = new data_type[x][y];
For example: int[][] arr = new int[10][20];
DataProvider method which returns a two dimensional array.
Suppose you are testing a student registration application. To register a student, you need to pass Name, Address and City of student. You need to understand here that You required three data
Row is a Number of students to be registered which is three and each row has three columns which are details of each student. Below is the flow it goes through:
In a DataProvider method in TestNG.We need to pass above table in form of an Array to method from a DataProvider method.We will create a 2D(Two Dimensional Matrix) array containing rows and columns which looks similar to above table.I hope you would have basic understanding of Arrays.Now use first column (Name) of first row and use it followed by second column (Address) and third column (City). Done with first row.Now you will pick second row and iterate through its columns and same for each columns of each rows.
No comments:
Post a Comment