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
42 changes: 2 additions & 40 deletions src/Appium.Net/Appium/Android/AndroidDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

namespace OpenQA.Selenium.Appium.Android
{
public class AndroidDriver<W> : AppiumDriver<W>, IFindByAndroidUIAutomator<W>, IFindByAndroidDataMatcher<W>,
public class AndroidDriver : AppiumDriver,
IStartsActivity,
IHasNetworkConnection, INetworkActions, IHasClipboard, IHasPerformanceData,
ISendsKeyEvents,
IPushesFiles, IHasSettings where W : IWebElement
IPushesFiles, IHasSettings
{
private static readonly string Platform = MobilePlatform.Android;

Expand Down Expand Up @@ -127,42 +127,6 @@ public AndroidDriver(AppiumLocalService service, DriverOptions driverOptions,
{
}

#region IFindByAndroidUIAutomator Members

public W FindElementByAndroidUIAutomator(string selector) =>
FindElement(MobileSelector.AndroidUIAutomator, selector);

public W FindElementByAndroidUIAutomator(IUiAutomatorStatementBuilder selector) =>
FindElement(MobileSelector.AndroidUIAutomator, selector.Build());

public IReadOnlyCollection<W> FindElementsByAndroidUIAutomator(string selector) =>
ConvertToExtendedWebElementCollection<W>(FindElements(MobileSelector.AndroidUIAutomator, selector));

public IReadOnlyCollection<W> FindElementsByAndroidUIAutomator(IUiAutomatorStatementBuilder selector) =>
ConvertToExtendedWebElementCollection<W>(FindElements(MobileSelector.AndroidUIAutomator, selector.Build()));

#endregion IFindByAndroidUIAutomator Members

#region IFindByAndroidDataMatcher Members

public W FindElementByAndroidDataMatcher(string selector) =>
FindElement(MobileSelector.AndroidDataMatcher, selector);

public IReadOnlyCollection<W> FindElementsByAndroidDataMatcher(string selector) =>
ConvertToExtendedWebElementCollection<W>(FindElements(MobileSelector.AndroidDataMatcher, selector));

#endregion IFindByAndroidDataMatcher Members

#region IFindByAndroidViewMatcher Members

public W FindElementByAndroidViewMatcher(string selector) =>
FindElement(MobileSelector.AndroidViewMatcher, selector);

public IReadOnlyCollection<W> FindElementsByAndroidViewMatcher(string selector) =>
ConvertToExtendedWebElementCollection<W>(FindElements(MobileSelector.AndroidViewMatcher, selector));

#endregion IFindByAndroidViewMatcher Members

public void StartActivity(string appPackage, string appActivity, string appWaitPackage = "",
string appWaitActivity = "", bool stopApp = true) =>
AndroidCommandExecutionHelper.StartActivity(this, appPackage, appActivity, appWaitPackage, appWaitActivity,
Expand Down Expand Up @@ -302,8 +266,6 @@ public IList<string> GetPerformanceDataTypes() =>
public string EndTestCoverage(string intent, string path) =>
AndroidCommandExecutionHelper.EndTestCoverage(this, intent, path);

protected override WebElementFactory CreateElementFactory() => new AndroidElementFactory(this);

public void SetSetting(string setting, object value) =>
AndroidCommandExecutionHelper.SetSetting(this, setting, value);

Expand Down
71 changes: 0 additions & 71 deletions src/Appium.Net/Appium/Android/AndroidElement.cs

This file was deleted.

15 changes: 0 additions & 15 deletions src/Appium.Net/Appium/Android/AndroidElementFactory.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/Appium.Net/Appium/AppiumCommandExecutionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static void SetClipboard(IExecuteMethod executeMethod, ClipboardContentTy
{
case ClipboardContentType.Image:
case ClipboardContentType.Url:
if (executeMethod.GetType().GetGenericTypeDefinition() == typeof(AndroidDriver<>))
if (executeMethod.GetType().GetGenericTypeDefinition() == typeof(AndroidDriver))
{
throw new NotImplementedException(
$"Android only supports contentType: {nameof(ClipboardContentType.PlainText)}");
Expand All @@ -118,7 +118,7 @@ public static string GetClipboard(IExecuteMethod executeMethod, ClipboardContent
{
case ClipboardContentType.Image:
case ClipboardContentType.Url:
if (executeMethod.GetType().GetGenericTypeDefinition() == typeof(AndroidDriver<>))
if (executeMethod.GetType().GetGenericTypeDefinition() == typeof(AndroidDriver))
{
throw new NotImplementedException(
$"Android only supports contentType: {nameof(ClipboardContentType.PlainText)}");
Expand Down
108 changes: 18 additions & 90 deletions src/Appium.Net/Appium/AppiumDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
//See the License for the specific language governing permissions and
//limitations under the License.

using Appium.Interfaces.Generic.SearchContext;
using OpenQA.Selenium.Appium.Enums;
using OpenQA.Selenium.Appium.Interfaces;
using OpenQA.Selenium.Appium.Service;
using OpenQA.Selenium.Internal;
using OpenQA.Selenium.Interactions;
using System;
using System.Collections;
Expand All @@ -29,15 +27,11 @@

namespace OpenQA.Selenium.Appium
{
public abstract class AppiumDriver<W> : WebDriver, IFindsByImage<W>,
public abstract class AppiumDriver : WebDriver,
IHasSessionDetails,
IHasLocation,
IFindByAccessibilityId<W>,
IHidesKeyboard, IInteractsWithFiles,
IInteractsWithApps, IPerformsTouchActions, IRotatable, IContextAware, IGenericSearchContext<W>,
IGenericFindsByClassName<W>,
IGenericFindsById<W>, IGenericFindsByCssSelector<W>, IGenericFindsByLinkText<W>, IGenericFindsByName<W>,
IGenericFindsByPartialLinkText<W>, IGenericFindsByTagName<W>, IGenericFindsByXPath<W> where W : IWebElement
IHidesKeyboard, IInteractsWithFiles, IFindsByFluentSelector<AppiumWebElement>,
IInteractsWithApps, IPerformsTouchActions, IRotatable, IContextAware
{
private const string NativeApp = "NATIVE_APP";

Expand Down Expand Up @@ -92,94 +86,28 @@ public AppiumDriver(AppiumLocalService service, ICapabilities appiumOptions, Tim

#endregion Constructors

#region Generic FindMethods

public new W FindElement(By by) =>
(W)base.FindElement(by);

public new ReadOnlyCollection<W> FindElements(By by) =>
ConvertToExtendedWebElementCollection<W>(base.FindElements(by));

public new W FindElement(string by, string value) => (W)base.FindElement(by, value);

public new IReadOnlyCollection<W> FindElements(string selector, string value) =>
ConvertToExtendedWebElementCollection<W>(base.FindElements(selector, value));

public W FindElementByClassName(string className) =>
(W)base.FindElement(MobileSelector.ClassName, className);

public ReadOnlyCollection<W> FindElementsByClassName(string className) =>
ConvertToExtendedWebElementCollection<W>(base.FindElements(MobileSelector.ClassName, className));

public W FindElementById(string id) =>
(W)base.FindElement(MobileSelector.Id, id);

public ReadOnlyCollection<W> FindElementsById(string id) =>
ConvertToExtendedWebElementCollection<W>(base.FindElements(MobileSelector.Id, id));

public W FindElementByCssSelector(string cssSelector) =>
(W)base.FindElement("css selector", cssSelector);

public ReadOnlyCollection<W> FindElementsByCssSelector(string cssSelector) =>
ConvertToExtendedWebElementCollection<W>(base.FindElements("css selector", cssSelector));

public W FindElementByLinkText(string linkText) =>
(W)base.FindElement("link text", linkText);

public ReadOnlyCollection<W> FindElementsByLinkText(string linkText) =>
ConvertToExtendedWebElementCollection<W>(base.FindElements("link text", linkText));

public W FindElementByName(string name) =>
(W)base.FindElement(MobileSelector.Name, name);

public ReadOnlyCollection<W> FindElementsByName(string name) =>
ConvertToExtendedWebElementCollection<W>(base.FindElements(MobileSelector.Name, name));

public W FindElementByPartialLinkText(string partialLinkText) =>
(W)base.FindElement("partial link text", partialLinkText);

public ReadOnlyCollection<W> FindElementsByPartialLinkText(string partialLinkText) =>
ConvertToExtendedWebElementCollection<W>(base.FindElements("partial link text", partialLinkText));

public W FindElementByTagName(string tagName) =>
(W)base.FindElement(MobileSelector.TagName, tagName);

public ReadOnlyCollection<W> FindElementsByTagName(string tagName) =>
ConvertToExtendedWebElementCollection<W>(base.FindElements(MobileSelector.TagName, tagName));

public W FindElementByXPath(string xpath) =>
(W)base.FindElement("xpath", xpath);

public ReadOnlyCollection<W> FindElementsByXPath(string xpath) =>
ConvertToExtendedWebElementCollection<W>(base.FindElements("xpath", xpath));

#region IFindByAccessibilityId Members

public W FindElementByAccessibilityId(string selector) => FindElement(MobileSelector.Accessibility, selector);

public IReadOnlyCollection<W> FindElementsByAccessibilityId(string selector) =>
FindElements(MobileSelector.Accessibility, selector);

#endregion IFindByAccessibilityId Members
#region Public Methods

#region IFindsByImage Members
protected override Response Execute(string driverCommandToExecute, Dictionary<string, object> parameters) =>
base.Execute(driverCommandToExecute, parameters);

public W FindElementByImage(string base64Template) => FindElement(MobileSelector.Image, base64Template);
Response IExecuteMethod.Execute(string commandName, Dictionary<string, object> parameters) =>
base.Execute(commandName, parameters);

public IReadOnlyCollection<W> FindElementsByImage(string base64Template) =>
ConvertToExtendedWebElementCollection<W>(FindElements(MobileSelector.Image, base64Template));

#endregion
#region Generic FindMethods

#endregion
public new AppiumWebElement FindElement(By by) =>
(AppiumWebElement)base.FindElement(by);

#region Public Methods
public new ReadOnlyCollection<AppiumWebElement> FindElements(By by) =>
ConvertToExtendedWebElementCollection<AppiumWebElement>(base.FindElements(by));

protected override Response Execute(string driverCommandToExecute, Dictionary<string, object> parameters) =>
base.Execute(driverCommandToExecute, parameters);
public new AppiumWebElement FindElement(string by, string value) => (AppiumWebElement)base.FindElement(by, value);

Response IExecuteMethod.Execute(string commandName, Dictionary<string, object> parameters) =>
base.Execute(commandName, parameters);
public new IReadOnlyCollection<AppiumWebElement> FindElements(string selector, string value) =>
ConvertToExtendedWebElementCollection<AppiumWebElement>(base.FindElements(selector, value));
#endregion Generic FindMethods

Response IExecuteMethod.Execute(string driverCommand) => Execute(driverCommand, null);

Expand Down Expand Up @@ -658,7 +586,7 @@ public SimilarityMatchingResult GetImagesSimilarity(string base64Image1, string

#region Support methods

protected new abstract WebElementFactory CreateElementFactory();
protected WebElementFactory CreateElementFactory() => new AppiumElementFactory(this);

internal static ICapabilities SetPlatformToCapabilities(DriverOptions dc, string desiredPlatform)
{
Expand Down
15 changes: 15 additions & 0 deletions src/Appium.Net/Appium/AppiumElementFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

namespace OpenQA.Selenium.Appium
{
public class AppiumElementFactory : CachedElementFactory<AppiumWebElement>
{
public AppiumElementFactory(WebDriver parentDriver) : base(parentDriver)
{
}

protected override AppiumWebElement CreateCachedElement(WebDriver parentDriver, string elementId)
{
return new AppiumWebElement(parentDriver, elementId);
}
}
}
Loading