Skip to content
Merged
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
10 changes: 10 additions & 0 deletions UiAutomationGRPC.Client/Calc/Pages/BasePageObject.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
using System;
using UiAutomationGRPC.Library;
using UiAutomationGRPC.Library.Helpers;

namespace UiAutomationGRPC.Client.Calc.Pages
{
public abstract class BasePageObject<T> where T : BasePageObject<T>
{
protected readonly CalcPageLocators Locators;
public UiAutomationDriver _driver;
protected BasePageObject(UiAutomationDriver driver)
{
_driver = driver ?? throw new ArgumentNullException(nameof(driver));
KeyboardHelper.Init(_driver);
}
}
}
26 changes: 10 additions & 16 deletions UiAutomationGRPC.Client/Calc/Pages/CalcNavigationPage.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Automation;
using UiAutomation;
using UiAutomationGRPC.Client.Framework;
using UiAutomationGRPC.Library;
using UiAutomationGRPC.Library.Locators;

namespace UiAutomationGRPC.Client.Calc.Pages
{
public class CalcNavigationPaget<TPage> where TPage : BasePageObject<TPage>
public class CalcNavigationPaget<TPage> : BasePageObject<TPage> where TPage : BasePageObject<TPage>
{
private readonly TPage _previousPage;
private readonly UiAutomationService.UiAutomationServiceClient _client;
private readonly CalcNavigationPagetLocators _locators;
public CalcNavigationPaget(UiAutomationService.UiAutomationServiceClient client, TPage previousPage)
public CalcNavigationPaget(UiAutomationDriver driver, TPage previousPage) : base(driver)
{
_client = client ?? throw new ArgumentNullException(nameof(client));
_driver = driver ?? throw new ArgumentNullException(nameof(driver));
_previousPage = previousPage;
_locators = new CalcNavigationPagetLocators(client);
_locators = new CalcNavigationPagetLocators(driver);
// Optional: Wait for the app to be ready in constructor
_locators.ButtonSettings.WaitForElementExist();
}

public CalcSettingsPage<TPage> ClickSettings()
{
_locators.ButtonSettings.Click();
return new CalcSettingsPage<TPage>(_client, _previousPage);
return new CalcSettingsPage<TPage>(_driver, _previousPage);
}
public TPage ClickNavigationButton()
{
Expand All @@ -37,11 +31,11 @@ public TPage ClickNavigationButton()
}
public class CalcNavigationPagetLocators
{
private readonly UiAutomationService.UiAutomationServiceClient _client;
private readonly UiAutomationDriver _driver;

public CalcNavigationPagetLocators(UiAutomationService.UiAutomationServiceClient client) => _client = client;
public CalcNavigationPagetLocators(UiAutomationDriver driver) => _driver = driver;

private IAutomationElement CreateElement(Func<BaseSelector> selector) => new UiAutomationAdapter(_client, selector);
private IAutomationElement CreateElement(Func<BaseSelector> selector) => new UiAutomationAdapter(_driver, selector);

private Selector Window => new Selector(new PropertyConditions().NameProperty("Calculator"));

Expand Down
31 changes: 17 additions & 14 deletions UiAutomationGRPC.Client/Calc/Pages/CalcPage.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
using System;
using System.Drawing;
using System.Windows.Automation;
using System.Xml.Linq;
using UiAutomation;
using UiAutomationGRPC.Client.Framework;
using UiAutomationGRPC.Library;
using UiAutomationGRPC.Library.Locators;
using UiAutomationGRPC.Library.Helpers;

namespace UiAutomationGRPC.Client.Calc.Pages
{
public class CalcPage : BasePageObject<CalcPage>
{
private readonly UiAutomationService.UiAutomationServiceClient _client;
{
private readonly CalcPageLocators _locators;
public CalcPage(UiAutomationService.UiAutomationServiceClient client)
public CalcPage(UiAutomationDriver driver) : base(driver)
{
// Optional: Wait for the app to be ready in constructor
_client = client;
_locators = new CalcPageLocators(client);
_driver = driver;
_locators = new CalcPageLocators(driver);
_locators.ResultText.WaitForElementExist();
}

Expand Down Expand Up @@ -45,23 +42,29 @@ public string GetResult()
public CalcNavigationPaget<CalcPage> ClickNavigationButton()
{
_locators.ResultText.Name();
return new CalcNavigationPaget<CalcPage>(_client, this);
return new CalcNavigationPaget<CalcPage>(_driver, this);
}

public CalcPage ClickResultText()
{
_locators.ResultText.Click();
return this;
}

public CalcPage SendKey(string key) {
KeyboardHelper.SendKey(key);
return this;
}

}

public class CalcPageLocators
{
private readonly UiAutomationService.UiAutomationServiceClient _client;
private readonly UiAutomationDriver _driver;

public CalcPageLocators(UiAutomationService.UiAutomationServiceClient client) => _client = client;
public CalcPageLocators(UiAutomationDriver driver) => _driver = driver;

private IAutomationElement CreateElement(Func<BaseSelector> selector) => new UiAutomationAdapter(_client, selector);
private IAutomationElement CreateElement(Func<BaseSelector> selector) => new UiAutomationAdapter(_driver, selector);

private Selector Window => new Selector(new PropertyConditions().NameProperty("Calculator"));

Expand Down
25 changes: 12 additions & 13 deletions UiAutomationGRPC.Client/Calc/Pages/CalcSettingsPage.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
using System;
using UiAutomation;
using UiAutomationGRPC.Client.Framework;
using UiAutomationGRPC.Library;
using UiAutomationGRPC.Library.Locators;

namespace UiAutomationGRPC.Client.Calc.Pages
{
public class CalcSettingsPage<TPage> where TPage : BasePageObject<TPage>
public class CalcSettingsPage<TPage> : BasePageObject<TPage> where TPage : BasePageObject<TPage>
{
private readonly TPage _previousPage;
private readonly UiAutomationService.UiAutomationServiceClient _client;
private readonly CalcSettingsPageLocators _locators;
public CalcSettingsPage(UiAutomationService.UiAutomationServiceClient client, TPage previousPage)

public CalcSettingsPage(UiAutomationDriver driver, TPage previousPage) : base(driver)
{
_client = client ?? throw new ArgumentNullException(nameof(client));
_previousPage = previousPage;
_locators = new CalcSettingsPageLocators(client);

_driver = driver ?? throw new ArgumentNullException(nameof(driver));
_locators = new CalcSettingsPageLocators(driver);
// Optional: Wait for the app to be ready in constructor
_locators.BackButton.WaitForElementExist();
}

public CalcPage ClickBack()
{
_locators.BackButton.Click();
return new CalcPage(_client);
return new CalcPage(_driver);
}
}
public class CalcSettingsPageLocators
{
private readonly UiAutomationService.UiAutomationServiceClient _client;
private readonly UiAutomationDriver _driver;

public CalcSettingsPageLocators(UiAutomationService.UiAutomationServiceClient client) => _client = client;
public CalcSettingsPageLocators(UiAutomationDriver driver) => _driver = driver;

private IAutomationElement CreateElement(Func<BaseSelector> selector) => new UiAutomationAdapter(_client, selector);
private IAutomationElement CreateElement(Func<BaseSelector> selector) => new UiAutomationAdapter(_driver, selector);

private Selector Window => new Selector(new PropertyConditions().NameProperty("Calculator"));

Expand Down
36 changes: 0 additions & 36 deletions UiAutomationGRPC.Client/Framework/Helpers/ConditionConverter.cs

This file was deleted.

45 changes: 0 additions & 45 deletions UiAutomationGRPC.Client/Framework/Locators/PropertyConditions.cs

This file was deleted.

Loading