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
17 changes: 1 addition & 16 deletions appium-dotnet-driver/Appium/Android/AndroidDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace OpenQA.Selenium.Appium.Android
{
public class AndroidDriver<W> : AppiumDriver<W>, IFindByAndroidUIAutomator<W>, IStartsActivity,
IHasNetworkConnection,
Appium.Interfaces.ISendsKeyEvents,
ISendsKeyEvents,
IPushesFiles, IHasSettings where W : IWebElement
{
private static readonly string Platform = MobilePlatform.Android;
Expand Down Expand Up @@ -185,27 +185,12 @@ public void LongPressKeyCode(int keyCode, int metastate = -1) =>
public string EndTestCoverage(string intent, string path) =>
AndroidCommandExecutionHelper.EndTestCoverage(this, intent, path);

/// <summary>
/// Saves a string as a file on the remote mobile device.
/// </summary>
/// <param name="pathOnDevice">Path to file to write data to on remote device</param>
/// <param name="stringData">A string to write to remote device</param>
public void PushFile(string pathOnDevice, string stringData) => AndroidCommandExecutionHelper.PushFile(this,
pathOnDevice, Convert.FromBase64String(Convert.ToBase64String(Encoding.UTF8.GetBytes(stringData))));

/// <summary>
/// Saves base64 encoded data as a file on the remote mobile device.
/// </summary>
/// <param name="pathOnDevice">Path to file to write data to on remote device</param>
/// <param name="base64Data">Base64 encoded byte array of data to write to remote device</param>
public void PushFile(string pathOnDevice, byte[] base64Data) =>
AndroidCommandExecutionHelper.PushFile(this, pathOnDevice, base64Data);

/// <summary>
/// Saves given file as a file on the remote mobile device.
/// </summary>
/// <param name="pathOnDevice">Path to file to write data to on remote device</param>
/// <param name="base64Data">A file to write to remote device</param>
public void PushFile(string pathOnDevice, FileInfo file) =>
AndroidCommandExecutionHelper.PushFile(this, pathOnDevice, file);

Expand Down
192 changes: 0 additions & 192 deletions appium-dotnet-driver/Appium/AppiumDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
using Newtonsoft.Json;
using OpenQA.Selenium.Appium.Enums;
using OpenQA.Selenium.Appium.Interfaces;
using OpenQA.Selenium.Appium.MultiTouch;
using OpenQA.Selenium.Appium.Service;
using OpenQA.Selenium.Remote;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Linq;

namespace OpenQA.Selenium.Appium
Expand Down Expand Up @@ -304,9 +302,6 @@ public ReadOnlyCollection<string> Contexts

#region Orientation

/// <summary>
/// Sets/Gets the Orientation
/// </summary>
public ScreenOrientation Orientation
{
get
Expand Down Expand Up @@ -390,193 +385,6 @@ public void PerformTouchAction(ITouchAction touchAction)

#endregion Multi Actions

#region tap, swipe, pinch, zoom

/// <summary>
/// Convenience method for tapping the center of an element on the screen
/// </summary>
/// <param name="fingers">number of fingers/appendages to tap with</param>
/// <param name="element">element to tap</param>
/// <param name="duration">how long between pressing down, and lifting fingers/appendages</param>
[Obsolete("This method is going to be removed")]
public void Tap(int fingers, IWebElement element, int duration)
{
MultiAction multiTouch = new MultiAction(this);

for (int i = 0; i < fingers; i++)
{
multiTouch.Add(new TouchAction(this).Press(element).Wait(duration).Release());
}

multiTouch.Perform();
}

/// <summary>
/// Convenience method for tapping a position on the screen
/// </summary>
/// <param name="fingers">number of fingers/appendages to tap with</param>
/// <param name="x">x coordinate</param>
/// <param name="y">y coordinate</param>
/// <param name="duration">how long between pressing down, and lifting fingers/appendages</param>
[Obsolete("This method is going to be removed")]
public void Tap(int fingers, int x, int y, int duration)
{
MultiAction multiTouch = new MultiAction(this);

for (int i = 0; i < fingers; i++)
{
multiTouch.Add(new TouchAction(this).Press(x, y).Wait(duration).Release());
}

multiTouch.Perform();
}

/// <summary>
/// Convenience method for swiping across the screen
/// </summary>
/// <param name="startx">starting x coordinate</param>
/// <param name="starty">starting y coordinate</param>
/// <param name="endx">ending x coordinate</param>
/// <param name="endy">ending y coordinate</param>
/// <param name="duration">amount of time in milliseconds for the entire swipe action to take</param>
[Obsolete("This method is going to be removed")]
public void Swipe(int startx, int starty, int endx, int endy, int duration)
{
TouchAction touchAction = new TouchAction(this);

// appium converts Press-wait-MoveTo-Release to a swipe action
touchAction.Press(startx, starty).Wait(duration)
.MoveTo(endx, endy).Release();

touchAction.Perform();
}

/// <summary>
/// Convenience method for pinching an element on the screen.
/// "pinching" refers to the action of two appendages Pressing the screen and sliding towards each other.
/// NOTE:
/// driver convenience method places the initial touches around the element, if driver would happen to place one of them
/// off the screen, appium with return an outOfBounds error. In driver case, revert to using the MultiAction api
/// instead of driver method.
/// </summary>
/// <param name="el">The element to pinch</param>
[Obsolete("This method is going to be removed")]
public void Pinch(IWebElement el)
{
MultiAction multiTouch = new MultiAction(this);

Size dimensions = el.Size;
Point upperLeft = el.Location;
Point center = new Point(upperLeft.X + dimensions.Width / 2, upperLeft.Y + dimensions.Height / 2);
int yOffset = center.Y - upperLeft.Y;

ITouchAction action0 = new TouchAction(this).Press(el, center.X, center.Y - yOffset).MoveTo(el).Release();
ITouchAction action1 = new TouchAction(this).Press(el, center.X, center.Y + yOffset).MoveTo(el).Release();

multiTouch.Add(action0).Add(action1);

multiTouch.Perform();
}

/// <summary>
/// Convenience method for pinching an element on the screen.
/// "pinching" refers to the action of two appendages Pressing the screen and sliding towards each other.
/// NOTE:
/// driver convenience method places the initial touches around the element at a distance, if driver would happen to place
/// one of them off the screen, appium will return an outOfBounds error. In driver case, revert to using the
/// MultiAction api instead of driver method.
/// </summary>
/// <param name="x">x coordinate to terminate the pinch on</param>
/// <param name="y">y coordinate to terminate the pinch on></param>
[Obsolete("This method is going to be removed")]
public void Pinch(int x, int y)
{
MultiAction multiTouch = new MultiAction(this);

int scrHeight = Manage().Window.Size.Height;
int yOffset = 100;

if (y - 100 < 0)
{
yOffset = y;
}
else if (y + 100 > scrHeight)
{
yOffset = scrHeight - y;
}

ITouchAction action0 = new TouchAction(this).Press(x, y - yOffset).MoveTo(0, yOffset).Release();
ITouchAction action1 = new TouchAction(this).Press(x, y + yOffset).MoveTo(0, -yOffset).Release();

multiTouch.Add(action0).Add(action1);

multiTouch.Perform();
}

/// <summary>
/// Convenience method for "zooming in" on an element on the screen.
/// "zooming in" refers to the action of two appendages Pressing the screen and sliding away from each other.
/// NOTE:
/// driver convenience method slides touches away from the element, if driver would happen to place one of them
/// off the screen, appium will return an outOfBounds error. In driver case, revert to using the MultiAction api
/// instead of driver method.
/// <param name="x">x coordinate to terminate the zoom on</param>
/// <param name="y">y coordinate to terminate the zoom on></param>
/// </summary>
[Obsolete("This method is going to be removed")]
public void Zoom(int x, int y)
{
MultiAction multiTouch = new MultiAction(this);

int scrHeight = Manage().Window.Size.Height;
int yOffset = 100;

if (y - 100 < 0)
{
yOffset = y;
}
else if (y + 100 > scrHeight)
{
yOffset = scrHeight - y;
}

ITouchAction action0 = new TouchAction(this).Press(x, y).MoveTo(0, -yOffset).Release();
ITouchAction action1 = new TouchAction(this).Press(x, y).MoveTo(0, yOffset).Release();

multiTouch.Add(action0).Add(action1);

multiTouch.Perform();
}

/// <summary>
/// Convenience method for "zooming in" on an element on the screen.
/// "zooming in" refers to the action of two appendages Pressing the screen and sliding away from each other.
/// NOTE:
/// driver convenience method slides touches away from the element, if driver would happen to place one of them
/// off the screen, appium will return an outOfBounds error. In driver case, revert to using the MultiAction api
/// instead of driver method.
/// <param name="el">The element to pinch</param>
/// </summary>
[Obsolete("This method is going to be removed")]
public void Zoom(IWebElement el)
{
MultiAction multiTouch = new MultiAction(this);

Size dimensions = el.Size;
Point upperLeft = el.Location;
Point center = new Point(upperLeft.X + dimensions.Width / 2, upperLeft.Y + dimensions.Height / 2);
int yOffset = center.Y - upperLeft.Y;

ITouchAction action0 = new TouchAction(this).Press(el).MoveTo(el, 0, -yOffset).Release();
ITouchAction action1 = new TouchAction(this).Press(el).MoveTo(el, 0, yOffset).Release();

multiTouch.Add(action0).Add(action1);

multiTouch.Perform();
}

#endregion

#region Device Time

/// <summary>
Expand Down
57 changes: 0 additions & 57 deletions appium-dotnet-driver/Appium/iOS/IOSDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
using OpenQA.Selenium.Appium.Enums;
using OpenQA.Selenium.Appium.Interfaces;
using OpenQA.Selenium.Appium.iOS.Interfaces;
using OpenQA.Selenium.Appium.MultiTouch;
using OpenQA.Selenium.Appium.Service;
using OpenQA.Selenium.Remote;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace OpenQA.Selenium.Appium.iOS
Expand Down Expand Up @@ -124,57 +122,27 @@ public IOSDriver(AppiumLocalService service, DesiredCapabilities desiredCapabili

#region IFindByIosUIAutomation Members

/// <summary>
/// Finds the first element that matches the iOS UIAutomation selector
/// </summary>
/// <param name="selector">UIAutomation selector</param>
/// <returns>First element found</returns>
public W FindElementByIosUIAutomation(string selector) => FindElement(MobileSelector.iOSAutomatoion, selector);

/// <summary>
/// Finds a list of elements that match the iOS UIAutomation selector
/// </summary>
/// <param name="selector">UIAutomation selector</param>
/// <returns>ReadOnlyCollection of elements found</returns>
public ReadOnlyCollection<W> FindElementsByIosUIAutomation(string selector) =>
FindElements(MobileSelector.iOSAutomatoion, selector);

#endregion IFindByIosUIAutomation Members

#region IFindsByIosClassChain Members

/// <summary>
/// Finds the first element that matches the iOS class chain selector
/// </summary>
/// <param name="selector">class chain selector</param>
/// <returns>First element found</returns>
public W FindElementByIosClassChain(string selector) => FindElement(MobileSelector.iOSClassChain, selector);

/// <summary>
/// Finds a list of elements that match the iOS class chain selector
/// </summary>
/// <param name="selector">class chain selector</param>
/// <returns>ReadOnlyCollection of elements found</returns>
public ReadOnlyCollection<W> FindElementsByIosClassChain(string selector) =>
FindElements(MobileSelector.iOSClassChain, selector);

#endregion IFindsByIosClassChain Members

#region IFindsByIosNSPredicate Members

/// <summary>
/// Finds the first element that matches the IosNSPredicate selector
/// </summary>
/// <param name="selector">IosNSPredicate selector</param>
/// <returns>First element found</returns>
public W FindElementByIosNsPredicate(string selector) =>
FindElement(MobileSelector.iOSPredicateString, selector);

/// <summary>
/// Finds a list of elements that match the IosNSPredicate selector
/// </summary>
/// <param name="selector">IosNSPredicate selector</param>
/// <returns>ReadOnlyCollection of elements found</returns>
public ReadOnlyCollection<W> FindElementsByIosNsPredicate(string selector) =>
FindElements(MobileSelector.iOSPredicateString, selector);

Expand All @@ -185,11 +153,6 @@ public ReadOnlyCollection<W> FindElementsByIosNsPredicate(string selector) =>
public void HideKeyboard(string key, string strategy = null) =>
AppiumCommandExecutionHelper.HideKeyboard(this, strategy, key);

/// <summary>
/// Create an iOS Element
/// </summary>
/// <param name="elementId">element to create</param>
/// <returns>IOSElement</returns>
protected override RemoteWebElement CreateElement(string elementId) => new IOSElement(this, elementId);

/// <summary>
Expand All @@ -198,26 +161,6 @@ public void HideKeyboard(string key, string strategy = null) =>
/// <param name="seconds">The number of seconds during which the device need to be locked for.</param>
public void Lock(int seconds) => AppiumCommandExecutionHelper.Lock(this, seconds);

/// <summary>
/// Convenience method for swiping across the screen
/// </summary>
/// <param name="startx">starting x coordinate</param>
/// <param name="starty">starting y coordinate</param>
/// <param name="endx">ending x coordinate</param>
/// <param name="endy">ending y coordinate</param>
/// <param name="duration">amount of time in milliseconds for the entire swipe action to take</param>
[Obsolete("This method is going to be removed")]
public void Swipe(int startx, int starty, int endx, int endy, int duration)
{
TouchAction touchAction = new TouchAction(this);

// appium converts Press-wait-MoveTo-Release to a swipe action
touchAction.Press(startx, starty).Wait(duration)
.MoveTo(endx - startx, endy - starty).Release();

touchAction.Perform();
}

public void PerformTouchID(bool match) => IOSCommandExecutionHelper.PerformTouchID(this, match);
}
}
Loading