Skip to content

Commit

Permalink
Added proxy DLLs and updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrelex committed Apr 1, 2019
1 parent bec85b7 commit 985606b
Show file tree
Hide file tree
Showing 8 changed files with 239 additions and 0 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using TestProject.Addons.Proxy;
using TestProject.SDK.Common.Attributes;
using TestProject.SDK.Common.Enums;
using TestProject.SDK.Examples.Android.Test.Pages;
using TestProject.SDK.PageObjects;
using TestProject.SDK.Tests;
using TestProject.SDK.Tests.Helpers;

namespace TestProject.SDK.Examples.Android.Test
{
[Test(Name = "Clear Fields")]
public class ProxyTest : IAndroidTest
{
[Parameter(DefaultValue = "John Smith")]
public string name;

[Parameter(DefaultValue = "12345")]
public string password;

[Parameter(DefaultValue = "Earth")]
public string country;

[Parameter(DefaultValue = "Address")]
public string address;

[Parameter(DefaultValue = "[email protected]")]
public string email;


public ExecutionResult Execute(AndroidTestHelper helper)
{
var driver = helper.Driver;
var report = helper.Reporter;

driver.ResetApp();

var loginPage = PageFactory.InitElements<LoginPage>(driver);
report.Step("Launched TestProject Demo app", loginPage.Displayed);

loginPage.Login(name, password);
var profilePage = PageFactory.InitElements<ProfilePage>(driver);

report.Step($"Logged in with {name}:{password}", profilePage.Displayed);

profilePage.HideKeyboardIfVisible();
profilePage.TypeCountry(country);
profilePage.TypeAddress(address);
profilePage.TypeEmail(email);

// Type random phone number using Addon proxy
var actionProxy = CAndroidExampleAddon.CreateTypeRandomPhoneAction("1", 7);
ExecutionResult result = helper.ExecuteProxy(actionProxy, profilePage.GetPhoneElement());
report.Step("Type random phone number using Addon proxy", result.Equals(ExecutionResult.Passed));

// Save profile
profilePage.Save();

report.Step("Profile information saved", profilePage.Saved, TakeScreenshotConditionType.Always);

report.Result = "Test completed successfully";
return ExecutionResult.Passed;
}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using TestProject.Addons.Proxy;
using TestProject.SDK.Common.Attributes;
using TestProject.SDK.Common.Enums;
using TestProject.SDK.Tests;
using TestProject.SDK.Tests.Helpers;

namespace TestProject.SDK.Examples.Generic.Test
{
[Test(Name = "Test with Addon proxy")]
public class ProxyTest : IGenericTest
{

[Parameter(DefaultValue = "1")]
public int a;

[Parameter(DefaultValue = "1")]
public int b;

[Parameter(Description = "Calculation expected result", DefaultValue = "2")]
public int expectedResult;

[Parameter(Description = "Calculation actual result", Direction = ParameterDirection.Output)]
public int actualResult;


public ExecutionResult Execute(GenericTestHelper helper)
{
var actionProxy = CGenericExampleAddon.CreateAdditionAction(a, b);
ExecutionResult result = helper.ExecuteProxy(actionProxy);

actualResult = actionProxy.result;

bool passed = result.Equals(ExecutionResult.Passed) && actualResult == expectedResult;

helper.Reporter.Step($"{a} + {b} == {expectedResult}?", passed);

helper.Reporter.Result = "Addition result is: " + actualResult;

return passed ? ExecutionResult.Passed : ExecutionResult.Failed;
}
}
}
Binary file added IOS/Test/Test/Proxy/AddonProxy.dll
Binary file not shown.
64 changes: 64 additions & 0 deletions IOS/Test/Test/ProxyTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using TestProject.Addons.Proxy;
using TestProject.SDK.Common.Attributes;
using TestProject.SDK.Common.Enums;
using TestProject.SDK.Examples.IOS.Addon;
using TestProject.SDK.Examples.IOS.Test.Pages;
using TestProject.SDK.PageObjects;
using TestProject.SDK.Tests;
using TestProject.SDK.Tests.Helpers;

namespace TestProject.SDK.Examples.IOS.Test
{
[Test(Name = "Clear Fields")]
public class ProxyTest : IIOSTest
{
[Parameter(DefaultValue = "John Smith")]
public string name;

[Parameter(DefaultValue = "12345")]
public string password;

[Parameter(DefaultValue = "Earth")]
public string country;

[Parameter(DefaultValue = "Address")]
public string address;

[Parameter(DefaultValue = "[email protected]")]
public string email;


public ExecutionResult Execute(IOSTestHelper helper)
{
var driver = helper.Driver;
var report = helper.Reporter;

driver.ResetApp();

var loginPage = PageFactory.InitElements<LoginPage>(driver);
report.Step("Launched TestProject Demo app", loginPage.Displayed);

loginPage.Login(name, password);

var profilePage = PageFactory.InitElements<ProfilePage>(driver);
report.Step($"Logged in with {name}:{password}", profilePage.Displayed);

profilePage.TypeCountry(country);
profilePage.TypeAddress(address);
profilePage.TypeEmail(email);

// Type random phone number using Addon proxy
var actionProxy = CiOSExampleAddon.CreateTypeRandomPhoneAction("1", 7);
ExecutionResult result = helper.ExecuteProxy(actionProxy, profilePage.GetPhoneElement());
report.Step("Type random phone number using Addon proxy", result == ExecutionResult.Passed);

// Save profile
profilePage.Save();

report.Step("Profile information saved", profilePage.Saved, TakeScreenshotConditionType.Always);

report.Result = "Test completed successfully";
return ExecutionResult.Passed;
}
}
}
Binary file not shown.
69 changes: 69 additions & 0 deletions Web/Test/TestProject.SDK.Examples.Web.Test/Test/ProxyTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using TestProject.SDK.Examples.Web.Test.Pages;
using TestProject.SDK.Tests;
using TestProject.SDK.Tests.Helpers;
using TestProject.SDK.Common.Attributes;
using TestProject.SDK.PageObjects;
using TestProject.SDK.Common.Enums;
using TestProject.SDK.Examples.Web.Addon;
using TestProject.SDK.Reporters;

namespace TestProject.SDK.Examples.Web.Test
{
[Test(Name = "Test with Addon proxy")]
public class ProxyTest : IWebTest
{
[Parameter(DefaultValue = "John Smith")]
public string name;

[Parameter(DefaultValue = "12345")]
public string password;

[Parameter(DefaultValue = "United States")]
public string country;

[Parameter(DefaultValue = "Address")]
public string address;

[Parameter(DefaultValue = "[email protected]")]
public string email;

public ExecutionResult Execute(WebTestHelper helper)
{
// Get driver initialized by TestProject Agent
// No need to specify browser type, it can be done later via UI
var driver = helper.Driver;
TestReporter report = helper.Reporter;

// Navigate to TestProject Demo website
driver.Navigate().GoToUrl("https://example.testproject.io/web/");

// Initialize the properties of the LoginPage with the driver
var loginPage = PageFactory.InitElements<LoginPage>(driver);
report.Step("Navigated to TestProject Demo", loginPage.Displayed);

// Login using provided credentials
loginPage.Login(name, password);

// Initialize the properties of the profilePage with the driver
var profilePage = PageFactory.InitElements<ProfilePage>(driver);
report.Step($"Logged in with {name}:{password}", profilePage.Displayed);

profilePage.SelectCountry(country);
profilePage.TypeAddress(address);
profilePage.TypeEmail(email);

// Type random phone number using Addon proxy
var actionProxy = new TypeRandomPhoneAction("1", 7);
ExecutionResult result = helper.ExecuteProxy(actionProxy, profilePage.GetPhoneElement());
report.Step("Type random phone number using Addon proxy", result == ExecutionResult.Passed);

// Save profile
profilePage.Save();
report.Step("Profile information saved", profilePage.Saved, TakeScreenshotConditionType.Always);

report.Result = "Test completed successfully";
return profilePage.Saved ? ExecutionResult.Passed : ExecutionResult.Failed;
}
}
}

0 comments on commit 985606b

Please sign in to comment.