forked from eldarkra/csharp-sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+3 KB
Android/Test/TestProject.SDK.Examples.Android.Test/Test/Proxy/AddonProxy.dll
Binary file not shown.
64 changes: 64 additions & 0 deletions
64
Android/Test/TestProject.SDK.Examples.Android.Test/Test/ProxyTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 added
BIN
+3 KB
Generic/Test/TestProject.SDK.Examples.Generic.Test/Test/Proxy/AddonProxy.dll
Binary file not shown.
42 changes: 42 additions & 0 deletions
42
Generic/Test/TestProject.SDK.Examples.Generic.Test/Test/ProxyTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
69
Web/Test/TestProject.SDK.Examples.Web.Test/Test/ProxyTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |