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