Ejemplo n.º 1
0
        public void AppiumLazyTest()
        {
            Assert.IsNotNull(this.TestObject.AppiumDriver);
            this.AppiumDriver.Navigate().GoToUrl(Config.GetValueForSection(ConfigSection.AppiumMaqs, "WebSiteBase"));
            LazyMobileElement lazy = new LazyMobileElement(this.TestObject, By.XPath("//button[@class=\"navbar-toggle\"]"), "Nav toggle");

            Assert.IsTrue(lazy.Enabled, "Expect enabled");
            Assert.IsTrue(lazy.Displayed, "Expect displayed");
            Assert.IsTrue(lazy.ExistsNow, "Expect exists now");
            lazy.Click();

            LazyMobileElement missing = new LazyMobileElement(this.TestObject, By.XPath("//button[@class=\"Missing\"]"), "Missing");

            this.AppiumDriver.SetWaitDriver(new WebDriverWait(this.AppiumDriver, TimeSpan.FromSeconds(10)));

            Assert.IsFalse(missing.Exists, "Expect element not to exist");
        }
Ejemplo n.º 2
0
        public void AppiumLazyParentTest()
        {
            this.AppiumDriver.Navigate().GoToUrl(Config.GetValueForSection(ConfigSection.AppiumMaqs, "WebSiteBase"));
            LazyMobileElement parent       = new LazyMobileElement(this.TestObject, By.XPath("//*[@class=\"jumbotron\"]"), "Parent");
            LazyMobileElement child        = new LazyMobileElement(this.TestObject, By.XPath("//H2"), "Child");
            LazyMobileElement missingChild = new LazyMobileElement(this.TestObject, By.XPath("//Missing"), "Missing");

            this.SoftAssert.AreEqual(child.Text, parent.FindElement(child.By, "Child").Text);
            this.SoftAssert.Assert(() => Assert.AreEqual(1, parent.FindElements(child.By, "Child").Count), "Name1");
            this.SoftAssert.Assert(() => Assert.IsTrue(child.Exists, "Expect exists now"), "Name2");

            // Override the timeout
            this.AppiumDriver.SetWaitDriver(new WebDriverWait(this.AppiumDriver, TimeSpan.FromSeconds(10)));

            this.SoftAssert.IsFalse(missingChild.Exists, "Expect element not to exist");
            this.SoftAssert.FailTestIfAssertFailed();
        }