From 51d259e27a478a111510eaac2eefe680c531b653 Mon Sep 17 00:00:00 2001 From: Troy Walsh Date: Wed, 20 Oct 2021 08:28:07 -0500 Subject: [PATCH 1/2] Add and test missing mobile Bys --- src/Appium.Net/Appium/MobileBy.cs | 30 ++++++++++++++++++++ test/integration/Windows/ClickElementTest.cs | 10 +++++++ 2 files changed, 40 insertions(+) diff --git a/src/Appium.Net/Appium/MobileBy.cs b/src/Appium.Net/Appium/MobileBy.cs index bc0e7a2f0..d93b23ecf 100644 --- a/src/Appium.Net/Appium/MobileBy.cs +++ b/src/Appium.Net/Appium/MobileBy.cs @@ -133,6 +133,10 @@ public static By AndroidUIAutomator(IUiAutomatorStatementBuilder selector) => public static new By Name(string selector) => new ByName(selector); public static new By Id(string selector) => new ById(selector); + + public static new By ClassName(string selector) => new ByClassName(selector); + + public static new By TagName(string selector) => new ByTagName(selector); } /// @@ -472,4 +476,30 @@ public ById(string selector) : base(selector, MobileSelector.Id) public override string ToString() => $"ById({selector})"; } + + public class ByTagName : MobileBy + { + /// + /// Initializes a new instance of the class. + /// + /// Id selector. + public ByTagName(string selector) : base(selector, MobileSelector.TagName) + { + } + public override string ToString() => + $"ByTagName({selector})"; + } + + public class ByClassName : MobileBy + { + /// + /// Initializes a new instance of the class. + /// + /// Id selector. + public ByClassName(string selector) : base(selector, MobileSelector.ClassName) + { + } + public override string ToString() => + $"ByClassName({selector})"; + } } \ No newline at end of file diff --git a/test/integration/Windows/ClickElementTest.cs b/test/integration/Windows/ClickElementTest.cs index a25354af6..a87675f5d 100644 --- a/test/integration/Windows/ClickElementTest.cs +++ b/test/integration/Windows/ClickElementTest.cs @@ -70,6 +70,16 @@ public void Addition() Assert.AreEqual("Display is 8", CalculatorResult.Text); } + [Test] + public void AdditionWithCompoundBys() + { + _calculatorSession.FindElement(MobileBy.ClassName("ApplicationFrameWindow")).FindElement(MobileBy.Name("One")).Click(); + _calculatorSession.FindElement(MobileBy.AccessibilityId("plusButton")).Click(); + _calculatorSession.FindElement(MobileBy.Name("Calculator")).FindElement(MobileBy.Name("Five")).Click(); + _calculatorSession.FindElement(MobileBy.Name("Equals")).Click(); + Assert.AreEqual("Display is 6", CalculatorResult.Text); + } + [Test] public void Combination() { From f3f2f3472cc1ca6d82511b123cd90640b820d3d3 Mon Sep 17 00:00:00 2001 From: Troy Walsh Date: Wed, 20 Oct 2021 08:50:30 -0500 Subject: [PATCH 2/2] Fix docs --- src/Appium.Net/Appium/MobileBy.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Appium.Net/Appium/MobileBy.cs b/src/Appium.Net/Appium/MobileBy.cs index d93b23ecf..a6220f506 100644 --- a/src/Appium.Net/Appium/MobileBy.cs +++ b/src/Appium.Net/Appium/MobileBy.cs @@ -480,9 +480,9 @@ public override string ToString() => public class ByTagName : MobileBy { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// Id selector. + /// Tag name selector. public ByTagName(string selector) : base(selector, MobileSelector.TagName) { } @@ -493,9 +493,9 @@ public override string ToString() => public class ByClassName : MobileBy { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// Id selector. + /// Class name selector. public ByClassName(string selector) : base(selector, MobileSelector.ClassName) { }