Add initial structure of functional test project

This commit is contained in:
Herbert Saal
2014-01-24 14:40:28 -04:00
parent 7be2599e0a
commit dc2f15b7f8
49 changed files with 5284 additions and 0 deletions

153
tests/functional/pom.xml Normal file
View File

@@ -0,0 +1,153 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.colosa.qa.automation</groupId>
<artifactId>pm3FunctionalTests</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>pm3FunctionalTests</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.resources.sourceEncoding>UTF-8</project.resources.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<!--<scope>test</scope>-->
</dependency>
<!--<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
</dependency>-->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.39.0</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.1.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.itextpdf.tool</groupId>
<artifactId>xmlworker</artifactId>
<version>1.1.1</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<!--<testSourceDirectory>${basedir}\src\main\java\com\colosa\qa\automatization\tests\PMFunctions</testSourceDirectory>-->
<plugins>
<!-- To define the plugin version in your parent POM -->
<!-- <pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.16</version>
</plugin>
</plugins>
</pluginManagement> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<fork>true</fork>
<executable>${JAVA_JDK_1_7_JAVAC}</executable>
<encoding>UTF-8</encoding>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.13</version>
<configuration>
<includes>
<include>**/TestSuiteAll.java</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.13</version>
</dependency>
</dependencies>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<includes>
<include>**/TestSuiteAll.java</include>
</includes>
<!--<parallel>classes</parallel>
<threadCount>2</threadCount>-->
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.16</version>
</dependency>
</dependencies>
<!--<goals>
<goal>
<id>test22</id>
<configuration>
<fork>true</fork>
<executable>${JAVA_JDK_1_7_JAVAC}</executable>
<encoding>UTF-8</encoding>
<source>1.7</source>
<target>1.7</target>
<includes>
<include>**/Test*.java</include>
</includes>
</configuration>
</goal>
</goals>-->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.16</version>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.16</version>
</plugin>
</plugins>
</reporting>
</project>

View File

@@ -0,0 +1 @@
#This file must be filled with the configuration settings for the application

View File

@@ -0,0 +1,27 @@
#Default Browser connection Data
server.url=http://192.168.11.188/
#browser.name: chrome, firefox, ie
browser.name=firefox
#browser.mode: local, remote
browser.mode=local
#browser.version=22
#WINDOWS, MAC, LINUX
browser.platform=WINDOWS
#remote.server
remote.server.url=http://192.168.11.169:4444/wd/hub
debug.enable=1
permissions.file.upload=archivo.txt
implicit.wait.seconds=10
#testing browsers (firefox, chrome, ie)
browser.count=1
browser.browser1=firefox
browser.platform1=WINDOWS
#browser.version1=23
browser.browser2=chrome
browser.platform2=WINDOWS
#browser.version2=22
browser.browser3=ie
browser.platform3=WINDOWS
#browser.version3=22

View File

