diff --git a/src/Appium.Net/Appium.Net.xml b/src/Appium.Net/Appium.Net.xml index c56b47ad7..4bde4c9b1 100644 --- a/src/Appium.Net/Appium.Net.xml +++ b/src/Appium.Net/Appium.Net.xml @@ -3330,9 +3330,9 @@ A desired capability - + - AppiumWebElement allows you to have access to specific items that are found on the page. + AppiumElement allows you to have access to specific items that are found on the page. @@ -3342,122 +3342,122 @@ public void TestGoogle() { driver = new AppiumDriver(); - AppiumWebElement elem = driver.FindElement(By.Name("q")); + AppiumElement elem = driver.FindElement(By.Name("q")); elem.SendKeys("Cheese please!"); } - + - Initializes a new instance of the AppiumWebElement class. + Initializes a new instance of the AppiumElement class. Driver in use. ID of the element. - - + + Finds the first element in the page that matches the OpenQA.Selenium.By object Mechanism to find element first element found - - - - + + + + Finds the first element in the page that matches the ID supplied ID of the element First element found - + Finds a list of elements that match the ID supplied ID of the element ReadOnlyCollection of elements found - + Finds the first element matching the specified CSS selector The CSS selector to match First element found - + Finds a list of elements that match the CSS selector The CSS selector to match ReadOnlyCollection of elements found - + Finds the first of elements that match the link text supplied Link text of element First element found - + Finds a list of elements that match the link text supplied Link text of element ReadOnlyCollection of elements found - + Finds the first of elements that match the name supplied Name of the element on the page First element found - + Finds a list of elements that match the name supplied Name of the element on the page ReadOnlyCollection of elements found - + Finds the first of elements that match the part of the link text supplied Part of the link text First element found - + Finds a list of elements that match the part of the link text supplied Part of the link text ReadOnlyCollection of elements found - + Finds the first of elements that match the DOM Tag supplied DOM tag name of the element being searched First element found - + Finds a list of elements that match the DOM Tag supplied DOM tag name of the element being searched ReadOnlyCollection of elements found - + Finds the first of elements that match the XPath supplied xpath to the element First element found - + Finds a list of elements that match the XPath supplied diff --git a/src/Appium.Net/Appium/AppiumDriver.cs b/src/Appium.Net/Appium/AppiumDriver.cs index 4a506698d..41ec067dd 100644 --- a/src/Appium.Net/Appium/AppiumDriver.cs +++ b/src/Appium.Net/Appium/AppiumDriver.cs @@ -30,7 +30,7 @@ namespace OpenQA.Selenium.Appium public abstract class AppiumDriver : WebDriver, IHasSessionDetails, IHasLocation, - IHidesKeyboard, IInteractsWithFiles, IFindsByFluentSelector, + IHidesKeyboard, IInteractsWithFiles, IFindsByFluentSelector, IInteractsWithApps, IPerformsTouchActions, IRotatable, IContextAware { private const string NativeApp = "NATIVE_APP"; @@ -97,16 +97,16 @@ Response IExecuteMethod.Execute(string commandName, Dictionary p #region Generic FindMethods - public new AppiumWebElement FindElement(By by) => - (AppiumWebElement)base.FindElement(by); + public new AppiumElement FindElement(By by) => + (AppiumElement)base.FindElement(by); - public new ReadOnlyCollection FindElements(By by) => - ConvertToExtendedWebElementCollection(base.FindElements(by)); + public new ReadOnlyCollection FindElements(By by) => + ConvertToExtendedWebElementCollection(base.FindElements(by)); - public new AppiumWebElement FindElement(string by, string value) => (AppiumWebElement)base.FindElement(by, value); + public new AppiumElement FindElement(string by, string value) => (AppiumElement)base.FindElement(by, value); - public new IReadOnlyCollection FindElements(string selector, string value) => - ConvertToExtendedWebElementCollection(base.FindElements(selector, value)); + public new IReadOnlyCollection FindElements(string selector, string value) => + ConvertToExtendedWebElementCollection(base.FindElements(selector, value)); #endregion Generic FindMethods Response IExecuteMethod.Execute(string driverCommand) => Execute(driverCommand, null); diff --git a/src/Appium.Net/Appium/AppiumWebElement.cs b/src/Appium.Net/Appium/AppiumElement.cs similarity index 88% rename from src/Appium.Net/Appium/AppiumWebElement.cs rename to src/Appium.Net/Appium/AppiumElement.cs index b6516336d..7ac9a2ab0 100644 --- a/src/Appium.Net/Appium/AppiumWebElement.cs +++ b/src/Appium.Net/Appium/AppiumElement.cs @@ -23,7 +23,7 @@ namespace OpenQA.Selenium.Appium { /// - /// AppiumWebElement allows you to have access to specific items that are found on the page. + /// AppiumElement allows you to have access to specific items that are found on the page. /// /// /// @@ -33,19 +33,19 @@ namespace OpenQA.Selenium.Appium /// public void TestGoogle() /// { /// driver = new AppiumDriver(); - /// AppiumWebElement elem = driver.FindElement(By.Name("q")); + /// AppiumElement elem = driver.FindElement(By.Name("q")); /// elem.SendKeys("Cheese please!"); /// } /// /// - public class AppiumWebElement : WebElement, IFindsByFluentSelector, IWebElementCached + public class AppiumElement : WebElement, IFindsByFluentSelector, IWebElementCached { /// - /// Initializes a new instance of the AppiumWebElement class. + /// Initializes a new instance of the AppiumElement class. /// /// Driver in use. /// ID of the element. - public AppiumWebElement(WebDriver parent, string id) + public AppiumElement(WebDriver parent, string id) : base(parent, id) { } @@ -207,19 +207,19 @@ public void SetImmediateValue(string value) => Execute(AppiumDriverCommand.SetVa public Response Execute(string driverCommand) => Execute(driverCommand, null); - AppiumWebElement IFindsByFluentSelector.FindElement(string by, string value) + AppiumElement IFindsByFluentSelector.FindElement(string by, string value) { - return (AppiumWebElement)base.FindElement(by, value); + return (AppiumElement)base.FindElement(by, value); } - IReadOnlyCollection IFindsByFluentSelector.FindElements(string selector, string value) + IReadOnlyCollection IFindsByFluentSelector.FindElements(string selector, string value) { return ConvertToExtendedWebElementCollection(base.FindElements(selector, value)); } - internal static ReadOnlyCollection ConvertToExtendedWebElementCollection(IEnumerable collection) + internal static ReadOnlyCollection ConvertToExtendedWebElementCollection(IEnumerable collection) { - return collection.Cast().ToList().AsReadOnly(); + return collection.Cast().ToList().AsReadOnly(); } public new string Id => base.Id; diff --git a/src/Appium.Net/Appium/AppiumElementFactory.cs b/src/Appium.Net/Appium/AppiumElementFactory.cs index b835cf380..498bb37de 100644 --- a/src/Appium.Net/Appium/AppiumElementFactory.cs +++ b/src/Appium.Net/Appium/AppiumElementFactory.cs @@ -1,15 +1,15 @@  namespace OpenQA.Selenium.Appium { - public class AppiumElementFactory : CachedElementFactory + public class AppiumElementFactory : CachedElementFactory { public AppiumElementFactory(WebDriver parentDriver) : base(parentDriver) { } - protected override AppiumWebElement CreateCachedElement(WebDriver parentDriver, string elementId) + protected override AppiumElement CreateCachedElement(WebDriver parentDriver, string elementId) { - return new AppiumWebElement(parentDriver, elementId); + return new AppiumElement(parentDriver, elementId); } } } \ No newline at end of file diff --git a/src/Appium.Net/Appium/AppiumOptions.cs b/src/Appium.Net/Appium/AppiumOptions.cs index bc9def95b..240f28f6f 100644 --- a/src/Appium.Net/Appium/AppiumOptions.cs +++ b/src/Appium.Net/Appium/AppiumOptions.cs @@ -51,6 +51,15 @@ public AppiumOptions() : base() /// public string PlatformVersion { get; set; } + /// + /// Gets or sets the Browser name of the Appium browser's (e.g. Chrome, Safari and so on) setting. + /// + public new string BrowserName + { + get { return base.BrowserName; } + set { base.BrowserName = value; } + } + /// /// Provides a means to add additional capabilities not yet added as type safe options /// for the Appium driver. diff --git a/test/integration/Android/ConnectionTest.cs b/test/integration/Android/ConnectionTest.cs index 08adcc39d..229a59352 100644 --- a/test/integration/Android/ConnectionTest.cs +++ b/test/integration/Android/ConnectionTest.cs @@ -14,9 +14,7 @@ class ConnectionTest [OneTimeSetUp] public void BeforeAll() { - var capabilities = Env.ServerIsRemote() - ? Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos")) - : Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos")); + var capabilities = Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos")); var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; _driver = new AndroidDriver(serverUri, capabilities, Env.InitTimeoutSec); _driver.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec; diff --git a/test/integration/Android/Device/BrowserTests.cs b/test/integration/Android/Device/BrowserTests.cs new file mode 100644 index 000000000..f421762c5 --- /dev/null +++ b/test/integration/Android/Device/BrowserTests.cs @@ -0,0 +1,39 @@ +using Appium.Net.Integration.Tests.helpers; +using NUnit.Framework; +using OpenQA.Selenium.Appium; +using OpenQA.Selenium.Appium.Android; +using System; + +namespace Appium.Net.Integration.Tests.Android.Device.App +{ + internal class BrowserTests + { + private AppiumDriver _driver; + private AppiumOptions _androidOptions; + + [OneTimeSetUp] + public void SetUp() + { + _androidOptions = new AppiumOptions(); + _androidOptions.BrowserName = "Chrome"; + + _driver = new AndroidDriver( + Env.ServerIsLocal() ? AppiumServers.LocalServiceUri : AppiumServers.RemoteServerUri, + _androidOptions); + _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); + } + + [OneTimeTearDown] + public void TearDown() + { + _driver.Dispose(); + } + + [Test] + public void Browser() + { + _driver.Navigate().GoToUrl("https://github.com/appium"); + Assert.IsNotEmpty(_driver.PageSource); + } + } +} \ No newline at end of file diff --git a/test/integration/Android/TouchActionTest.cs b/test/integration/Android/TouchActionTest.cs index e0740f89b..038b6e4d7 100644 --- a/test/integration/Android/TouchActionTest.cs +++ b/test/integration/Android/TouchActionTest.cs @@ -50,7 +50,7 @@ public void AfterAll() [Test] public void SimpleTouchActionTestCase() { - IList els = _driver.FindElements(MobileBy.ClassName("android.widget.TextView")); + IList els = _driver.FindElements(MobileBy.ClassName("android.widget.TextView")); var number1 = els.Count; @@ -65,7 +65,7 @@ public void SimpleTouchActionTestCase() [Test] public void ComplexTouchActionTestCase() { - IList els = _driver.FindElements(MobileBy.ClassName("android.widget.TextView")); + IList els = _driver.FindElements(MobileBy.ClassName("android.widget.TextView")); var loc1 = els[7].Location; var target = els[1]; var loc2 = target.Location; @@ -78,7 +78,7 @@ public void ComplexTouchActionTestCase() [Test] public void SingleMultiActionTestCase() { - IList els = _driver.FindElements(MobileBy.ClassName("android.widget.TextView")); + IList els = _driver.FindElements(MobileBy.ClassName("android.widget.TextView")); var loc1 = els[7].Location; var target = els[1]; var loc2 = target.Location; @@ -97,7 +97,7 @@ public void SingleMultiActionTestCase() public void SequentalMultiActionTestCase() { var originalActivity = _driver.CurrentActivity; - IList els = _driver.FindElements(MobileBy.ClassName("android.widget.TextView")); + IList els = _driver.FindElements(MobileBy.ClassName("android.widget.TextView")); var multiTouch = new MultiAction(_driver); var tap1 = new TouchAction(_driver); diff --git a/test/integration/Windows/MultiSelectControlTest.cs b/test/integration/Windows/MultiSelectControlTest.cs index 72bde59ca..acfd36f67 100644 --- a/test/integration/Windows/MultiSelectControlTest.cs +++ b/test/integration/Windows/MultiSelectControlTest.cs @@ -107,7 +107,7 @@ public void SwitchToWorldClockTab() public string ReadLocalTime() { var localTimeText = ""; - AppiumWebElement worldClockPivotItem = + AppiumElement worldClockPivotItem = AlarmClockSession.FindElement(MobileBy.AccessibilityId("ClockButton")); if (worldClockPivotItem != null) { @@ -144,7 +144,7 @@ public void AddAlarm(string timeText) AlarmClockSession.FindElement(MobileBy.AccessibilityId("AlarmNameTextBox")).Clear(); AlarmClockSession.FindElement(MobileBy.AccessibilityId("AlarmNameTextBox")) .SendKeys("Windows Application Driver Test Alarm"); - AppiumWebElement periodSelector = null; + AppiumElement periodSelector = null; try { periodSelector = AlarmClockSession.FindElement(MobileBy.AccessibilityId("PeriodLoopingSelector")); @@ -166,7 +166,7 @@ public void DismissNotification() { try { - AppiumWebElement newNotification = DesktopSession.FindElement(MobileBy.Name("New notification")); + AppiumElement newNotification = DesktopSession.FindElement(MobileBy.Name("New notification")); Assert.IsTrue(newNotification.FindElement(MobileBy.AccessibilityId("MessageText")).Text .Contains("Windows Application Driver Test Alarm")); newNotification.FindElement(MobileBy.Name("Dismiss")).Click(); @@ -181,7 +181,7 @@ private static void ReturnToMainPage() // Try to return to main page in case application is started in nested view try { - AppiumWebElement backButton = null; + AppiumElement backButton = null; do { backButton = AlarmClockSession.FindElement(MobileBy.AccessibilityId("Back")); diff --git a/test/integration/Windows/PentTest.cs b/test/integration/Windows/PentTest.cs index 72daf1357..45de2f20e 100644 --- a/test/integration/Windows/PentTest.cs +++ b/test/integration/Windows/PentTest.cs @@ -37,7 +37,7 @@ namespace Appium.Net.Integration.Tests.Windows public class PenTest : StickyNotesTest { private WindowsDriver newStickyNoteSession; - private AppiumWebElement inkCanvas; + private AppiumElement inkCanvas; [Test] public void DrawBasicSquare() @@ -225,7 +225,7 @@ public void CreateNewStickyNote() Assert.AreEqual(openedStickyNotesWindowsBefore.Count + 1, openedStickyNotesWindowsAfter.Count); // Identify the newly opened Sticky Note by removing the previously opened ones from the list - List openedStickyNotes = new List(openedStickyNotesWindowsAfter); + List openedStickyNotes = new List(openedStickyNotesWindowsAfter); foreach (var preExistingStickyNote in openedStickyNotesWindowsBefore) { openedStickyNotes.Remove(preExistingStickyNote);