Fixed issues with script manager
This commit is contained in:
parent
b63f2eb3f7
commit
f65d2df7cf
5 changed files with 14 additions and 26 deletions
BankingBot
|
@ -37,15 +37,6 @@ namespace BankingBot.ActionManagers.LoginManagers
|
||||||
var response = new Response();
|
var response = new Response();
|
||||||
var lloydsCreds = (LloydsLoginCredentials)credentials;
|
var lloydsCreds = (LloydsLoginCredentials)credentials;
|
||||||
|
|
||||||
var data = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "name", "aaron" },
|
|
||||||
{ "age", "12" },
|
|
||||||
{ "isOldEnough", "true" }
|
|
||||||
};
|
|
||||||
|
|
||||||
_scriptManager.Execute("scripts/test.js", data, ScriptBundles.Global);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoginStep1(lloydsCreds);
|
LoginStep1(lloydsCreds);
|
||||||
|
|
|
@ -83,7 +83,9 @@
|
||||||
<Content Include="ScriptManagement\Scripts\jquery-3.1.1.min.js">
|
<Content Include="ScriptManagement\Scripts\jquery-3.1.1.min.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="ScriptManagement\Scripts\test.js" />
|
<Content Include="ScriptManagement\Scripts\test.js">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
using System;
|
namespace BankingBot.ScriptManagement
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace BankingBot.ScriptManagement
|
|
||||||
{
|
{
|
||||||
public static class ScriptBundles
|
public static class ScriptBundles
|
||||||
{
|
{
|
||||||
public static string[] Global => new[]
|
public static string[] Global => new[]
|
||||||
{
|
{
|
||||||
"scripts/jquery-3.1.1.min",
|
"ScriptManagement/Scripts/jquery-3.1.1.min.js",
|
||||||
"scripts/global.js"
|
"ScriptManagement/Scripts/global.js"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using BankingBot.Contracts;
|
using BankingBot.Contracts;
|
||||||
using OpenQA.Selenium;
|
using OpenQA.Selenium;
|
||||||
using OpenQA.Selenium.Internal;
|
|
||||||
|
|
||||||
namespace BankingBot.ScriptManagement
|
namespace BankingBot.ScriptManagement
|
||||||
{
|
{
|
||||||
|
@ -30,6 +26,7 @@ namespace BankingBot.ScriptManagement
|
||||||
{
|
{
|
||||||
var script = GenerateScript(scriptPath, data, includedScripts);
|
var script = GenerateScript(scriptPath, data, includedScripts);
|
||||||
var executor = _browserBot.WebDriver as IJavaScriptExecutor;
|
var executor = _browserBot.WebDriver as IJavaScriptExecutor;
|
||||||
|
executor.ExecuteScript(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetIncludedScriptsCompilation(string currentCompliation, string[] scripts)
|
private string GetIncludedScriptsCompilation(string currentCompliation, string[] scripts)
|
||||||
|
@ -47,7 +44,7 @@ namespace BankingBot.ScriptManagement
|
||||||
|
|
||||||
private string GetScriptContent(string scriptPath)
|
private string GetScriptContent(string scriptPath)
|
||||||
{
|
{
|
||||||
return File.ReadAllText(scriptPath).Trim();
|
return File.ReadAllText(scriptPath).Trim() + Environment.NewLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetScriptWithPopulatedData(string currentCompliation, Dictionary<string, string> data)
|
private string GetScriptWithPopulatedData(string currentCompliation, Dictionary<string, string> data)
|
||||||
|
@ -58,7 +55,7 @@ namespace BankingBot.ScriptManagement
|
||||||
foreach (var pair in data)
|
foreach (var pair in data)
|
||||||
{
|
{
|
||||||
var placeholderText = string.Format(placeholderFormat, pair.Key);
|
var placeholderText = string.Format(placeholderFormat, pair.Key);
|
||||||
currentCompliation = currentCompliation.Replace(placeholderText, pair.Value);
|
currentCompliation = currentCompliation.Replace(placeholderText, $"\"{pair.Value}\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
(function () {
|
(function () {
|
||||||
// Do the placeholders work?
|
// Do the placeholders work?
|
||||||
var netVersion = __$netVersion;
|
//var netVersion = __$netVersion;
|
||||||
|
|
||||||
|
var name = __$name;
|
||||||
|
var age = __$age;
|
||||||
|
var isoldenough = __$isOldEnough;
|
||||||
|
|
||||||
// Do the modules work?
|
// Do the modules work?
|
||||||
global.testFunction();
|
global.testFunction();
|
||||||
|
|
Loading…
Add table
Reference in a new issue