Example #1
0
        public void ScientificFormula(string n, string x, string y, double expectedResult)
        {
            var calcPage = new ScientificCalculatorPage(_driver);

            calcPage.ExecuteFormulaCalculation(n, x, y);

            calcPage.AssertResultStartsWith(expectedResult);
        }
        public void TestInit()
        {
            var options = new AppiumOptions();

            options.AddAdditionalCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
            options.AddAdditionalCapability("deviceName", "WindowsPC");
            _driver = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), options);
            _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);

            _ScientificCalculatorPage = new ScientificCalculatorPage(_driver);
            _calculatorResults        = new CalculatorResults(_driver);

            // Identify calculator mode by locating the header
            try
            {
                header = _driver.FindElementByAccessibilityId("Header");
            }
            catch
            {
                header = _driver.FindElementByAccessibilityId("ContentPresenter");
            }

            // Ensure that calculator is in scientific mode
            if (!header.Text.Equals("Scientific", StringComparison.OrdinalIgnoreCase))
            {
                _driver.FindElementByName("Open Navigation").Click();
                Thread.Sleep(TimeSpan.FromSeconds(10));
                var menu = _driver.FindElementByClassName("SplitViewPane");
                menu.FindElementByName("Scientific Calculator").Click();
                _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
                Assert.IsTrue(header.Text.Equals("Scientific", StringComparison.OrdinalIgnoreCase));
            }

            // Locate the calculatorResult element
            calculatorResult = _driver.FindElementByAccessibilityId("CalculatorResults");
            Assert.IsNotNull(calculatorResult);
        }