Skip to content

Commit

Permalink
Merge pull request saucepleez#5 from saucepleez/development-branch
Browse files Browse the repository at this point in the history
Development branch
  • Loading branch information
saucepleez authored Jul 2, 2018
2 parents 11a0706 + df2f456 commit 002e904
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 43 deletions.
2 changes: 2 additions & 0 deletions taskt/Core/ApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ public class EngineSettings
public bool AutoCloseDebugWindow { get; set; }
public bool EnableDiagnosticLogging { get; set; }
public bool ShowAdvancedDebugOutput { get; set; }
public bool CreateMissingVariablesDuringExecution { get; set; }
public EngineSettings()
{
ShowDebugWindow = true;
AutoCloseDebugWindow = true;
EnableDiagnosticLogging = true;
ShowAdvancedDebugOutput = false;
CreateMissingVariablesDuringExecution = true;
}
}
/// <summary>
Expand Down
74 changes: 54 additions & 20 deletions taskt/Core/AutomationCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public IEBrowserCreateCommand()
this.CommandName = "IEBrowserCreateCommand";
this.SelectionName = "Create Browser";
this.v_InstanceName = "default";
this.CommandEnabled = true;
this.CommandEnabled = false;
}

public override void RunCommand(object sender)
Expand Down Expand Up @@ -198,7 +198,7 @@ public IEBrowserFindBrowserCommand()
this.CommandName = "IEBrowserFindBrowserCommand";
this.SelectionName = "Find Browser";
this.v_InstanceName = "default";
this.CommandEnabled = true;
this.CommandEnabled = false;
}

public override void RunCommand(object sender)
Expand Down Expand Up @@ -260,7 +260,7 @@ public IEBrowserNavigateCommand()
this.CommandName = "WebBrowserNavigateCommand";
this.SelectionName = "Navigate";
this.v_InstanceName = "default";
this.CommandEnabled = true;
this.CommandEnabled = false;
}

public override void RunCommand(object sender)
Expand Down Expand Up @@ -309,7 +309,7 @@ public IEBrowserCloseCommand()
{
this.CommandName = "IEBrowserCloseCommand";
this.SelectionName = "Close Browser";
this.CommandEnabled = true;
this.CommandEnabled = false;
this.v_InstanceName = "default";
}