@@ -0,0 +1,164 @@
package com.colosa.qa.automatization.common;
/*
public class Browser {
private static WebDriver _driver = null;
private static BrowserInstance _browserInstance = null;
private static long _timeoutSeconds = 0;
public static void checkBrowserSettingsFromSystemProperties() throws IOException {
//Read browser information from default page this is done in the constructor of Browsersettings
//Read browser information from registry
//-Dbrowser.settings=1 -Dbrowser.mode=local -Dbrowser.name=firefox
//-Dbrowser.settings=1 -Dbrowser.mode=remote -Dbrowser.name=firefox -Dremote.server.url=http:// browser.version=
//if variable set from system properties overrride configuration of browser
String setBrowserSettings = System.getProperty("browser.settings");
if(setBrowserSettings != null){
System.out.printf("User Browser Settings detected\n");
String browserMode = System.getProperty("browser.mode");
BrowserConfiguration.getInstance().setBrowserMode(browserMode);
String browserName = System.getProperty("browser.name");
BrowserConfiguration.getInstance().setBrowserName(browserName);
System.out.printf(" Browser Mode: %s, Browser Name: %s \n",
browserMode, browserName);
if(browserMode.equals("remote")){
String browserVersion = System.getProperty("browser.version");
BrowserConfiguration.getInstance().setBrowserVersion(browserVersion);
String browserPlatform = System.getProperty("browser.platform");
BrowserConfiguration.getInstance().setBrowserPlatform(browserPlatform);
String remoteServerUrl = System.getProperty("remote.server.url");
BrowserConfiguration.getInstance().setRemoteServerUrl(remoteServerUrl);
System.out.printf(" Browser Version: %s, Browser Platform: %s, Remote Server URL:%s\n",
browserVersion, browserPlatform, remoteServerUrl );
}
}
}
//
* Create a default instance of the browser using default configuration from registry
* @return Return the instance of the browser created by default
* @throws FileNotFoundException
* @throws IOException
//
public static WebDriver driver() throws FileNotFoundException, IOException{
if(_driver == null){
System.out.printf("Create New Browser instance.\n");
checkBrowserSettingsFromSystemProperties();
String browserMode = BrowserConfiguration.getInstance().getBrowserMode(); //ConfigurationSettings.getInstance().getSetting("browser.mode");
String browserName = "firefox";
browserName = BrowserConfiguration.getInstance().getBrowserName();
if(browserMode.equals("local")){
_browserInstance = new BrowserInstance(browserMode, browserName, "", "", "");
_driver = _browserInstance.getInstanceDriver();
}
if(browserMode.equals("remote")){
String browserVersion = BrowserConfiguration.getInstance().getBrowserVersion();//ConfigurationSettings.getInstance().getSetting("browser.version");
String browserPlatform = BrowserConfiguration.getInstance().getBrowserPlatform();//ConfigurationSettings.getInstance().getSetting("browser.platform");
String remoteServerUrl = BrowserConfiguration.getInstance().getRemoteServerUrl();//ConfigurationSettings.getInstance().getSetting("remote.server.url");
System.out.printf("Remote browser:%s, version:%s, platform:%s, url:%s \n",
browserName, browserVersion, browserPlatform, remoteServerUrl);
_browserInstance = new BrowserInstance(browserMode, browserName, browserVersion, browserPlatform, remoteServerUrl);
_driver = _browserInstance.getInstanceDriver();
}
}
return _driver;
}
public static void maximize(){
_browserInstance.maximize();
}
public static void gotoUrl(String url){
_browserInstance.gotoUrl(url);
}
public static String title(){
return _browserInstance.title();
}
public static void close(){
_browserInstance.quit();
_driver = null;
_browserInstance = null;
}
public static void quit(){
_browserInstance.quit();
_driver = null;
_browserInstance = null;
}
public static By getBySearchCriteria(String str, Object... args) throws Exception{
return _browserInstance.getBySearchCriteria(str, args);
}
public static By getBySearchCriteriaUsingCriteria(String searchCriteria) throws Exception{
return _browserInstance.getBySearchCriteriaUsingCriteria(searchCriteria);
}
public static WebElement getParent(WebElement element) throws Exception{
return _browserInstance.getParent(element);
}
public static WebElement getElement(String str) throws Exception{
return _browserInstance.getElement(str);
}
public static List<WebElement> getElements(String str) throws Exception{
return _browserInstance.getElements(str);
}
public static WebElement getElementf(String str, Object... args) throws Exception{
return _browserInstance.getElementf(str, args);
}
public static Boolean elementExists(String key, int occurrences) throws Exception{
return _browserInstance.elementExists(key, occurrences);
}
public static Boolean elementExists(String key) throws Exception{
return _browserInstance.elementExists(key);
}
public static Boolean elementExistsSearchCriteria(String searchCriteria, int occurrences) throws Exception{
return _browserInstance.elementExistsSearchCriteria(searchCriteria, occurrences);
}
public static Boolean elementExistsSearchCriteria(String searchCriteria) throws Exception{
return _browserInstance.elementExistsSearchCriteria(searchCriteria);
}
public static Boolean waitForElement(By elementLocator, long timeoutSeconds) throws Exception{
return _browserInstance.waitForElement(elementLocator, timeoutSeconds);
}
public static void waitForElement(String key, long timeoutSeconds) throws Exception{
_browserInstance.waitForElement(key, timeoutSeconds);
}
public static List<WebElement> getPreviousSimblingElements(WebElement currentElement){
return _browserInstance.getPreviousSimblingElements(currentElement);
}
} */

View File

