Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0"?>

<configuration>
<configSections>
<sectionGroup name="White">
<section name="Core" type="System.Configuration.NameValueSectionHandler" />
</sectionGroup>
</configSections>
<appSettings>
<add key="Browser1" value="Chrome" />
<!-- <add key="Browser1" value="Chrome" />-->
<!-- <add key="Browser3" value="PhantomJS" />-->
<!-- <add key="Browser4" value="Safari" />-->
<!-- <add key="Browser4" value="Edge" />-->
<add key="HostIp" value="localhost" />
<add key="LaunchBrowser" value="True" />
<add key="CommandDelayMs" value="0" />
<add key="RunOnRemoteHost" value="false" />
<add key="DegreeOfParallelism" value="5" />
<add key="HtmlOnError" value="False" />
<add key="ScreenshotOnError" value="True" />
<add key="VideoRecordingOnError" value="True" />
<add key="ValidateTraffic" value="True" />
<add key="CommandLogging" value="True" />
<add key="ActionLogging" value="True" />
<add key="DiagnosticLog" value="True" />
<add key="TestLog" value="True" />
<add key="StartProxy" value="False"/>
<add key="UseProxy" value="False"/>
<add key="ProxyPort" value="18881" />
<add key="ProxyServerPort" value="18880" />
<add key="TestTimeoutMin" value="5" />
<add key="ElementTimeoutSec" value="5" />
<add key="EnvironmentUrl" value="http://www.google.com" />
<add key="ValidateSpellcheck" value="false" />
<add key="CustomSetting" value="WasFound" />
<add key="UpdateImages" value="False" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
<add key="UserAgent" value="Golem Test Automation" />
<add key="RelativePath" value="True" />
<add key="CompressToZip" value="True" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider"
type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider"
type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
</configuration>
100 changes: 100 additions & 0 deletions Appium/AppiumTouchCommands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using OpenQA.Selenium;
using ProtoTest.Golem.WebDriver;

namespace ProtoTest.Golem.Appium
{
public class AppiumTouchCommands
{
private readonly IWebDriver driver;
public Dictionary<String, Double> coords;

public AppiumTouchCommands(IWebDriver driver)
{
this.driver = driver;
}

public void ResetCoordinates()
{
coords = new Dictionary<string, double>();
}

public void AddCoordinate(string key, double value)
{
coords.Add(key, value);
}

public void Execute(string command)
{
driver.ExecuteJavaScript("mobile: " + command, coords);
}

public void Tap(double X, double Y, int count = 1, double duration = .1)
{
coords = new Dictionary<string, double>();
coords.Add("x", X);
coords.Add("y", Y);
coords.Add("tapCount", count);
coords.Add("duration", duration);
driver.ExecuteJavaScript("mobile: swipe", coords);
}

public void ScrollTo(string id)
{
var elementObject = new Dictionary<string, string>();
elementObject.Add("element", id);
driver.ExecuteJavaScript("mobile: scrollTo", elementObject);
}

public void Swipe(double startX, double startY, double endX, double endY)
{
coords = new Dictionary<string, double>();
coords.Add("startX", startX);
coords.Add("startY", startY);
coords.Add("endX", endX);
coords.Add("endY", endY);
driver.ExecuteJavaScript("mobile: swipe", coords);
}

public void SwipeDown()
{
coords = new Dictionary<string, double>();
coords.Add("startX", 0.5);
coords.Add("startY", 0.95);
coords.Add("endX", 0.5);
coords.Add("endY", 0.05);
driver.ExecuteJavaScript("mobile: swipe", coords);
}

public void SwipeUp()
{
coords = new Dictionary<string, double>();
coords.Add("startX", 0.5);
coords.Add("startY", 0.05);
coords.Add("endX", 0.5);
coords.Add("endY", 0.95);
driver.ExecuteJavaScript("mobile: swipe", coords);
}

public void SwipeRight()
{
coords = new Dictionary<string, double>();
coords.Add("startX", 0.05);
coords.Add("startY", 0.5);
coords.Add("endX", 0.95);
coords.Add("endY", 0.5);
driver.ExecuteJavaScript("mobile: swipe", coords);
}

public void SwipeLeft()
{
coords = new Dictionary<string, double>();
coords.Add("startX", 0.95);
coords.Add("startY", 0.5);
coords.Add("endX", 0.05);
coords.Add("endY", 0.5);
driver.ExecuteJavaScript("mobile: swipe", coords);
}
}
}
94 changes: 94 additions & 0 deletions Core/ActionList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;

