Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using NUnit.Framework;
- using Selenium;
- using System.Threading;
- using System.Drawing;
- using System.Drawing.Imaging;
- using System.Windows.Forms;
- using Word_Export;
- namespace Lune_Automation_Unite
- {
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Selenium_Server -------------
- // This is the main class of the framework, it handle steps errors and pushes step
- // execution to the report
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public class Selenium_Server
- {
- private ISelenium selenium;
- private StringBuilder verificationErrors;
- private Database_Manager database;
- private List<string> commandList = new List<string>();
- //private Word_Export.Word_Export word = new Word_Export.Word_Export();
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Configuração de Variáveis -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public int tries;
- public int wait_time;
- public int deepness;
- public string path_save;
- public string scenario_name;
- public string selenium_timeout = "30000";
- public int scenario_sequence;
- public int scenario;
- public int evidence_width = 800;
- public int evidence_height = 600;
- public bool on_error = false;
- public bool highlight = false;
- public bool on_error_continue = false;
- public int scenario_time_begin = 0;
- public int scenario_time_end = 0;
- public int scenario_time_begin_transaction = 0;
- public int scenario_time_end_transaction = 0;
- public string time_of_test = "";
- public int errorNum = 0;
- public string currentError = "";
- public string save_output = "";
- public int on_error_step = 0;
- private List<string> listCommands = new List<string>();
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Método de configuração principal -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void Config()
- {
- //word.cgPageHeight(15);
- System.Diagnostics.Process.Start("C:/Selenium/selenium-server-standalone-2.42.2.jar");
- selenium = new DefaultSelenium("localhost", 4444, "*googlechrome", "http:generic");
- selenium.Start();
- verificationErrors = new StringBuilder();
- selenium.WindowMaximize();
- set_tries(10);
- selenium.SetTimeout("30000");
- scenario_sequence = 1;
- database = new Database_Manager();
- start_timer_transaction();
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Deepness configuration method -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void set_deepness(int d)
- {
- deepness = d;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Scenario configuration method -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void set_scenario(int d)
- {
- listCommands.Clear();
- //word.createDocument();
- scenario_sequence = 1;
- scenario = d;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Path configuration method -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void set_path(string d)
- {
- System.IO.Directory.CreateDirectory(d);
- path_save = d;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Path configuration method -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void set_path(string d, string ev_name)
- {
- System.IO.Directory.CreateDirectory(d);
- path_save = d + ev_name;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Loop configuration method -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void set_wait(int w)
- {
- wait_time = w;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Wait configuration method -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void set_timeout(int t)
- {
- selenium_timeout = t.ToString();
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Loop configuration Method -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void set_tries(int t)
- {
- tries = t;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Highlight configuration Method -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void set_highlight(bool h)
- {
- highlight = h;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- OnErrorContinue configuration Method -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void set_OnErrorContinue(bool error)
- {
- on_error_continue = error;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Evidence Resolution configuration Method -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void set_EvidenceResolution(int width, int height)
- {
- evidence_height = height;
- evidence_width = width;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:Compare -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public bool Compare(string value1, string value2)
- {
- if (deepness > 0)
- take_evidence("Compare");
- if (value1 == value2)
- return true;
- else
- return false;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Loop configuration method -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public string GetText(string locator)
- {
- if (on_error)
- return "";
- try
- {
- return selenium.GetText(locator);
- }
- catch
- {
- return "Valor não exibido na tela";
- }
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:Type -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void Type(string locator, string value)
- {
- listCommands.Add("Type|" + locator + "|" + value);
- if (on_error)
- return;
- if (deepness > 1)
- take_evidence("Type");
- if (waitelement(locator))
- {
- if (selenium.IsEditable(locator))
- selenium.Type(locator, value);
- else
- {
- if (value == "")
- return;
- Error("editable", locator);
- }
- if (deepness > 0)
- take_evidence("Type");
- return;
- }
- Error("objetone", locator);
- if (deepness > 0)
- take_evidence("Type");
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:Type -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void KeyPress(string locator, string value)
- {
- listCommands.Add("KeyPress|" + locator + "|" + value);
- if (on_error)
- return;
- if (deepness > 1)
- take_evidence("KeyPress");
- if (waitelement(locator))
- {
- if (selenium.IsEditable(locator))
- selenium.Type(locator, value);
- else
- {
- if (value == "")
- return;
- Error("editable", locator);
- }
- if (deepness > 0)
- take_evidence("KeyPress");
- return;
- }
- Error("objetone", locator);
- if (deepness > 0)
- take_evidence("KeyPress");
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:Select -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void Select(string locator, string value)
- {
- listCommands.Add("Select|" + locator + "|" + value);
- if (value == "label=")
- return;
- if (on_error)
- return;
- if (deepness > 1)
- take_evidence("Select");
- if (waitelement(locator))
- {
- selenium.Select(locator, value);
- if (deepness > 0)
- take_evidence("Select");
- return;
- }
- Error("objetone", locator);
- if (deepness > 0)
- take_evidence("Select");
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:Click -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void Click(string locator)
- {
- listCommands.Add("Click|" + locator);
- if (on_error)
- return;
- if (deepness > 1)
- take_evidence("Click");
- if (waitelement(locator))
- {
- try
- {
- selenium.Click(locator);
- wait_for_page("Click", locator);
- return;
- }
- catch (Exception)
- {
- Error("nopen", locator);
- if (deepness > 0)
- take_evidence("Click");
- return;
- }
- }
- Error("objetone", locator);
- if (deepness > 0)
- take_evidence("Click");
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:DoubleClick -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void DoubleClick(string locator)
- {
- listCommands.Add("DoubleClick|" + locator);
- if (on_error)
- return;
- if (deepness > 1)
- take_evidence("DoubleClick");
- if (waitelement(locator))
- {
- selenium.DoubleClick(locator);
- wait_for_page("DoubleClick", locator);
- return;
- }
- Error("objetone", locator);
- if (deepness > 0)
- take_evidence("DoubleClick");
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:DoubleClick -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void Focus(string locator)
- {
- listCommands.Add("Focus|" + locator);
- if (on_error)
- return;
- if (deepness > 1)
- take_evidence("Focus");
- if (waitelement(locator))
- {
- selenium.Focus(locator);
- wait_for_page("Focus", locator);
- return;
- }
- Error("objetone", locator);
- if (deepness > 0)
- take_evidence("Focus");
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:Click -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void Check(string locator)
- {
- listCommands.Add("Check|" + locator);
- if (on_error)
- return;
- if (deepness > 1)
- take_evidence("Check");
- if (waitelement(locator))
- {
- selenium.Check(locator);
- if (deepness > 0)
- take_evidence("Check");
- return;
- }
- Error("objetone", locator);
- if (deepness > 0)
- take_evidence("Check");
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method: MouseOver -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void MouseOver(string locator)
- {
- listCommands.Add("MouseOver|" + locator);
- if (on_error)
- return;
- if (deepness > 1)
- take_evidence("MouseOver");
- if (waitelement(locator))
- {
- selenium.MouseOver(locator);
- if (deepness > 0)
- take_evidence("MouseOver");
- return;
- }
- Error("objetone", locator);
- if (deepness > 0)
- take_evidence("MouseOver");
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:WindowMaximize -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void WindowMaximize()
- {
- try
- {
- selenium.WindowMaximize();
- }
- catch (Exception)
- {
- Error("windowne", "");
- }
- }
- public void Close()
- {
- selenium.Close();
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:Stop -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void Stop()
- {
- selenium.Stop();
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:Open -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void Open(string url)
- {
- listCommands.Add("Open|" + url);
- if (on_error)
- return;
- if (deepness > 1)
- take_evidence("Open");
- try
- {
- selenium.Open(url);
- if (deepness > 0)
- take_evidence("Open");
- return;
- }
- catch (Exception ex)
- {
- return;
- // Ignore errors if unable to close the browser
- }
- Error("open", "");
- if (deepness > 0)
- take_evidence("Open");
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method: WaitElement -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public bool waitelement(string locator)
- {
- for (int n = 0; n < tries; n++)
- {
- if (selenium.IsElementPresent(locator))
- {
- selenium.Focus(locator);
- if (highlight)
- selenium.Highlight(locator);
- return true;
- }
- System.Threading.Thread.Sleep(wait_time);
- }
- return false;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method: IsElementPresent -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public bool IsElementPresent(string locator)
- {
- return selenium.IsElementPresent(locator);
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method: Evidenciar -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void take_evidence(string action)
- {
- ScreenCapture sc = new ScreenCapture();
- Image img = sc.CaptureScreen();
- ImageHandler image = new ImageHandler();
- Bitmap evidencia = new Bitmap(img);
- string path_image = path_save + "_" + scenario.ToString("00#") + "_" + scenario_sequence.ToString("00#") + "_" + action + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("0#") + DateTime.Now.Day.ToString("0#") + ".gif";
- image.Save(evidencia, evidence_width, evidence_height, 60, path_image);
- start_timer_transaction();
- System.Threading.Thread.Sleep(1000);
- scenario_sequence += 1;
- }
- public void CaptureEntirePageScreenshot(string filename, string kwargs)
- {
- selenium.CaptureEntirePageScreenshot(filename, kwargs);
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:Wait For Page -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void WaitForPageToLoad(string timeout)
- {
- selenium.WaitForPageToLoad(timeout);
- take_evidence("PageLoad");
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:Wait For Page -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void wait_for_page()
- {
- try
- {
- selenium.WaitForPageToLoad("1");
- }
- catch
- {
- selenium.WaitForPageToLoad(selenium_timeout);
- return;
- }
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Action Method:Wait For Page Overload(Evidence) -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void wait_for_page(string evidence, string locator)
- {
- take_evidence(evidence);
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Auxiliar Method:start_timer(Starts the Timer) -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void start_timer(){
- scenario_time_begin = (DateTime.Now.Second + DateTime.Now.Minute * 100 + DateTime.Now.Hour * 10000);
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Auxiliar Method:start_timer_transaction(Starts the Timer for steps) -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void start_timer_transaction()
- {
- scenario_time_begin_transaction = (DateTime.Now.Second + DateTime.Now.Minute * 100 + DateTime.Now.Hour * 10000);
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Auxiliar Method:end_timer_transaction(Ends the Timer for steps) -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public string end_timer_transaction()
- {
- int hour = scenario_time_begin_transaction / 10000;
- int minute = (scenario_time_begin_transaction / 100) % 100;
- int second = scenario_time_begin_transaction % 100;
- hour = DateTime.Now.Hour - hour;
- minute = DateTime.Now.Minute - minute;
- if (minute < 0)
- {
- hour -= 1;
- minute += 60;
- }
- second = DateTime.Now.Second - second;
- if (second < 0)
- {
- minute -= 1;
- second += 60;
- }
- scenario_time_end_transaction -= scenario_time_begin_transaction;
- time_of_test = hour.ToString("0#") + ":" + minute.ToString("0#") + ":" + second.ToString("0#");
- return time_of_test;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Auxiliar Method:end_timer(Ends the Timer) -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public string end_timer()
- {
- int hour = scenario_time_begin / 10000;
- int minute = (scenario_time_begin / 100) % 100;
- int second = scenario_time_begin % 100;
- hour = DateTime.Now.Hour - hour;
- minute = DateTime.Now.Minute - minute;
- if (minute < 0){
- hour -= 1;
- minute += 60;
- }
- second = DateTime.Now.Second - second;
- if (second < 0)
- {
- minute -= 1;
- second += 60;
- }
- scenario_time_end -= scenario_time_begin;
- time_of_test = hour.ToString("0#") + ":" + minute.ToString("0#") + ":" + second.ToString("0#");
- return time_of_test;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Error Method -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void Error(string type, string erro)
- {
- on_error = true;
- switch (type)
- {
- case "objetone":
- save_output = "Objeto: " + erro + " não encontrado";
- break;
- case "timeout":
- save_output = "Timeout excedido";
- break;
- case "mensagemne":
- save_output = "Mensagem não esperada";
- break;
- case "editable":
- save_output = "Objeto: " + erro + " não pode ser editado";
- break;
- case "open":
- save_output = "Página: " + erro + " não pode ser aberta";
- break;
- case "nopen":
- save_output = "Não foi possível abrir o arquivo";
- break;
- case "inactive":
- save_output = "A tela: " + erro + " não está ativa";
- break;
- case "itemne":
- save_output = "Item: " + erro + " não encontrado na listbox";
- break;
- }
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Set Error Method -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void set_on_error(bool set){
- on_error = set;
- on_error_step = 0;
- if (on_error == false)
- save_output = "";
- if (on_error_continue)
- on_error = true;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- send_query - For SQL Only -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void send_query(string query)
- {
- database.send_query(query);
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Invokes Me Methods -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void invokeMethod(string name, object[] args)
- {
- this.GetType().GetMethod(name).Invoke(this, args);
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Gets error step -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public int GetOnErrorStep()
- {
- return on_error_step;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Gets the list of steps -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public List<string> GetList(){
- return listCommands;
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Adds a step to the list -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void AddOnList(string type, string locator)
- {
- listCommands.Add(type + "|" + locator);
- }
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- // ---------- Adds a step to the list with its value -------------
- //=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
- public void AddOnList(string type, string locator, string value)
- {
- listCommands.Add(type + "|" + locator + "|" + value);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement