|
| 1 | +//Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | +//you may not use this file except in compliance with the License. |
| 3 | +//See the NOTICE file distributed with this work for additional |
| 4 | +//information regarding copyright ownership. |
| 5 | +//You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +//Unless required by applicable law or agreed to in writing, software |
| 10 | +//distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +//See the License for the specific language governing permissions and |
| 13 | +//limitations under the License. |
| 14 | + |
| 15 | +using System.Collections.Generic; |
| 16 | +using NUnit.Framework; |
| 17 | +using OpenQA.Selenium.Appium.Android; |
| 18 | +using OpenQA.Selenium.Appium; |
| 19 | +using Appium.Net.Integration.Tests.helpers; |
| 20 | + |
| 21 | +namespace Appium.Net.Integration.Tests.Android |
| 22 | +{ |
| 23 | + [TestFixture] |
| 24 | + public class FiltersTests |
| 25 | + { |
| 26 | + private AndroidDriver _driver; |
| 27 | + |
| 28 | + [OneTimeSetUp] |
| 29 | + public void BeforeAll() |
| 30 | + { |
| 31 | + var capabilities = Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos")); |
| 32 | + var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; |
| 33 | + _driver = new AndroidDriver(serverUri, capabilities, Env.InitTimeoutSec); |
| 34 | + _driver.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec; |
| 35 | + } |
| 36 | + |
| 37 | + [Test] |
| 38 | + public void FirstWithName_ReturnsCorrectElement() |
| 39 | + { |
| 40 | + var viewsElement = _driver.FindElement(MobileBy.AccessibilityId("Views")); |
| 41 | + |
| 42 | + var textElement = _driver.FindElement(MobileBy.AccessibilityId("Text")); |
| 43 | + |
| 44 | + var elements = new List<AppiumElement> { viewsElement, textElement }; |
| 45 | + |
| 46 | + var result = Filters.FirstWithName(elements, "Text"); |
| 47 | + |
| 48 | + Assert.That(result, Is.EqualTo(textElement)); |
| 49 | + } |
| 50 | + |
| 51 | + [OneTimeTearDown] |
| 52 | + public void AfterAll() |
| 53 | + { |
| 54 | + _driver?.Quit(); |
| 55 | + if (!Env.ServerIsRemote()) |
| 56 | + { |
| 57 | + AppiumServers.StopLocalService(); |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | +} |
0 commit comments