コード例 #1
0
        private static List <AndroidElement> GetElementsByXpath(string xpath)
        {
            var driver = OpenCommand.GetDriver();
            var wait   = new WebDriverWait(driver, TimeSpan.FromSeconds(7));

            try
            {
                wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(xpath)));
                return(new List <AndroidElement>(driver.FindElements(By.XPath(xpath))));
            }
            catch
            {
                throw new ArgumentException($"Element with provided xpath was not found.");
            }
        }
コード例 #2
0
        private static List <AndroidElement> GetElementsByText(string text)
        {
            var driver = OpenCommand.GetDriver();
            var wait   = new WebDriverWait(driver, TimeSpan.FromSeconds(7));

            try
            {
                wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[contains(text(),\"" + text + "\")]")));
                return(new List <AndroidElement>(driver.FindElements(By.XPath("//*[contains(text(),\"" + text + "\")]"))));
            }
            catch
            {
                throw new ArgumentException($"Element with provided text was not found.");
            }
        }
コード例 #3
0
        private static List <AndroidElement> GetElementsByAccessibilityId(string accessibilityId)
        {
            var driver = OpenCommand.GetDriver();
            var wait   = new WebDriverWait(driver, TimeSpan.FromSeconds(7));

            try
            {
                wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[contains(@content-desc,\"" + accessibilityId + "\")]")));
                return(new List <AndroidElement>(driver.FindElementsByAccessibilityId(accessibilityId)));
            }
            catch
            {
                throw new ArgumentException($"Element with provided accessibility id was not found.");
            }
        }
コード例 #4
0
        public void Execute(Arguments arguments)
        {
            var    driver  = OpenCommand.GetDriver();
            string keycode = arguments.KeyCode.Value.ToLower();

            switch (keycode)
            {
            case "back":
                driver.PressKeyCode(AndroidKeyCode.Back);
                break;

            default:
                throw new ArgumentException($"Provided button name is invalid.");
            }
        }
コード例 #5
0
        public void Execute(Arguments arguments)
        {
            var driver = OpenCommand.GetDriver();

            if (arguments.By.Value != "" && arguments.Search.Value != "")
            {
                driver.HideKeyboard();
                SrollToElement(driver, arguments);
            }
            else if (arguments.ScrollAmount.Value != 0)
            {
                float top          = 0.9f;
                float bottom       = 0.1f;
                float swipeAmmount = arguments.ScrollAmount.Value / 100f * (top - bottom);
                SwipeVertical(driver, top, top - swipeAmmount, 0.5, 250, arguments.SwipeDir.Value);
            }
            else
            {
                throw new ArgumentException($"The id and text are not defined. You should provide one of them.");
            }
        }
コード例 #6
0
        public void Execute(Arguments arguments)
        {
            var driver = OpenCommand.GetDriver();

            driver.Quit();
        }