Selenium Test Frameworks
are thought to be a blend of set conventions, principles, measures and rules that can be taken as whole in order to influence the advantages of the platform gave by the framework. If frameworks wont exist, then it is hard to get appropriate reports, handle the checkpoints
.
There is a different scope of Automation Frameworks accessible now a days. These systems might contrast from another based on their backing to various key elements to do computerization like re-usability
, simplicity of maintenance. Modular
, Keyword
, Data driven
, Hybrid
are the four prominent test computerization methodologies. passed
. In the event that any of the test information blend is fizzled, then the whole experiment will be dealt with as Fail
.
Following are the advantages of Data Driven:
before test execution is prepared
.OOPS idea – Abstraction
. The structure separates the whole "Application Under Test" into number of consistent and different modules. For every module, make a different and free test script. In this manner, when these test scripts taken together forms a bigger test script speaking to more than one modules. Google
, Internet Explore
and Firefox
.
[java]
browserName.equalsIgnoreCase("Firefox")
else if (browserName.equalsIgnoreCase("chrome")) {
System.setProperty("webdriver.chrome.driver",
"D:/Jars/chromedriver.exe");
lse if (browserName.equalsIgnoreCase("IE")) {
System.setProperty("webdriver.ie.driver",
"D:/Jars/IEDriverServer.exe");
[/java]
Here catch block has been used to describe the exception.
[java]
catch (WebDriverException e) {
System.out.println(e.getMessage());
}
[/java]
The driver.navigate().to(URL);
method is used to write any web site for the testing, here provided text method and link method and button method to process the exception.
[java]
public void enter_Text(String locatorType, String value, String text)
public void click_On_Link(String locatorType, String value)
public void click_On_Button(String locatorType, String value)
[/java]
KeyWordExecution
, which assumes the liability of recovering the information from excel sheet, distinguish the locators and parameters and conjure the separate techniques in the "KeyWordExample" class.
[java]
//This is an example for the Selenium Test Frameworks.
package com.keyword.sample;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
public class KeyWordExecution {
public void runReflectionMethod(String strClassName, String strMethodName,
Object... inputArgs) {
Class<?> params[] = new Class[inputArgs.length];
for (int i = 0; i <inputArgs.length; i++) {
if (inputArgs[i] instanceof String) {
params[i] = String.class;
}
}
try {
Class<?> cls = Class.forName(strClassName);
Object _instance = cls.newInstance();
Method myMethod = cls.getDeclaredMethod(strMethodName, params);
myMethod.invoke(_instance, inputArgs);
} catch (ClassNotFoundException e) {
System.err.format(strClassName + ":- Class not found%n");
} catch (IllegalArgumentException e) {
System.err
.format("Method invoked with wrong number of arguments%n");
} catch (NoSuchMethodException e) {
System.err.format("In Class " + strClassName + "::" + strMethodName
+ ":- method does not exists%n");
} catch (InvocationTargetException e) {
System.err.format("Exception thrown by an invoked method%n");
} catch (IllegalAccessException e) {
System.err
.format("Can not access a member of class with modifiers private%n");
e.printStackTrace();
} catch (InstantiationException e) {
System.err
.format("Object cannot be instantiated for the specified class using the newInstance method%n");
}
}
public static void main(String[] args) {
KeyWordExecution exeKey = new KeyWordExecution();
ReadExcel excelSheet = new ReadExcel();
excelSheet.openSheet("D:/testCaseSheet.xls");
for (int row = 1; row <excelSheet.getRowCount(); row++) {
List<Object> myParamList = new ArrayList<Object>();
String methodName = excelSheet.getValueFromCell(0, row);
for (int col = 1; col < excelSheet.getColumnCount(); col++) {
if (!excelSheet.getValueFromCell(col, row).isEmpty()
!excelSheet.getValueFromCell(col, row).equals("null")) {
myParamList.add(excelSheet.getValueFromCell(col, row));
}
}
Object[] paramListObject = new String[myParamList.size()];
paramListObject = myParamList.toArray(paramListObject);
exeKey.runReflectionMethod("com.keyword.sample.KeyWordExample",
methodName, paramListObject);
}
}
}
[/java]
The InvocationTargetException method is used if the underlying method throws an exception. ClassNotFoundException
is one of the java startegy, From the name java.lang.ClassNotFoundException looks quite simple but underlying cause of it is always different and which classifies it as an environmental issue. System.err
and System.out
both are setup by OS when the Java code is executed.
ReadExcel
and also created FileInputStream
class that can obtain input bytes from the file, it is utilized to read the raw bytes such as image.
The getMessage()
or getSheet()
techniques for Throwable class acquired by each special case class like ArithmeticException . The getMessage() technique prints just the message part of the yield printed by an object e. This style can be favored when the developer might not want to give his message to the real client.
data-driven
and keyword driven
testing structures. It permits information driven scripts to exploit the capable libraries and utilities in a keyword based methodology.
Following are the advantages of Hybrid Framework: