Exemplo n.º 1
0
 // http://developer.android.com/intl/ru/tools/testing-support-library/index.html#uia-apis (e.g. "new UiSelector().text(\"REST URL\")")
 public static Search AndroidUiAutomator(string androidUiAutomator)
 {
     return(new Search
     {
         Wrapper = MobileBy.AndroidUIAutomator(androidUiAutomator)
     });
 }
Exemplo n.º 2
0
        private static IWebElement FindElementDiffMethods(IWebDriver driver, string element)
        {
            IWebElement resElement = null;

            try
            {
                if (driver is AndroidDriver <AppiumWebElement> )
                {
                    resElement = driver.FindElement(MobileBy.AndroidUIAutomator("new UiSelector().textContains(\"" + element + "\")"));
                }
                else if (driver is IOSDriver <AppiumWebElement> )
                {
                    resElement = driver.FindElement(MobileBy.AccessibilityId(element));
                }
                else
                {
                    throw new OpenQA.Selenium.WebDriverException("WRONG DRIVER");
                }
            }
            catch (OpenQA.Selenium.NoSuchElementException)
            {
                try
                {
                    resElement = driver.FindElement(By.ClassName(element));
                }
                catch (OpenQA.Selenium.NoSuchElementException)
                {
                    resElement = driver.FindElement(By.Id(element));
                }
            }
            return(resElement);
        }
Exemplo n.º 3
0
        public void validaValorSnacks()
        {
            TimeSpan period   = TimeSpan.FromSeconds(2);
            int      tryCount = 2;

            if (tryCount <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(tryCount));
            }

            Cinemas cinemas = new Cinemas();

            cinemas.EscolherCinemaComSucesso();

            while (true)
            {
                try
                {
                    AndroidElement menu_snackbar = _driver.FindElementById(menuSnackBar);
                    menu_snackbar.Click();
                    break;
                }
                catch (StaleElementReferenceException)
                {
                    if (--tryCount == 0)
                    {
                        throw;
                    }
                    Common.WaitAndRetry(period);
                }
            }

            AndroidElement pipocas = _driver.FindElementByXPath(menuPipocas);

            pipocas.Click();

            AndroidElement add_pipocas1 = _driver.FindElement(MobileBy.AndroidUIAutomator(addPipocas1));

            add_pipocas1.Click();
            AndroidElement add_pipocas2 = _driver.FindElement(MobileBy.AndroidUIAutomator(addPipocas2));

            add_pipocas2.Click();

            AndroidElement preco_pipocas1    = _driver.FindElement(MobileBy.AndroidUIAutomator(precoPipocas1));
            decimal        preco1            = Decimal.Parse(preco_pipocas1.Text, NumberStyles.Currency);
            AndroidElement preco_pipocas2    = _driver.FindElement(MobileBy.AndroidUIAutomator(precoPipocas2));
            decimal        preco2            = Decimal.Parse(preco_pipocas2.Text, NumberStyles.Currency);
            AndroidElement soma_valor_snacks = _driver.FindElementById(somaValorSnacks);
            decimal        soma_final        = Decimal.Parse(soma_valor_snacks.Text, NumberStyles.Currency);

            if (!(preco1 + preco2 == soma_final))
            {
                throw new ArgumentException("App nao esta somando os valores corretamente");
            }
        }
Exemplo n.º 4
0
        public void scroll_to_element_by_id(string resource_id)
        {
            Thread.Sleep(3000);
            var temp = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().resourceId(\"" + resource_id + "\"));"));

            if (temp.Count == 0)
            {
                throw new Exception(string.Format("Element with the given Resource-Id: {0} not found on screen", resource_id));
            }
            //var elements = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("+ "new UiSelector().text(\"" + text + "\"));"));
        }
Exemplo n.º 5
0
        //For Scroll to Element using Text
        public void scroll_to_element_text_instance(string text, string instance)
        {
            Thread.Sleep(3000);
            var temp = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(" + instance + ")).scrollIntoView(new UiSelector().textContains(\"" + text + "\"));"));

            if (temp.Count == 0)
            {
                throw new Exception(string.Format("Element with the given text: {0} not found on screen", text));
            }
            //var elements = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("+ "new UiSelector().text(\"" + text + "\"));"));
        }
Exemplo n.º 6
0
        public void SelectStatus()
        {
            switch (TestBase.mobileOS)
            {
            case "IOS":
                break;

            case "Android":
                IWebElement element = Driver.FindElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(resourceId(\"com.shophumm:id/statusCheck\"));"));
                element.Click();
                break;
            }
        }
Exemplo n.º 7
0
        public void scroll_to_element_text_with_parent_sibling(string parent_text, string child)
        {
            Thread.Sleep(3000);
            //string text2 = "Mobile Prepaid and Postpaid Payments";
            var temp = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true)).scrollIntoView(new UiSelector().textContains(\"" + parent_text + "\").fromParent(new UiSelector().textContains(\"" + child + "\")));"));

            //var temp = driver.FindElements(MobileBy.AndroidUIAutomator("//android.widget.TextView[@resource-id='com.hbl.android.hblmobilebanking:id/limit_title' and @text='Mobile Prepaid and Postpaid Payments']//following-sibling::android.widget.TextView[@resource - id = 'com.hbl.android.hblmobilebanking:id/txn_limit_label']"));
            //var temp = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0).resourceId(\"" + ali + "\")).scrollIntoView(new UiSelector().textContains(\"" + text + "\").instance(5));"));

            if (temp.Count == 0)
            {
                throw new Exception(string.Format("Element with the given text: {0} and index: {1} not found on screen", parent_text, child));
            }
            //var elements = driver.FindElements(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("+ "new UiSelector().text(\"" + text + "\"));"));
        }
Exemplo n.º 8
0
        public static void ScrollDownAndroid(this IWebDriver driver)
        {
            IWebElement element = driver.FindElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(resourceId(\"com.shophumm:id/statusCheck\"));"));

            element.Click();
            // Using Touch Action Classes
            //ITouchAction touchAction = new TouchAction((IPerformsTouchActions)driver);

            //// get the proper location of where to start to swipe from
            //Size size = driver.Manage().Window.Size;
            //int startx = (int)(size.Width / 2);
            //int starty = (int)(size.Height * 0.8);
            //int endy = (int)(size.Height * 0.2);
            //// perform the swipe
            //driver.Swipe(startx, starty, startx, endy, 3000);
        }
Exemplo n.º 9
0
 public static void ScrollToUiSelector(AndroidDriver <AndroidElement> driver, String UiSelector)
 {
     driver.FindElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(" + UiSelector + ")"));
 }
Exemplo n.º 10
0
 public static void ScrollToResourceId(AndroidDriver <AndroidElement> driver, String resourceId)
 {
     driver.FindElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().resourceId(\"" + resourceId + "\").instance(0))"));
 }
Exemplo n.º 11
0
 public static void ScrollToElement(AndroidDriver <AndroidElement> driver, String textContent)
 {
     driver.FindElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(\"" + textContent + "\").instance(0))"));
 }