Exemplo n.º 1
0
        private static AndroidElement GetElementByXpath(string xpath)
        {
            var driver = OpenCommand.GetDriver();
            var wait   = new WebDriverWait(driver, TimeSpan.FromSeconds(7));

            try
            {
                wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(xpath)));
                return(driver.FindElement(By.XPath(xpath)));
            }
            catch
            {
                throw new ArgumentException($"Element with provided xpath was not found.");
            }
        }
Exemplo n.º 2
0
        private static AndroidElement GetElementByText(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(driver.FindElement(By.XPath("//*[contains(text(),\"" + text + "\")]")));
            }
            catch
            {
                throw new ArgumentException($"Element with provided text was not found.");
            }
        }
Exemplo n.º 3
0
        private static AndroidElement GetElementByAccessibilityId(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(driver.FindElementByAccessibilityId(accessibilityId));
            }
            catch
            {
                throw new ArgumentException($"Element with provided accessibility id was not found.");
            }
        }
Exemplo n.º 4
0
        public void Execute(Arguments arguments)
        {
            arguments.Search.Value = "com.viber.voip:id/bottom_nav_tab_3";
            arguments.By.Value     = "id";
            var by = arguments.By.Value.ToLower();


            if (by == "xy")
            {
                TouchAction clickAction = new TouchAction(OpenCommand.GetDriver());
                var         coordinates = arguments.Search.Value.Split(',');
                clickAction.Tap(int.Parse(coordinates[0]), int.Parse(coordinates[1])).Perform();
            }
            else
            {
                ElementHelper.GetElement(arguments.By.Value.ToLower(), arguments.Search.Value).Click();
            }
        }
Exemplo n.º 5
0
        public void Execute(Arguments arguments)
        {
            arguments.Search.Value = "com.viber.voip:id/bottom_nav_tab_3";
            arguments.By.Value     = "id";
            var by = arguments.By.Value.ToLower();


            if (by == "xy")
            {
                TouchAction clickAction = new TouchAction(OpenCommand.GetDriver());
                var         coordinates = arguments.Search.Value.Split(',');
                clickAction.Tap(int.Parse(coordinates[0]), int.Parse(coordinates[1])).Perform();
            }
            else
            {
                ElementHelper.GetElement(arguments.By.Value.ToLower(), arguments.Search.Value).Click();
                arguments.Search.Value = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[5]";
                arguments.By.Value     = "xpath";
                ElementHelper.GetElement(arguments.By.Value.ToLower(), arguments.Search.Value).Click();
            }
        }
Exemplo n.º 6
0
        public void Execute(Arguments arguments)
        {
            arguments.Search.Value = "com.viber.voip:id / menu_search";
            arguments.By.Value     = "id";
            var by = arguments.By.Value.ToLower();


            if (by == "xy")
            {
                TouchAction clickAction = new TouchAction(OpenCommand.GetDriver());
                var         coordinates = arguments.Search.Value.Split(',');
                clickAction.Tap(int.Parse(coordinates[0]), int.Parse(coordinates[1])).Perform();
            }
            else
            {
                ElementHelper.GetElement(arguments.By.Value.ToLower(), arguments.Search.Value).Click();
                arguments.Search.Value = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.widget.LinearLayout/android.view.ViewGroup/androidx.appcompat.widget.LinearLayoutCompat/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.EditText";
                arguments.By.Value     = "xpath";
                ElementHelper.GetElement(arguments.By.Value.ToLower(), arguments.Search.Value).Click();
                ElementHelper.GetElement(arguments.By.Value, arguments.Search.Value).SendKeys(arguments.search.Value);
            }
        }