@@ -0,0 +1,109 @@
package com.colosa.qa.automatization.common;
import java.io.IOException;
/**
* Created with IntelliJ IDEA.
* User: Herbert Saal
* Date: 3/8/13
* Time: 5:16 PM
* To change this template use File | Settings | File Templates.
*/
public class BrowserConfiguration {
private static BrowserConfiguration ourInstance = new BrowserConfiguration();
public static BrowserConfiguration getInstance() {
return ourInstance;
}
private BrowserConfiguration() {
//init browser configuration by default
try {
getBrowserMode();
getBrowserName();
getBrowserVersion();
getBrowserPlatform();
getRemoteServerUrl();
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
public String getBrowserMode() throws IOException {
//read configuration from registry if not found read from configuration file and store in registry
String browserMode = (String)Registry.getInstance().getReference("browser.mode");
if(browserMode == null){
browserMode = ConfigurationSettings.getInstance().getSetting("browser.mode");
Registry.getInstance().register("browser.mode", browserMode);
}
return browserMode;
}
public void setBrowserMode(String browserMode) throws IOException {
//set configuration in registry
Registry.getInstance().register("browser.mode", browserMode);
}
public String getBrowserName() throws IOException {
String browserName = (String)Registry.getInstance().getReference("browser.name");
if(browserName == null){
browserName = ConfigurationSettings.getInstance().getSetting("browser.name");
Registry.getInstance().register("browser.name", browserName);
}
return browserName;
}
public void setBrowserName(String browserName) throws IOException {
//set configuration in registry
Registry.getInstance().register("browser.name", browserName);
}
public String getBrowserVersion() throws IOException {
String browserVersion = (String)Registry.getInstance().getReference("browser.version");
if(browserVersion == null){
browserVersion = ConfigurationSettings.getInstance().getSetting("browser.version");
Registry.getInstance().register("browser.version", browserVersion);
}
return browserVersion;
}
public void setBrowserVersion(String browserVersion) throws IOException {
//set configuration in registry
Registry.getInstance().register("browser.version", browserVersion);
}
public String getBrowserPlatform() throws IOException {
String browserPlatform = (String)Registry.getInstance().getReference("browser.platform");
if(browserPlatform == null){
browserPlatform = ConfigurationSettings.getInstance().getSetting("browser.platform");
Registry.getInstance().register("browser.platform", browserPlatform);
}
return browserPlatform;
}
public void setBrowserPlatform(String browserPlatform) throws IOException {
//set configuration in registry
Registry.getInstance().register("browser.platform", browserPlatform);
}
public String getRemoteServerUrl() throws IOException {
String remoteServerUrl = (String)Registry.getInstance().getReference("remote.server.url");
if(remoteServerUrl == null){
remoteServerUrl = ConfigurationSettings.getInstance().getSetting("remote.server.url");
Registry.getInstance().register("remote.server.url", remoteServerUrl);
}
return remoteServerUrl;
}
public void setRemoteServerUrl(String remoteServerUrl) throws IOException {
//set configuration in registry
Registry.getInstance().register("remote.server.url", remoteServerUrl);
}
}

View File

@@ -0,0 +1,68 @@
package com.colosa.qa.automatization.common;
/**
* Created with IntelliJ IDEA.
* User: Herbert Saal
* Date: 3/28/13
* Time: 3:00 PM
* To change this template use File | Settings | File Templates.
*/
public class BrowserSettings {
private String _browserMode;
private String _browserName;
private String _browserVersion;
private String _browserPlatform;
private String _remoteServerURL;
public String getBrowserMode() {
return _browserMode;
}
public void setBrowserMode(String browserMode) {
if(browserMode != null)
_browserMode = browserMode;
}
public String getBrowserName() {
return _browserName;
}
public void setBrowserName(String browserName) {
if(browserName != null)
_browserName = browserName;
}
public String getBrowserVersion() {
return _browserVersion;
}
public void setBrowserVersion(String browserVersion) {
if(browserVersion != null)
_browserVersion = browserVersion;
}
public String getBrowserPlatform() {
return _browserPlatform;
}
public void setBrowserPlatform(String browserPlatform) {
if(browserPlatform != null)
_browserPlatform = browserPlatform;
}
public String getRemoteServerUrl() {
return _remoteServerURL;
}
public void setRemoteServerUrl(String remoteServerUrl) {
if(remoteServerUrl != null)
_remoteServerURL = remoteServerUrl;
}
public String toString() {
return "Browser Mode:" + _browserMode + ", Browser Name:" + _browserName +
", Browser Version:" + _browserVersion + ", Browser Platform:" + _browserPlatform +
", Remote Server URL:" + _remoteServerURL;
}
}

View File

@@ -0,0 +1,65 @@
package com.colosa.qa.automatization.common;
import java.io.*;
import java.util.Properties;
public class ConfigurationSettings{
private static ConfigurationSettings INSTANCE = null;
private Properties applicationProperties;
private String appConfigurationFile;
private ConfigurationSettings(String defaultConfFile, String applicationConfFile) throws FileNotFoundException, IOException{
FileInputStream propertiesFile = new FileInputStream(defaultConfFile);
Properties defaultProperties = new Properties();
this.appConfigurationFile = applicationConfFile;
defaultProperties.load(propertiesFile);
propertiesFile.close();
this.applicationProperties = new Properties(defaultProperties);
propertiesFile = new FileInputStream(this.appConfigurationFile);
this.applicationProperties.load(propertiesFile);
propertiesFile.close();
}
private static void createInstance(String defaultConfFile, String applicationConfFile) throws FileNotFoundException, IOException{
if(INSTANCE == null)
INSTANCE = new ConfigurationSettings(defaultConfFile, applicationConfFile);
}
public static ConfigurationSettings getInstance() throws FileNotFoundException, IOException{
File f = new File("default.conf");
File fa = new File("app.conf");
if(f.exists() && fa.exists()) {
ConfigurationSettings.getInstance("default.conf", "app.conf");
}else{
f = new File("." + File.separator +"src"+ File.separator + "main"+ File.separator + "default.conf");
fa = new File("." + File.separator +"src"+ File.separator +"main"+ File.separator + "app.conf");
if(f.exists() && fa.exists()) {
ConfigurationSettings.getInstance("." + File.separator +"src"+ File.separator + "main"+ File.separator + "default.conf", "." + File.separator +"src"+ File.separator + "main"+ File.separator + "app.conf");
}
}
return INSTANCE;
}
public static ConfigurationSettings getInstance(String defaultConfFile, String applicationConfFile) throws FileNotFoundException, IOException{
ConfigurationSettings.createInstance(defaultConfFile, applicationConfFile);
return INSTANCE;
}
public String getSetting(String key){
return this.applicationProperties.getProperty(key);
}
public void setSetting(String key, String value) throws IOException{
this.setSetting(key, value, null);
}
public void setSetting(String key, String value, String comment) throws IOException{
FileOutputStream fos = new FileOutputStream(this.appConfigurationFile);
this.applicationProperties.setProperty(key, value);
this.applicationProperties.store(fos, comment);
fos.close();
}
}

View File

@@ -0,0 +1,12 @@
package com.colosa.qa.automatization.common;
/**
* Created with IntelliJ IDEA.
* User: herbert
* Date: 3/5/13
* Time: 9:54 AM
* To change this template use File | Settings | File Templates.
*/
public class Constant {
public static final String SEARCH_CRITERIA_SEPARATOR = "__&&__";
}

View File

@@ -0,0 +1,13 @@
package com.colosa.qa.automatization.common;
public enum FieldKeyType{
ID,
XPATH,
CSSSELECTOR,
LINKTEXT,
PARTIALLINKTEXT,
TAGNAME,
CLASSNAME,
NAME;
}

View File

@@ -0,0 +1,27 @@
package com.colosa.qa.automatization.common;
public enum FieldType{
TITLE,
SUBTITLE,
LINK,
FILE,
TEXTBOX,
BUTTON,
SUBMITBUTTON,
RESETBUTTON,
TEXTAREA,
DROPDOWN,
LISTBOX,
RADIOBUTTON,
CHECK,
DATEPICKER,
READONLY,
SUGGEST,
CURRENCY,
PERCENTAGE,
YESNO,
HIDDEN,
PASSWORD;
}

View File

@@ -0,0 +1,15 @@
package com.colosa.qa.automatization.common;
/**
* Created with IntelliJ IDEA.
* User: herbert
* Date: 5/6/13
* Time: 5:46 PM
* To change this template use File | Settings | File Templates.
*/
public class InvalidPageException extends Exception {
public InvalidPageException() { super(); }
public InvalidPageException(String message) { super(message); }
public InvalidPageException(String message, Throwable cause) { super(message, cause); }
public InvalidPageException(Throwable cause) { super(cause); }
}

View File

@@ -0,0 +1,37 @@
package com.colosa.qa.automatization.common;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
* Created with IntelliJ IDEA.
* User: herbert
* Date: 6/6/13
* Time: 2:44 PM
* To change this template use File | Settings | File Templates.
*/
public class Logger {
public Logger(){
}
public static void addLog(String logText) {
//System.out.println("VerifyPage Login .");
//System.out.printf("Instance Remote browser:%s, version:%s, platform:%s, url:%s \n",
// browserName, browserVersion, browserPlatform, remoteServerUrl);
//debug.enable=1
String debugEnabled = null;
try {
debugEnabled = ConfigurationSettings.getInstance().getSetting("debug.enable");
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
if(debugEnabled.equals("1")){
System.out.println(logText);
}
//add log code
}
}

View File

@@ -0,0 +1,65 @@
package com.colosa.qa.automatization.common;
import java.util.HashMap;
import java.util.Map;
/**
* Registry pattern
* User: Herbert Saal
* Date: 3/7/13
* Time: 3:50 PM
* To change this template use File | Settings | File Templates.
*/
public class Registry {
private static Registry ourInstance = new Registry();
private final Map registry = new HashMap();
public static Registry getInstance() {
return ourInstance;
}
private Registry() {
}
/**
* Get Reference of stored object in registry identified by the key
* @param key the identifier of the object
* @return return the found object
*/
public Object getReference(
final Object key) {
Object result = null;
if (isRegistered(key)) {
result = registry.get(key);
}
return result;
}
private boolean isRegistered(Object key) {
return registry.containsKey(key);
}
/**
* Register the specified object (value) int he registry identified by the specified key
* @param key The identifier of the object.
* @param value The value - object to be stored in the registry
*/
public synchronized void register(
Object key, Object value) {
registry.put(key, value);
}
/**
* Unregister the specified object from registry.
* @param key the identifier of the object -value to unregister
*/
public synchronized void unregister(
Object key) {
registry.remove(key);
}
}

View File

@@ -0,0 +1,40 @@
package com.colosa.qa.automatization.common;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.Select;
import java.net.URL;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.openqa.selenium.JavascriptExecutor;
import java.util.Random;
public class Utils{
public static String getRandomString (int longString){
String randomString = "";
long milis = new java.util.GregorianCalendar().getTimeInMillis();
Random r = new Random(milis);
int i = 0;
while ( i < longString){
char c = (char)r.nextInt(255);
if ( (c >= '0' && c <='9') || (c >='A' && c <='Z') ){
randomString += c;
i ++;
}
}
return randomString;
}
}

View File

@@ -0,0 +1,151 @@
package com.colosa.qa.automatization.common.controlOptions;
import com.colosa.qa.automatization.common.BrowserInstance;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import java.util.ArrayList;
public class ControlOptions{
//protected String fieldname = null;
//protected String label = "";
protected Boolean required = false;
protected Boolean readOnly = false;
private ArrayList<String> dependentFields = new ArrayList<String>();
protected String defaultValue = null;
protected String hint = "";
public Mode mode = Mode.EDIT;
protected SQLConnection sqlConnection = null;
protected String sql = null;
protected DependentFieldsApplicableBehavior dependentFieldsApplicableBehavior;
public enum Mode{
EDIT("edit"),
VIEW("view");
private String value;
Mode(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}
public enum SQLConnection{
NONE(""),
DBARRAY("dbarray"),
WORKFLOW("workflow"),
RBAC("rbac"),
REPORT("rp");
private String value;
SQLConnection(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}
public ControlOptions(){
this.dependentFieldsApplicableBehavior = new DependentFieldsNotApplicableOption();
this.sqlConnection = SQLConnection.NONE;
}
protected void fillForm(BrowserInstance browser) throws Exception{
Select ddown = null;
this.fillRequired(browser);
this.fillReadOnly(browser);
this.fillDependentFields(browser);
this.fillDefaultValue(browser);
browser.findElement("dynaformDesigner.webElement.blankDynaformModal.hint").sendKeys(this.hint);
ddown = new Select(browser.findElement("dynaformDesigner.webElement.blankDynaformModal.mode"));
ddown.selectByValue(this.mode.getValue());
this.fillSQLConnection(browser);
this.fillSQL(browser);
}
protected void addDependentField(String fieldname){
this.dependentFields.add(fieldname);
}
/*
public void setFieldName(String fieldname){
this.fieldname = fieldname;
}
public void setLabel(String label){
this.label = label;
}*/
public void setSQL(String sql){
this.sql = sql;
}
public void setSQLConnection(SQLConnection connection){
this.sqlConnection = connection;
}
public void setReadOnly(Boolean readOnly){
this.readOnly = readOnly;
}
public void setRequired(Boolean required){
this.required = required;
}
public void setHint(String hint){
this.hint = hint;
}
public void setMode(Mode mode){
this.mode = mode;
}
private void fillRequired(BrowserInstance browser) throws Exception{
if(this.required == null)
return;
WebElement we = null;
we = browser.findElement("dynaformDesigner.webElement.blankDynaformModal.required");
if(this.required != we.isSelected())
we.click();
}
private void fillDependentFields(BrowserInstance browser) throws Exception{
if(this.dependentFields != null)
this.dependentFieldsApplicableBehavior.fillDependentFields(browser, this.dependentFields);
}
protected void fillDefaultValue(BrowserInstance browser) throws Exception{
if(this.defaultValue == null)
return;
browser.findElement("dynaformDesigner.webElement.blankDynaformModal.defaultValue").sendKeys(this.defaultValue);
}
private void fillSQLConnection(BrowserInstance browser) throws Exception{
if(this.sqlConnection == null)
return;
(new Select(browser.findElement("dynaformDesigner.webElement.blankDynaformModal.sqlConnection"))).selectByValue(this.sqlConnection.getValue());
}
private void fillSQL(BrowserInstance browser) throws Exception{
if(this.sql == null)
return;
browser.findElement("dynaformDesigner.webElement.blankDynaformModal.sql").sendKeys(this.sql);
}
private void fillReadOnly(BrowserInstance browser) throws Exception{
if(this.readOnly == null)
return;
WebElement we = browser.findElement("dynaformDesigner.webElement.blankDynaformModal.readOnly");
if(this.readOnly != we.isSelected())
we.click();
}
}

View File

@@ -0,0 +1,9 @@
package com.colosa.qa.automatization.common.controlOptions;
import com.colosa.qa.automatization.common.BrowserInstance;
import java.util.ArrayList;
interface DependentFieldsApplicableBehavior{
public void fillDependentFields(BrowserInstance browser, ArrayList<String> fields) throws Exception;
}

View File

@@ -0,0 +1,20 @@
package com.colosa.qa.automatization.common.controlOptions;
import com.colosa.qa.automatization.common.BrowserInstance;
import org.openqa.selenium.support.ui.Select;
import java.util.ArrayList;
public class DependentFieldsApplicableOption implements DependentFieldsApplicableBehavior{
public void fillDependentFields(BrowserInstance browser, ArrayList<String> fields) throws Exception{
if(fields == null)
return;
Select we = new Select(browser.findElement("dynaformDesigner.webElement.blankDynaformModal.dependentFields"));
for(String fieldName:fields)
{
we.selectByVisibleText(fieldName);
}
}
}

View File

@@ -0,0 +1,11 @@
package com.colosa.qa.automatization.common.controlOptions;
import com.colosa.qa.automatization.common.BrowserInstance;
import java.util.ArrayList;
public class DependentFieldsNotApplicableOption implements DependentFieldsApplicableBehavior{
public void fillDependentFields(BrowserInstance browser, ArrayList<String> fields){}
}

View File

@@ -0,0 +1,72 @@
package com.colosa.qa.automatization.common.controlOptions.input;
import com.colosa.qa.automatization.common.BrowserInstance;
import com.colosa.qa.automatization.common.controlOptions.ControlOptions;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import java.util.ArrayList;
class InputControlOptions extends ControlOptions{
private ArrayList<Integer> size = new ArrayList<Integer>();
protected String validate = null;
protected String mask = null;
protected int maxLength = -1;
protected void fillForm(BrowserInstance browser) throws Exception{
super.fillForm(browser);
this.fillSize(browser);
this.fillValidate(browser);
this.fillMask(browser);
this.fillMaxLength(browser);
}
protected void setSize(int... args){
this.size.clear();
for(int i: args)
this.size.add(i);
}
private void fillSize(BrowserInstance browser) throws Exception{
if(this.size.size()==1)
{
WebElement we = browser.findElement("dynaformDesigner.webElement.blankDynaformModal.size");
we.clear();
we.sendKeys(Integer.toString(this.size.get(0)));
}
else if(this.size.size()==2)
{
WebElement we = browser.findElement("dynaformDesigner.webElement.blankDynaformModal.columns");
we.clear();
we.sendKeys(Integer.toString(this.size.get(0)));
we = browser.findElement("dynaformDesigner.webElement.blankDynaformModal.rows");
we.clear();
we.sendKeys(Integer.toString(this.size.get(1)));
}
}
private void fillValidate(BrowserInstance browser) throws Exception{
if(this.validate == null)
return;
Select we = new Select(browser.findElement("dynaformDesigner.webElement.blankDynaformModal.validate"));
we.selectByValue(this.validate);
}
private void fillMask(BrowserInstance browser) throws Exception{
if(this.mask == null)
return;
WebElement we = browser.findElement("dynaformDesigner.webElement.blankDynaformModal.mask");
we.clear();
we.sendKeys(this.mask);
}
private void fillMaxLength(BrowserInstance browser) throws Exception{
if(this.maxLength < 0)
return;
WebElement we = browser.findElement("dynaformDesigner.webElement.blankDynaformModal.maxLength");
we.clear();
we.sendKeys(Integer.toString(this.maxLength));
}
}

View File

@@ -0,0 +1,71 @@
package com.colosa.qa.automatization.common.controlOptions.input;
import com.colosa.qa.automatization.common.BrowserInstance;
import org.openqa.selenium.support.ui.Select;
public class NumericOptions extends InputControlOptions{
private Validate validate = Validate.REAL_NUMBER;
private DecimalSeparator decimalSeparator = DecimalSeparator.PERIOD;
private String formula = null;
public enum Validate{
INTEGER("Int"), REAL_NUMBER("Real");
private String value;
Validate(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
};
public enum DecimalSeparator{
PERIOD("."), COMMA(",");
private String value;
DecimalSeparator(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}
public void setMask(String mask){
this.mask = mask;
}
public void setSize(int i){
super.setSize(i);
}
public void setFormula(String formula){
this.formula = formula;
}
public void setValidate(Validate validate){
this.validate = validate;
}
public void setDecimalSeparator(DecimalSeparator decimalSeparator){
this.decimalSeparator = decimalSeparator;
}
public void setDefaultValue(String defaultValue){
this.defaultValue = defaultValue;
}
public void fillForm(BrowserInstance browser) throws Exception{
super.fillForm(browser);
new Select(browser.findElement("dynaformDesigner.webElement.blankDynaformModal.validate")).selectByValue(this.validate.getValue());
new Select(browser.findElement("dynaformDesigner.webElement.blankDynaformModal.decimalSeparator")).selectByValue(this.decimalSeparator.getValue());
browser.findElement("dynaformDesigner.webElement.blankDynaformModal.formula").sendKeys(this.formula);
}
}

View File

@@ -0,0 +1,37 @@
package com.colosa.qa.automatization.common.controlOptions.input;
import com.colosa.qa.automatization.common.BrowserInstance;
import org.openqa.selenium.WebElement;
public class PasswordOptions extends InputControlOptions{
private Boolean autocomplete = false;
public PasswordOptions(){
this.sqlConnection = null;
this.sql = null;
}
private void setSQLConnection(){}
private void setSQL(){}
public void setMaxLength(int length){
this.maxLength = length;
}
public void setSize(int i){
super.setSize(i);
}
public void setAutocomplete(Boolean autocomplete){
this.autocomplete = autocomplete;
}
public void fillForm(BrowserInstance browser) throws Exception{
super.fillForm(browser);
WebElement we = browser.findElement("dynaformDesigner.webElement.blankDynaformModal.autocomplete");
if(this.autocomplete != we.isSelected())
we.click();
}
}

View File

@@ -0,0 +1,102 @@
package com.colosa.qa.automatization.common.controlOptions.input;
import com.colosa.qa.automatization.common.BrowserInstance;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
public class SuggestOptions extends InputControlOptions{
private SaveSelectedOptionAs saveSelectedOptionAs = SaveSelectedOptionAs.LABEL;
private StoreNewEntryPrimaryKeyType storeNewEntryPrimaryKeyType;
private int maxResults = 6;
private Boolean showNoResultsMessage = false;
private Boolean storeNewEntry = false;
private String javascript = "";
private String table = "0";
private String primaryKey = "0";
public enum SaveSelectedOptionAs{
LABEL("1"), VALUE("0");
private String value;
SaveSelectedOptionAs(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}
public enum StoreNewEntryPrimaryKeyType{
NONE("0"), INTEGER("int"), VARCHAR("varchar");
private String value;
StoreNewEntryPrimaryKeyType(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}
public SuggestOptions(){
this.readOnly = null;
}
public void setSize(int i){
super.setSize(i);
}
public void setSaveSelectedOptionAs(SaveSelectedOptionAs saveAs){
this.saveSelectedOptionAs = saveAs;
}
public void setMaxResults(int i){
this.maxResults = i;
}
public void setShowNoResultsMessage(Boolean bln){
this.showNoResultsMessage = bln;
}
public void enableStoreNewEntry(String table, String primaryKey, StoreNewEntryPrimaryKeyType type){
this.storeNewEntry = true;
this.table = table;
this.primaryKey = primaryKey;
this.storeNewEntryPrimaryKeyType = type;
}
public void disableStoreNewEntry(){
this.storeNewEntry = false;
this.table = "0";
this.primaryKey = "0";
this.storeNewEntryPrimaryKeyType = StoreNewEntryPrimaryKeyType.NONE;
}
public void setJavascript(String script){
this.javascript = script;
}
public void addDependentField(String fieldName){
super.addDependentField(fieldName);
}
public void fillForm(BrowserInstance browser) throws Exception{
super.fillForm(browser);
(new Select(browser.findElement("dynaformDesigner.webElement.blankDynaformModal.saveSelectedOptionAs"))).selectByValue(this.saveSelectedOptionAs.getValue());
browser.findElement("dynaformDesigner.webElement.blankDynaformModal.maxResults").sendKeys(Integer.toString(this.maxResults));
WebElement we = browser.findElement("dynaformDesigner.webElement.blankDynaformModal.showNoResultsMessage");
if(this.showNoResultsMessage != we.isSelected())
we.click();
we = browser.findElement("dynaformDesigner.webElement.blankDynaformModal.storeNewEntry");
if(we.isSelected() != this.storeNewEntry)
we.click();
(new Select(browser.findElement("dynaformDesigner.webElement.blankDynaformModal.storeNewEntry.table"))).selectByValue(this.table);
(new Select(browser.findElement("dynaformDesigner.webElement.blankDynaformModal.storeNewEntry.primaryKey"))).selectByValue(this.primaryKey);
(new Select(browser.findElement("dynaformDesigner.webElement.blankDynaformModal.storeNewEntry.primaryKeyType"))).selectByValue(storeNewEntryPrimaryKeyType.getValue());
browser.findElement("dynaformDesigner.webElement.blankDynaformModal.javascriptCallback").sendKeys(this.javascript);
}
}

View File

@@ -0,0 +1,19 @@
package com.colosa.qa.automatization.common.controlOptions.input;
import com.colosa.qa.automatization.common.BrowserInstance;
public class TextAreaOptions extends InputControlOptions{
public void fillForm(BrowserInstance browser) throws Exception{
super.fillForm(browser);
}
public void setSize(int columns, int rows){
super.setSize(columns, rows);
}
public void setSize(int i){
this.setSize(i, i);
}
}

View File

@@ -0,0 +1,96 @@
package com.colosa.qa.automatization.common.controlOptions.input;
import com.colosa.qa.automatization.common.BrowserInstance;
import com.colosa.qa.automatization.common.controlOptions.DependentFieldsApplicableOption;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
public class TextFieldOptions extends InputControlOptions{
private TextTransform textTransform = TextTransform.NONE;
public enum TextTransform{
NONE(""),
UPPER_CASE("UPPER"),
LOWER_CASE("LOWER");
private String value;
TextTransform(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}
public enum Validate{
ANY("Any"),
ALPHA("Alpha"),
ALPHA_NUMERIC("AlphaNum"),
INT("Int"),
REAL("Real"),
EMAIL("Email"),
LOGIN("Login");
private String value;
Validate(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}
public TextFieldOptions(){
this.dependentFieldsApplicableBehavior = new DependentFieldsApplicableOption();
this.validate = (Validate.ANY).getValue();
}
public void setValidate(Validate validate){
this.validate = validate.getValue();
}
public void setTextTransform(TextTransform tf){
this.textTransform = tf;
}
public void setSize(int i){
super.setSize(i);
}
public void setMask(String mask){
this.mask = mask;
}
public void setMaxLength(int length){
this.maxLength = length;
}
public void setDefaultValue(String defaultValue){
this.defaultValue = defaultValue;
}
public void addDependentField(String fieldName){
super.addDependentField(fieldName);
}
@Override
public void fillForm(BrowserInstance browser) throws Exception{
super.fillForm(browser);
WebElement we = null;
Select ddown = null;
//ddown = new Select(browser.findElement("dynaformDesigner.webElement.blankDynaformModal.validate"));
//ddown.selectByValue(this.validate.getValue());
//browser.findElement("dynaformDesigner.webElement.blankDynaformModal.mask").sendKeys(this.mask);
ddown = new Select(browser.findElement("dynaformDesigner.webElement.blankDynaformModal.textTransform"));
ddown.selectByValue(this.textTransform.getValue());
//we = browser.findElement("dynaformDesigner.webElement.blankDynaformModal.size");
//we.clear();
//we.sendKeys(Integer.toString(this.size));
}
}

View File

@@ -0,0 +1,25 @@
package com.colosa.qa.automatization.common.controlOptions.selection;
class DropDownOption{
private String key = null;
private String value = null;
public DropDownOption(String key, String value){
this.key = key;
this.value = value;
}
public String getKey(){
return this.key;
}
public void setValue(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}

View File

@@ -0,0 +1,43 @@
package com.colosa.qa.automatization.common.controlOptions.selection;
import com.colosa.qa.automatization.common.BrowserInstance;
import com.colosa.qa.automatization.common.controlOptions.ControlOptions;
import com.colosa.qa.automatization.common.controlOptions.DependentFieldsApplicableOption;
import java.util.ArrayList;
public class DropDownOptions extends ControlOptions{
private ArrayList<DropDownOption> options = new ArrayList<DropDownOption>();
public DropDownOptions(){
this.dependentFieldsApplicableBehavior = new DependentFieldsApplicableOption();
}
public void addOption(String label, String value){
options.add(new DropDownOption(label, value));
}
public void addDependentField(String fieldName){
super.addDependentField(fieldName);
}
public void setDefaultValue(String value){
this.defaultValue = value;
}
@Override
public void fillForm(BrowserInstance browser) throws Exception{
super.fillForm(browser);
int i = 1;
for(DropDownOption opt:this.options)
{
if(i>1)
browser.findElement("dynaformDesigner.webElement.dropdownModal.gridNewElementButton").click();
browser.getElementf("dynaformDesigner.webElement.dropdownModal.gridValueElementLocator", i).sendKeys(opt.getValue());
browser.getElementf("dynaformDesigner.webElement.dropdownModal.gridLabelElementLocator", i).sendKeys(opt.getKey());
i++;
}
}
}

View File

@@ -0,0 +1,31 @@
package com.colosa.qa.automatization.common.controlOptions.selection;
import com.colosa.qa.automatization.common.BrowserInstance;
import com.colosa.qa.automatization.common.controlOptions.DependentFieldsNotApplicableOption;
import org.openqa.selenium.WebElement;
public class ListBoxOptions extends DropDownOptions{
private int size = 4;
public ListBoxOptions(){
}
//protected void setReadOnly(Boolean readOnly){}
public void setSize(int size){
this.size = size;
}
@Override
public void fillForm(BrowserInstance browser) throws Exception{
this.dependentFieldsApplicableBehavior = new DependentFieldsNotApplicableOption();;
this.readOnly = null;
super.fillForm(browser);
WebElement we = browser.findElement("dynaformDesigner.webElement.blankDynaformModal.size");
we.clear();
we.sendKeys(Integer.toString(this.size));
}
}

View File

@@ -0,0 +1,43 @@
package com.colosa.qa.automatization.common.controlOptions.selection;
import com.colosa.qa.automatization.common.BrowserInstance;
import com.colosa.qa.automatization.common.controlOptions.ControlOptions;
import org.openqa.selenium.support.ui.Select;
public class YesNoOptions extends ControlOptions{
public enum Options{
YES("1"), NO("");
private String value;
Options(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}
public void setDefaultValue(Options option){
this.defaultValue = option.getValue();
}
@Override
protected void fillDefaultValue(BrowserInstance browser) throws Exception{
new Select(browser.findElement("dynaformDesigner.webElement.blankDynaformModal.defaultValue")).selectByValue(this.defaultValue);
}
private void setRequired(){}
private void setSQL(/* String sql */){}
private void setSQLConnection(/*SQLConnection connection*/){}
public void fillForm(BrowserInstance browser) throws Exception{
this.sqlConnection = null;
this.required = null;
super.fillForm(browser);
}
}

Some files were not shown because too many files have changed in this diff Show More