Skip to content
Dor Blayzer edited this page Nov 16, 2023 · 1 revision
...
using NUnit.Framework;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Remote;
using System.Collections.Generic;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.iOS;
...

namespace IosSampmle
{
	[TestFixture ()]
	public class IosSimpleTest
	{
		private IOSDriver<IOSElement> driver;
		private bool allPassed = true;

		private Random rnd = new Random();

		[TestFixtureSetUp]
		public void BeforeAll(){
		     DesiredCapabilities capabilities = new DesiredCapabilities();
		     capabilities.SetCapability(MobileCapabilityType.
                                PlatformVersion, "8.0");
		     capabilities.SetCapability(MobileCapabilityType.
                                DeviceName, "iPhone Simulator");
		     capabilities.SetCapability(MobileCapabilityType.App, 
                                <path to your app>);

                     driver = new IOSDriver<IOSElement>(
                               new Uri("http://127.0.0.1:4723/wd/hub"), 
                                 capabilities);
		}


		[Test ()]
		public void ComputeSumTestCase ()
		{
			// compute and check the sum
			driver.FindElementByAccessibilityId ("ComputeSumButton").
                          Click ();
			Thread.Sleep (1000);

			IOSElement sumEl = driver.
                             FindElementByIosUIAutomation (
                                ".elements().withName(\"Answer\")");
			int sumOut = Convert.ToInt32 (sumEl.Text);
			Assert.AreEqual (sumIn, sumOut);
		}

	}
}