Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix ios ElementTests #796

Merged
merged 5 commits into from
Jun 22, 2024
Merged
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
33 changes: 23 additions & 10 deletions test/integration/IOS/ElementTest.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using Appium.Net.Integration.Tests.helpers;
using System;
using Appium.Net.Integration.Tests.helpers;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.iOS;
using OpenQA.Selenium.Support.UI;

namespace Appium.Net.Integration.Tests.IOS
{
class ElementTest
class ElementTests
{
private AppiumDriver _driver;
private WebDriverWait _driverWait;

[OneTimeSetUp]
public void BeforeAll()
Expand All @@ -17,6 +20,7 @@ public void BeforeAll()
var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri;
_driver = new IOSDriver(serverUri, capabilities, Env.InitTimeoutSec);
_driver.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec;
_driverWait = new WebDriverWait(_driver, TimeSpan.FromSeconds(5));
}

[OneTimeTearDown]
Expand All @@ -35,20 +39,29 @@ public void FindByAccessibilityIdTest()
By byAccessibilityId = new ByAccessibilityId("ComputeSumButton");
Assert.Multiple(() =>
{
Assert.That(Is.Not.EqualTo(_driver.FindElements(MobileBy.ClassName("UIAWindow"))[1].FindElement(byAccessibilityId).Text), null);
Assert.That(_driver.FindElements(MobileBy.ClassName("UIAWindow"))[1].FindElements(byAccessibilityId), Is.Not.Empty);
Assert.That(_driver.FindElement(MobileBy.ClassName("UIAWindow")).FindElement(byAccessibilityId).Text, Is.EqualTo("Compute Sum"));
Assert.That(_driver.FindElement(MobileBy.ClassName("UIAWindow")).FindElements(byAccessibilityId), Is.Not.Empty);
});
}

[Test]
public void FindByByIosUiAutomationTest()
public void FindElementsByClassNameTest()
{
By byIosUiAutomation = new ByIosUIAutomation(".elements().withName(\"Answer\")");
Assert.Multiple(() =>
By byClassName = new ByClassName("XCUIElementTypeTextField");
Assert.That(_driverWait.Until(_driver => _driver.FindElements(byClassName).Count == 2), Is.True);
}

[Test]
public void FindElementMobileByClassNameTest()
{
try
{
Assert.That(_driver.FindElements(MobileBy.ClassName("UIAWindow"))[1].FindElement(byIosUiAutomation).Text, Is.Not.Null);
Assert.That(_driver.FindElements(MobileBy.ClassName("UIAWindow"))[1].FindElements(byIosUiAutomation), Is.Not.Empty);
});
var switchElement = _driver.FindElement(MobileBy.ClassName("XCUIElementTypeSwitch"));
}
catch (NoSuchElementException ex)
{
Assert.Fail("Element not found, exception: " + ex.Message);
}
}

}
Expand Down