namespace Golem.Core
{
/// <summary>
/// Holds a list of Actions, with some functions to help print
/// </summary>
public class ActionList
{
public List<Action> actions;

public ActionList()
{
actions = new List<Action>();
}

public void addAction(string name, DateTime time)
{
actions.Add(new Action(name, time));
}

public void addAction(string name, Action.ActionType type=Action.ActionType.Other)
{
var time = DateTime.Now;
actions.Add(new Action(name, time, type));
}

public void PrintActions()
{
foreach (var a in actions)
{
Log.Message(a.name + " : " + a.time.ToString("HH:mm:ss.ffff"));
}
}

public void PrintActionTimings()
{
DateTime start;
DateTime end;
TimeSpan difference;
for (var i = 1; i < actions.Count; i++)
{
while (actions[i].name == actions[i - 1].name)
{
i++;
}
start = actions[i - 1].time;
end = actions[i].time;
difference = end.Subtract(start);
Log.Message(actions[i].name + " : " + difference);
}
start = actions[0].time;
end = actions[actions.Count - 1].time;
difference = end.Subtract(start);
Log.Message("All Actions : " + difference);
}

public void RemoveDuplicateEntries()
{
var distinctItems = actions.GroupBy(x => x.name).Select(y => y.Last());
actions = distinctItems.ToList();
}

public class Action
{
public DateTime time;
public string name;
public ActionType type;

public Action(string name, DateTime time, ActionType type=ActionType.Other)
{
this.name = name;
this.time = time;
this.type = type;
}

public enum ActionType
{
Message = 0,
Warning = 1,
Error = 2,
Video = 3,
Image = 4,
Link = 5,
Other = 6
}
}
}


}
54 changes: 54 additions & 0 deletions Core/BackgroundVideoRecorder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using Gallio.Common.Media;
using Gallio.Framework;
using ProtoTest.Golem.WebDriver;

namespace ProtoTest.Golem.Core
{
public class BackgroundVideoRecorder
{
public BackgroundWorker bgWorker;
public Video video;
public Size screensize;
public int fps;
public int frameDelayMs;
public BackgroundVideoRecorder(int fps)
{
this.fps = fps;
this.frameDelayMs = 1000 / fps;
screensize = WebDriverTestBase.testData.driver.GetScreenshot().Size;
Common.Log("The current dimensions are : " + screensize.Width + " x " + screensize.Height);
video = new FlashScreenVideo(new FlashScreenVideoParameters(screensize.Width, screensize.Height, fps));
bgWorker = new BackgroundWorker();
bgWorker.DoWork += bgWorker_DoWork;
bgWorker.WorkerSupportsCancellation = true;
bgWorker.RunWorkerAsync();
}

void Stop()
{
bgWorker.CancelAsync();
}

void bgWorker_DoWork(object sender, DoWorkEventArgs e)
{
while (!bgWorker.CancellationPending)
{

var bitmap = new Bitmap(WebDriverTestBase.testData.driver.GetScreenshot());
Common.Log("Bitmap dimensions are : " + bitmap.Width + " x " + bitmap.Height);
if(bitmap!=null)
video.AddFrame(new BitmapVideoFrame(bitmap));

Thread.Sleep(frameDelayMs);
}

}
}
}
Loading