Expand Down Expand Up @@ -356,7 +356,8 @@ public IEBrowserElementCommand()
{
this.CommandName = "IEBrowserElementCommand";
this.SelectionName = "Element Action";
this.CommandEnabled = true;
//this command is broken -- consider enhancing selenium instead
this.CommandEnabled = false;
this.v_InstanceName = "default";

this.v_WebSearchTable = new System.Data.DataTable
Expand Down Expand Up @@ -882,6 +883,7 @@ public class SeleniumBrowserElementActionCommand : ScriptCommand
public string v_SeleniumElementAction { get; set; }
[XmlElement]
[Attributes.PropertyAttributes.PropertyDescription("Additional Parameters")]
[Attributes.PropertyAttributes.PropertyUIHelper(Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)]
public DataTable v_WebActionParameterTable { get; set; }
public SeleniumBrowserElementActionCommand()
{
Expand All @@ -902,7 +904,8 @@ public override void RunCommand(object sender)
{
var sendingInstance = (UI.Forms.frmScriptEngine)sender;
//convert to user variable -- https://github.com/saucepleez/taskt/issues/22
v_SeleniumSearchParameter = v_SeleniumSearchParameter.ConvertToUserVariable(sender);
var seleniumSearchParam = v_SeleniumSearchParameter.ConvertToUserVariable(sender);


if (sendingInstance.appInstances.TryGetValue(v_InstanceName, out object browserObject))
{
Expand All @@ -912,9 +915,14 @@ public override void RunCommand(object sender)

if (v_SeleniumElementAction == "Wait For Element To Exist")
{
int timeOut = Convert.ToInt32((from rw in v_WebActionParameterTable.AsEnumerable()
where rw.Field<string>("Parameter Name") == "Timeout (Seconds)"
select rw.Field<string>("Parameter Value")).FirstOrDefault());

var timeoutText = (from rw in v_WebActionParameterTable.AsEnumerable()
where rw.Field<string>("Parameter Name") == "Timeout (Seconds)"
select rw.Field<string>("Parameter Value")).FirstOrDefault();

timeoutText = timeoutText.ConvertToUserVariable(sender);

int timeOut = Convert.ToInt32(timeoutText);

var timeToEnd = DateTime.Now.AddSeconds(timeOut);

Expand Down Expand Up @@ -950,23 +958,23 @@ where rw.Field<string>("Parameter Name") == "Timeout (Seconds)"
switch (v_SeleniumSearchType)
{
case "Find Element By XPath":
element = seleniumInstance.FindElementByXPath(v_SeleniumSearchParameter);
element = seleniumInstance.FindElementByXPath(seleniumSearchParam);
break;

case "Find Element By ID":
element = seleniumInstance.FindElementById(v_SeleniumSearchParameter);
element = seleniumInstance.FindElementById(seleniumSearchParam);
break;

case "Find Element By Name":
element = seleniumInstance.FindElementByName(v_SeleniumSearchParameter);
element = seleniumInstance.FindElementByName(seleniumSearchParam);
break;

case "Find Element By Tag Name":
element = seleniumInstance.FindElementByTagName(v_SeleniumSearchParameter);
element = seleniumInstance.FindElementByTagName(seleniumSearchParam);
break;

case "Find Element By Class Name":
element = seleniumInstance.FindElementByClassName(v_SeleniumSearchParameter);
element = seleniumInstance.FindElementByClassName(seleniumSearchParam);
break;

default:
Expand All @@ -983,13 +991,15 @@ where rw.Field<string>("Parameter Name") == "Timeout (Seconds)"
case "Right Click":
case "Middle Click":
case "Double Left Click":


int userXAdjust = Convert.ToInt32((from rw in v_WebActionParameterTable.AsEnumerable()
where rw.Field<string>("Parameter Name") == "X Adjustment"
select rw.Field<string>("Parameter Value")).FirstOrDefault());
select rw.Field<string>("Parameter Value")).FirstOrDefault().ConvertToUserVariable(sender));

int userYAdjust = Convert.ToInt32((from rw in v_WebActionParameterTable.AsEnumerable()
where rw.Field<string>("Parameter Name") == "Y Adjustment"
select rw.Field<string>("Parameter Value")).FirstOrDefault());
select rw.Field<string>("Parameter Value")).FirstOrDefault().ConvertToUserVariable(sender));

var elementLocation = element.Location;
SendMouseMoveCommand newMouseMove = new SendMouseMoveCommand();
Expand Down Expand Up @@ -1041,7 +1051,7 @@ where rw.Field<string>("Parameter Name") == "Variable Name"

string attributeName = (from rw in v_WebActionParameterTable.AsEnumerable()
where rw.Field<string>("Parameter Name") == "Attribute Name"
select rw.Field<string>("Parameter Value")).FirstOrDefault();
select rw.Field<string>("Parameter Value")).FirstOrDefault().ConvertToUserVariable(sender);

string elementValue;
if (v_SeleniumElementAction == "Get Text")
Expand Down Expand Up @@ -1673,19 +1683,42 @@ public VariableCommand()

public override void RunCommand(object sender)
{
//get sending instance
var sendingInstance = (UI.Forms.frmScriptEngine)sender;
var requiredVariable = sendingInstance.variableList.Where(var => var.variableName == v_userVariableName).FirstOrDefault();


var requiredVariable = LookupVariable(sendingInstance);

//if still not found and user has elected option, create variable at runtime
if ((requiredVariable == null) && (sendingInstance.createMissingVariables))
{
sendingInstance.variableList.Add(new Script.ScriptVariable() { variableName = v_userVariableName });
requiredVariable = LookupVariable(sendingInstance);
}

if (requiredVariable != null)
{
requiredVariable.variableValue = v_Input.ConvertToUserVariable(sender);
}
else
{
throw new Exception("Variable was not found. Enclose variables within brackets, ex. [vVariable]");
throw new Exception("Attempted to store data in a variable, but it was not found. Enclose variables within brackets, ex. [vVariable]");
}
}

private Script.ScriptVariable LookupVariable(UI.Forms.frmScriptEngine sendingInstance)
{
//search for the variable
var requiredVariable = sendingInstance.variableList.Where(var => var.variableName == v_userVariableName).FirstOrDefault();

//if variable was not found but it starts with variable naming pattern
if ((requiredVariable == null) && (v_userVariableName.StartsWith("[")) && (v_userVariableName.EndsWith("]")))
{
//reformat and attempt
var reformattedVariable = v_userVariableName.Replace("[", "").Replace("]", "");
requiredVariable = sendingInstance.variableList.Where(var => var.variableName == reformattedVariable).FirstOrDefault();
}

return requiredVariable;
}

public override string GetDisplayValue()
Expand Down Expand Up @@ -2837,6 +2870,7 @@ public class BeginIfCommand : ScriptCommand

[XmlElement]
[Attributes.PropertyAttributes.PropertyDescription("Additional Parameters")]
[Attributes.PropertyAttributes.PropertyUIHelper(Attributes.PropertyAttributes.PropertyUIHelper.UIAdditionalHelperType.ShowVariableHelper)]
public DataTable v_IfActionParameterTable { get; set; }

public BeginIfCommand()
Expand Down
2 changes: 1 addition & 1 deletion taskt/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.0.*")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.1.0")]
//[assembly: AssemblyVersion("0.0.0.2")]
//[assembly: AssemblyFileVersion("0.0.0.2")]
19 changes: 14 additions & 5 deletions taskt/UI/CustomControls/CustomControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ public static Dictionary<string, Image> UIImageDictionary()
uiImages.Add("RunTaskCommand", taskt.Properties.Resources.command_start_process);
uiImages.Add("StopTaskCommand", taskt.Properties.Resources.command_stop_process);
uiImages.Add("CloseWindowCommand", taskt.Properties.Resources.command_window_close);
uiImages.Add("WebBrowserCreateCommand", taskt.Properties.Resources.command_web);
uiImages.Add("WebBrowserNavigateCommand", taskt.Properties.Resources.command_web);
uiImages.Add("WebBrowserCloseCommand", taskt.Properties.Resources.command_window_close);
uiImages.Add("WebBrowserElementCommand", taskt.Properties.Resources.command_web);
uiImages.Add("IEBrowserCreateCommand", taskt.Properties.Resources.command_web);
uiImages.Add("IEBrowserNavigateCommand", taskt.Properties.Resources.command_web);
uiImages.Add("IEBrowserCloseCommand", taskt.Properties.Resources.command_window_close);
uiImages.Add("IEBrowserElementCommand", taskt.Properties.Resources.command_web);
uiImages.Add("SendKeysCommand", taskt.Properties.Resources.command_input);
uiImages.Add("SendMouseMoveCommand", taskt.Properties.Resources.command_input);
uiImages.Add("SendMouseClickCommand", taskt.Properties.Resources.command_input);
Expand Down Expand Up @@ -390,7 +390,16 @@ public static Image ResizeImageFile(Image image)
public static Image GetUIImage(string commandName)
{
var uiImageDictionary = UIImageDictionary();
return uiImageDictionary[commandName];
Image uiImage;
try
{
uiImage = uiImageDictionary[commandName];
}
catch (Exception)
{
uiImage = Properties.Resources.command_files;
}
return uiImage;
}
}
}
Loading

0 comments on commit 002e904

Please sign in to comment.