Example #1
0
        public List <ContactData> GetAllFoundedContacts()
        {
            List <ContactData> listContacts = new List <ContactData>();

            var contacts = ListFoundedContacts.FindElementsByXPath("//*[@class='android.widget.TableLayout']");

            foreach (var c in contacts)
            {
                var fName    = driver.FindElementById(Helpers.appPackage + ":id/textViewFirstName");
                var lName    = driver.FindElementById(Helpers.appPackage + ":id/textViewLastName");
                var email    = driver.FindElementById(Helpers.appPackage + ":id/textViewEmail");
                var phone    = driver.FindElementById(Helpers.appPackage + ":id/textViewPhone");
                var comments = driver.FindElementById(Helpers.appPackage + ":id/textViewComments");
                listContacts.Add(new ContactData()
                {
                    FirstName = fName.Text,
                    LastName  = lName.Text,
                    Email     = email.Text,
                    Phone     = phone.Text,
                    Comments  = comments.Text
                });
            }

            return(listContacts);
        }
        public void FindByAccessibilityIdTest()
        {
            By byAccessibilityId = new ByAccessibilityId("Graphics");

            Assert.AreNotEqual(driver.FindElementById("android:id/content").FindElement(byAccessibilityId).Text, null);
            Assert.GreaterOrEqual(driver.FindElementById("android:id/content").FindElements(byAccessibilityId).Count, 1);
        }
        public void Authorization_NegativeTest()
        {
            string login            = "******";
            string password         = "******";
            string errorMessageText = "";

            wait.Until(ExpectedConditions.ElementExists(By.Id("com.alibaba.aliexpresshd:id/et_email")));
            AndroidElement emailField = driver.FindElementById("com.alibaba.aliexpresshd:id/et_email");

            emailField.SendKeys(login);

            AndroidElement passwordField = driver.FindElementById("com.alibaba.aliexpresshd:id/et_password");

            passwordField.SendKeys(password);

            AndroidElement loginButton = driver.FindElementById("com.alibaba.aliexpresshd:id/tv_signin_btn_label");

            loginButton.Click();

            try
            {
                AndroidElement errorMessage = driver.FindElementById("com.alibaba.aliexpresshd:id/textinput_error");
                errorMessageText = errorMessage.Text;
            }
            catch (Exception)
            {
                throw new Exception("Элемент с сообщением об ошибке не представлен на странице");
            }

            Assert.IsTrue(errorMessageText == "???", "Текст сообщения об ошибке - '" + errorMessageText + "' отличается от ожидаемого" +
                          "???");
        }
Example #4
0
        public void deveSomarDoisValores()
        {
            DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

            desiredCapabilities.SetCapability("platformName", "Android");
            desiredCapabilities.SetCapability("deviceName", "emulator-5554");
            desiredCapabilities.SetCapability("automationName", "uiautomator2");
            desiredCapabilities.SetCapability("appPackage", "com.android.calculator2");
            desiredCapabilities.SetCapability("appActivity", "com.android.calculator2.Calculator");

            AndroidDriver <AppiumWebElement> driver = new AndroidDriver <AppiumWebElement>(new Uri("http://localhost:4723/wd/hub"), desiredCapabilities);

            AppiumWebElement el3 = (AppiumWebElement)driver.FindElementById("com.android.calculator2:id/digit_2");

            el3.Click();
            AppiumWebElement el4 = (AppiumWebElement)driver.FindElementByAccessibilityId("plus");

            el4.Click();
            AppiumWebElement el5 = (AppiumWebElement)driver.FindElementById("com.android.calculator2:id/digit_2");

            el5.Click();
            AppiumWebElement el6 = (AppiumWebElement)driver.FindElementById("com.android.calculator2:id/result");

            //System.out.print(el6.Text);

            Assert.AreEqual("4", el6.Text);
            driver.Quit();
        }
        public void deveSomarDoisValoress()
        {
            DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

            desiredCapabilities.SetCapability("platformName", "Android");
            desiredCapabilities.SetCapability("deviceName", "0030260344");
            desiredCapabilities.SetCapability("automationName", "uiautomator2");
            desiredCapabilities.SetCapability("appPackage", "com.google.android.calculator");
            desiredCapabilities.SetCapability("appActivity", "com.android.calculator2.CalculatorGoogle");

            AndroidDriver <AppiumWebElement> driver = new AndroidDriver <AppiumWebElement>(new Uri("http://localhost:4723/wd/hub"), desiredCapabilities);

            AppiumWebElement el1 = (AppiumWebElement)driver.FindElementById("com.google.android.calculator:id/digit_4");

            el1.Click();
            el1.Click();
            AppiumWebElement el2 = (AppiumWebElement)driver.FindElementByAccessibilityId("mais");

            el2.Click();
            AppiumWebElement el3 = (AppiumWebElement)driver.FindElementById("com.google.android.calculator:id/digit_4");

            el3.Click();
            AppiumWebElement el4 = (AppiumWebElement)driver.FindElementById("com.google.android.calculator:id/result");

            Assert.AreEqual("8", el4.Text);
            driver.Quit();
        }
Example #6
0
        public void TradeMe_verify_logged_account()
        {
            AppiumWebElement TradeMe_Login = app.FindElementById("nz.co.trademe.trademe:id/editTextLoginEmail");

            Assert.IsNotNull(TradeMe_Login);
            TradeMe_Login.SendKeys("*****@*****.**");
            AppiumWebElement TradeMe_Pwd = app.FindElementById("nz.co.trademe.trademe:id/editTextLoginPassword");

            TradeMe_Pwd.SendKeys("yorks64");
            AppiumWebElement Login_Button = app.FindElementById("nz.co.trademe.trademe:id/buttonLogin");

            Login_Button.Tap(1, 1);
            WebDriverWait wait = new WebDriverWait(app, TimeSpan.FromSeconds(30));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("nz.co.trademe.trademe:id/menuAccount")));
            AppiumWebElement account_icon = app.FindElementByAccessibilityId("Account");

            account_icon.Tap(1, 1);
            WebDriverWait wait1 = new WebDriverWait(app, TimeSpan.FromSeconds(30));

            wait1.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("nz.co.trademe.trademe:id/buttonLogout")));
            AppiumWebElement account_name = app.FindElementById("nz.co.trademe.trademe:id/textViewAboutMemberUsername");

            Assert.AreEqual(account_name.Text, "sunjeet81");
            AppiumWebElement logout_button = app.FindElementById("nz.co.trademe.trademe:id/buttonLogout");

            logout_button.Tap(1, 1);
            WebDriverWait wait2 = new WebDriverWait(app, TimeSpan.FromSeconds(30));

            wait2.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("nz.co.trademe.trademe:id/buttonDialogGenericConfirm")));
            AppiumWebElement confirm_button = app.FindElementByAccessibilityId("Confirm");

            confirm_button.Tap(1, 1);
            Assert.IsNotNull(app.FindElementByAccessibilityId("Login"));
        }
        public void BeforeAll()
        {
            DesiredCapabilities capabilities = new DesiredCapabilities();

            capabilities.SetCapability(MobileCapabilityType.BrowserName, "");
            capabilities.SetCapability(MobileCapabilityType.PlatformName, App.AndroidDeviceName());
            capabilities.SetCapability(MobileCapabilityType.PlatformVersion, App.AndroidPlatformVersion());
            capabilities.SetCapability(MobileCapabilityType.AutomationName, "UIAutomator2");
            capabilities.SetCapability(MobileCapabilityType.DeviceName, "Nokia");
            capabilities.SetCapability(MobileCapabilityType.App, App.AndroidApp());

            driver = new AndroidDriver <AndroidElement>(Env.ServerUri(), capabilities, Env.INIT_TIMEOUT_SEC);
            driver.Manage().Timeouts().ImplicitWait = Env.IMPLICIT_TIMEOUT_SEC;
            wait = new WebDriverWait(driver, Env.IMPLICIT_TIMEOUT_SEC);

            AndroidElement menuButton = driver.FindElementById("com.alibaba.aliexpresshd:id/left_action");

            menuButton.Click();

            AndroidElement authorizationMenuButton = driver.FindElementById("com.alibaba.aliexpresshd:id/chosen_account_content_view");

            authorizationMenuButton.Click();

            AndroidElement loginMenuButton = driver.FindElementById("com.alibaba.aliexpresshd:id/btn_sign_in");

            loginMenuButton.Click();

            AndroidElement list   = driver.FindElementById("android:id/autofill_dataset_list");
            TouchAction    action = new TouchAction(driver);

            action.Press(300, 100).Release().Perform();
        }
Example #8
0
        public void TradeMe_verify_logged_in()
        {
            // Find the login input field
            AppiumWebElement TradeMe_Login = app.FindElementById("nz.co.trademe.trademe:id/editTextLoginEmail");

            // key in your user name
            TradeMe_Login.SendKeys("*****@*****.**");
            // Find the password field
            AppiumWebElement TradeMe_Pwd = app.FindElementById("nz.co.trademe.trademe:id/editTextLoginPassword");

            // key in the password
            TradeMe_Pwd.SendKeys("yorks64");
            // Find the login button
            AppiumWebElement Login_Button = app.FindElementById("nz.co.trademe.trademe:id/buttonLogin");

            // Tap the login button
            Login_Button.Tap(1, 1);
            // Wait for the account menu item to be displayed
            WebDriverWait wait = new WebDriverWait(app, TimeSpan.FromSeconds(30));

            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("nz.co.trademe.trademe:id/menuAccount")));
            // Find icon for my account
            AppiumWebElement account_icon = app.FindElementByAccessibilityId("Account");

            // tap the icon
            account_icon.Tap(1, 1);
            // confirm that the logout button is visible, this is in turn ensure that the user name isbeing displayed
            wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("nz.co.trademe.trademe:id/buttonLogout")));
            // find and assert on the text of the user name
            AppiumWebElement account_name = app.FindElementById("nz.co.trademe.trademe:id/textViewAboutMemberUsername");

            Assert.AreEqual(account_name.Text, "sunjeet81");
        }
Example #9
0
        public void scrollAndSwipeTest()
        {
            driver.FindElementByName("Graphics").Click();
            driver.ScrollTo("FingerPaint", "android:id/list");
            driver.FindElementByName("FingerPaint").Click();
            AndroidElement element = driver.FindElementById("android:id/content");
            Point          point   = element.Coordinates.LocationInDom;
            Size           size    = element.Size;

            driver.Swipe
            (
                point.X + 5,
                point.Y + 5,
                point.X + size.Width - 5,
                point.Y + size.Height - 5,
                200
            );

            driver.Swipe
            (
                point.X + size.Width - 5,
                point.Y + 5,
                point.X + 5,
                point.Y + size.Height - 5,
                2000
            );
        }
Example #10
0
        public void SwipeTest()
        {
            driver.StartActivity("io.appium.android.apis", ".graphics.FingerPaint");
            AndroidElement element = driver.FindElementById("android:id/content");
            Point          point   = element.Coordinates.LocationInDom;
            Size           size    = element.Size;

            driver.Swipe
            (
                point.X + 5,
                point.Y + 5,
                point.X + size.Width - 5,
                point.Y + size.Height - 5,
                200
            );

            driver.Swipe
            (
                point.X + size.Width - 5,
                point.Y + 5,
                point.X + 5,
                point.Y + size.Height - 5,
                2000
            );
        }
Example #11
0
        //Method For Link Visibility
        public void links_visibility(string locator, string locator_type)
        {
            try
            {
                Thread.Sleep(3000);

                if (locator_type == "id")
                {
                    AndroidElement link = driver.FindElementById(locator);
                }
                else if (locator_type == "xpath")
                {
                    AndroidElement link = driver.FindElementByXPath(locator);
                }
            }
            catch (ElementNotVisibleException)
            {
                throw new AssertFailedException(string.Format("The element provided {0} is not on screen", locator));
            }
            catch (StaleElementReferenceException)
            {
                throw new AssertFailedException(string.Format("The element provided {0} is Stale", locator));
            }
            catch (Exception ex)
            {
                throw new Exception("ex message: " + ex.Message);
            }
        }
Example #12
0
        static void Main(string[] args)
        {
            AndroidDriver <AndroidElement> driver;
            var INIT_TIMEOUT_SEC = TimeSpan.FromSeconds(180);
            var Capabilities     = new DesiredCapabilities();
            var serverUrl        = new Uri("http://172.0.0.1:4723/wd/hub");

            //  Capabilities.SetCapability(CapabilityType.BrowserName,"");
            Capabilities.SetCapability(MobileCapabilityType.DeviceName, "Android");
            //Capabilities.SetCapability(MobileCapabilityType.AppActivity,"");
            //Capabilities.SetCapability(MobileCapabilityType.AppPackage,"");
            Capabilities.SetCapability(MobileCapabilityType.AppiumVersion, "1.4.13");
            Capabilities.SetCapability(MobileCapabilityType.App, @"C:/sample-code/apps/ApiDemos-debug.apk");

            driver = new AndroidDriver <AndroidElement>(serverUrl, Capabilities, INIT_TIMEOUT_SEC);
            driver.Manage().Timeouts().ImplicitlyWait(INIT_TIMEOUT_SEC);

            driver.FindElementByName("Graphics").Click();
            driver.ScrollTo("FingerPaint", "android:id/list");
            driver.FindElementByName("FingerPaint").Click();
            AndroidElement element = driver.FindElementById("android:id/content");
            Point          point   = element.Coordinates.LocationInDom;
            Size           size    = element.Size;

            driver.Swipe
            (
                point.X + 5,
                point.Y + 5,
                point.X + size.Width - 5,
                point.Y + size.Height - 5,
                200
            );

            driver.Swipe
            (
                point.X + size.Width - 5,
                point.Y + 5,
                point.X + 5,
                point.Y + size.Height - 5,
                2000
            );

            driver.FindElementByName("Graphics").Click();
            driver.ScrollTo("OpenGL ES", "android:id/list").Click();
            //driver.FindElementByName("OpenGL ES").Click();
            driver.ScrollTo("Touch Rotate", "android:id/list").Click();
            //driver.FindElementByName("TouchRotate").Click();

            AndroidElement element1 = driver.FindElementById("android:id/content");

            driver.Pinch(element1);
            driver.Zoom(element1);

            Thread.Sleep(2000);

            driver.Quit();
        }
Example #13
0
        public void ChangeLang()
        {
            var height = driver.Manage().Window.Size.Height;
            var width  = driver.Manage().Window.Size.Width;

            driver.FindElementById(BookmarkId).Click();

            Thread.Sleep(700);
            bool notfound = true;

            while (notfound)
            {
                try
                {
                    driver.FindElementByXPath(LanguagesBtn).Click();
                }
                catch (Exception e)
                {
                    driver.Swipe(width / 2, height * 3 / 5, width / 2, height / 5, 500);
                    continue;
                }
                notfound = false;
            }
            Thread.Sleep(700);

            driver.FindElementByXPath(EnglishOption).Click();
            //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(90);

            //driver.FindElementById(BookmarkId).Click();
            //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(4);

            //Thread.Sleep(700);
            //notfound = true;
            //while (notfound)
            //{
            //    try
            //    {
            //        var a = driver.FindElementByXPath(LanguagesBtn);
            //        Assert.AreEqual(a.GetAttribute("content-desc").ToLower(), "Язык".ToLower());
            //        a.Click();
            //    }
            //    catch (Exception e)
            //    {
            //        driver.Swipe(width / 2, height * 3 / 5, width / 2, height / 5, 500);
            //        continue;
            //    }
            //    notfound = false;
            //}
            //Thread.Sleep(700);

            //driver.FindElementByXPath(DefaultOption).Click();
            //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);

            //Thread.Sleep(6000);
        }
Example #14
0
        private void buffViewBtn_Click(object sender, EventArgs e)
        {
            var id = idInput.Text;

            if (string.IsNullOrEmpty(id))
            {
                MessageBox.Show("vui lòng nhập Id .........");
            }
            else
            {
                thaTimBtn.Enabled  = false;
                commentBtn.Enabled = false;
                DeviceConfiguration();
                _appiumLocalService = new AppiumServiceBuilder().UsingAnyFreePort().Build();
                _appiumLocalService.Start();

                foreach (var device in devices)
                {
                    AndroidDriver <IWebElement> _driver;
                    DesiredCapabilities         cap = new DesiredCapabilities();
                    cap.SetCapability("deviceName", device.DeviceName);
                    cap.SetCapability("UDID", device.UDID);
                    cap.SetCapability("platformVersion", device.PlatformVersion);
                    cap.SetCapability("platformName", "Android");
                    cap.SetCapability("appPackage", "sg.bigo.live");
                    cap.SetCapability("appActivity", "com.yy.iheima.MainActivity");
                    cap.SetCapability("noReset", "true");
                    cap.SetCapability(MobileCapabilityType.NewCommandTimeout, 30000);
                    _driver = new AndroidDriver <IWebElement>(_appiumLocalService, cap);
                    androidDrivers.Add(_driver);
                    var switchToSearchElementButton = _driver.FindElementById("sg.bigo.live:id/iv_search");
                    switchToSearchElementButton.Click();
                    Thread.Sleep(500);
                    var textSearchInput = _driver.FindElementById("sg.bigo.live:id/search_et");
                    textSearchInput.SendKeys(id);
                    var searchButtonElement = _driver.FindElementById("sg.bigo.live:id/tv_search");
                    searchButtonElement.Click();
                    Thread.Sleep(1000);
                    try
                    {
                        var liveButtonElement = _driver.FindElementById("sg.bigo.live:id/rl_live");
                        liveButtonElement.Click();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("người dùng này chưa online", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                thaTimBtn.Enabled      = true;
                commentBtn.Enabled     = true;
                thoigianthatim.Enabled = true;
            }
        }
Example #15
0
        public void Test1()
        {
            Assert.IsNotNull(driver);
            Thread.Sleep(5000);
            string context = driver.Context;

            driver.Context = ("NATIVE_APP");
            driver.FindElementById("com.android.chrome:id/terms_accept").Click();
            driver.FindElementById("com.android.chrome:id/negative_button").Click();
            driver.Context = (context);
            driver.Navigate().GoToUrl("http://www.cnn.com");

            Thread.Sleep(15000);
        }
Example #16
0
        public void OpedSideMenuWithButtonTest()
        {
            int duration = 1000;

            AndroidElement menuButton = driver.FindElementById("com.alibaba.aliexpresshd:id/left_action");

            menuButton.Click();
            wait.Until(ExpectedConditions.ElementExists(By.Id("com.alibaba.aliexpresshd:id/navdrawer_items_list")));

            TouchAction action = new TouchAction(driver);

            action.Tap(719, 400).Perform();
            wait.Until(ExpectedConditions.InvisibilityOfElementLocated(By.Id("com.alibaba.aliexpresshd:id/navdrawer_items_list")));
        }
Example #17
0
        public void SwipeTest()
        {
            _driver.StartActivity("io.appium.android.apis", ".graphics.FingerPaint");
            ITouchAction touchAction = new TouchAction(_driver);
            var          element     = _driver.FindElementById("android:id/content");
            Point        point       = element.Coordinates.LocationInDom;
            Size         size        = element.Size;

            touchAction
            .Press(point.X + 5, point.Y + 5)
            .Wait(200).MoveTo(point.X + size.Width - 5, point.Y + size.Height - 5)
            .Release()
            .Perform();
        }
Example #18
0
        public void leitura()
        {
            WebDriverWait aguardandoElmento = new WebDriverWait(driver, TimeSpan.FromSeconds(30));

            //interagindo com os componentes
            driver.FindElementById("br.com.xxx.android.xxxxxxx.launcher:id/imgIcon").Click();

            //aguarda até que o elemento exista
            aguardandoElmento.Until(ExpectedConditions.ElementExists(By.Id("br.com.xxx.android.xxxxxxx.lis:id/btnLogin")));

            //verifica o nome do botão, mas a ideia da variável seria para retorno ou exibição de mensagem
            String mensagemAtual = driver.FindElementById("br.com.xxx.android.xxxxxxx.lis:id/btnLogin").Text;

            Assert.AreEqual("ENTRAR", mensagemAtual);
        }
Example #19
0
        // Get element from selector
        public static AndroidElement GetElement(AndroidDriver <AndroidElement> driver, SelectBy by, string selector)
        {
            AndroidElement e = null;

            switch (by)
            {
            case SelectBy.ID:
                e = driver.FindElementById(selector);
                break;

            case SelectBy.Class:
                e = driver.FindElementByClassName(selector);
                break;

            case SelectBy.XPath:
                e = driver.FindElementByXPath(selector);
                break;

            case SelectBy.ExactText:
                e = driver.FindElementByAndroidUIAutomator(String.Format("new UiSelector().text(\"{0}\")", selector));
                break;

            case SelectBy.ContainsText:
                e = driver.FindElementByAndroidUIAutomator(String.Format("new UiSelector().textContains(\"{0}\")", selector));
                break;

            case SelectBy.RegexText:
                e = driver.FindElementByAndroidUIAutomator(String.Format("new UiSelector().textMatches(\"{0}\")", selector));
                break;
            }
            return(e ?? throw new NotFoundException("Element with selector " + selector + " not found."));
        }
Example #20
0
        public static string GetValueFromElement(AndroidDriver <AppiumWebElement> webDriver, string by, string elementName, int timeInseconds)
        {
            string elementText = "";

            switch (by)
            {
            case "id":
                elementText = webDriver.FindElementById(elementName).GetAttribute("value");
                break;

            case "xPath":
                elementText = webDriver.FindElementByXPath(elementName).GetAttribute("value");
                break;

            case "cssSelector":
                elementText = webDriver.FindElementByCssSelector(elementName).GetAttribute("value");
                break;

            case "name":
                elementText = webDriver.FindElementByName(elementName).GetAttribute("value");
                break;

            case "className":
                elementText = webDriver.FindElementByClassName(elementName).GetAttribute("value");
                break;

            case "linkText":
                elementText = webDriver.FindElementByLinkText(elementName).GetAttribute("value");
                break;
            }

            Thread.Sleep(timeInseconds * 1000);

            return(elementText);
        }
        public void FindByAndroidDataMatcherTest()
        {
            const string selectorData = @"{
                'name':'hasEntry',
                'args':['title','Graphics']
                }";

            By byAndroidDataMatcher = new ByAndroidDataMatcher(selectorData);

            Assert.AreNotEqual(
                _driver.FindElementById("android:id/list").FindElement(byAndroidDataMatcher).Text,
                null);
            Assert.GreaterOrEqual(
                _driver.FindElementById("android:id/list").FindElements(byAndroidDataMatcher).Count,
                1);
        }
Example #22
0
        public static void ClearTextElement(AndroidDriver <AppiumWebElement> webDriver, string by, string elementName, int timeInSeconds)
        {
            switch (by)
            {
            case "id":
                webDriver.FindElementById(elementName).Clear();
                break;

            case "xPath":
                webDriver.FindElementByXPath(elementName).Clear();
                break;

            case "cssSelector":
                webDriver.FindElementByCssSelector(elementName).Clear();
                break;

            case "name":
                webDriver.FindElementByName(elementName).Clear();
                break;

            case "className":
                webDriver.FindElementByClassName(elementName).Clear();
                break;
            }

            Thread.Sleep(timeInSeconds * 1000);
        }
Example #23
0
        public void Test1()
        {
            var apiBar = driver.FindElementById("contactbook.androidclient:id/buttonConnect");

            apiBar.Click();
            var searchBar = driver.FindElementById("contactbook.androidclient:id/editTextKeyword");

            searchBar.SendKeys("steve");
            var searchButton = driver.FindElementById("contactbook.androidclient:id/buttonSearch");

            searchButton.Click();
            string fname = driver.FindElementById("contactbook.androidclient:id/textViewFirstName").Text;
            string lname = driver.FindElementById("contactbook.androidclient:id/textViewLastName").Text;

            Assert.AreEqual("Steve Jobs", fname + " " + lname);
        }
Example #24
0
        /// <summary>
        /// 打开电台听一个英文节目
        /// </summary>
        /// <returns></returns>
        static void RadioStation(int Tag = 2)
        {
            Console.WriteLine("点击电台按钮");

            // 点击电台按钮
            (new TouchAction(driver)).Tap(968, 2246).Perform();
            Thread.Sleep(2000);

            Console.WriteLine("寻找听英语");
            // 滑动到最后听英语
            TouchAction actions = new TouchAction((IPerformsTouchActions)driver);

            actions.Press(906, 338).Wait(300).MoveTo(80, 338).Release().Perform();
            Thread.Sleep(1000);
            var groupList = driver.FindElementsByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout[1]/android.support.v4.view.ViewPager/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.view.ViewGroup/android.widget.LinearLayout");

            for (int i = 0; i < groupList.Count; i++)
            {
                var path = $@"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout[1]/android.support.v4.view.ViewPager/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.view.ViewGroup/android.widget.LinearLayout[{i+1}]/android.widget.TextView";

                var remark = driver.FindElementByXPath(path).GetAttribute("text");
                if (remark == "听英语")
                {
                    driver.FindElementByXPath(path).Click();
                    Thread.Sleep(2000);
                    Console.WriteLine("开始听英语新闻");

                    driver.FindElementByXPath($@"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout[1]/android.support.v4.view.ViewPager/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.ListView/android.widget.FrameLayout[{Tag}]").Click();
                    Thread.Sleep(2000);

                    driver.FindElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout[2]/android.widget.FrameLayout[2]/android.widget.ListView/android.widget.LinearLayout[1]/android.widget.LinearLayout").Click();
                    Console.WriteLine("小话到后台让他去听");

                    driver.FindElementById("cn.xuexi.android:id/btn_back").Click();

                    Thread.Sleep(1000);
                    driver.FindElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout[1]/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout[2]/android.widget.FrameLayout[1]/android.widget.LinearLayout").Click();
                    Console.WriteLine("返回到主页");
                    Thread.Sleep(1000);

                    (new TouchAction(driver)).Tap(535, 2246).Perform();
                    Thread.Sleep(2000);

                    return;
                }
            }
        }
 public void StartActivityWithDefaultIntentAndDefaultCategoryWithOptionalArgs()
 {
     driver.StartActivityWithIntent("com.prgguru.android", ".GreetingActivity", "android.intent.action.MAIN", null, null,
                                    "android.intent.category.DEFAULT", "0x4000000",
                                    "--es \"USERNAME\" \"AppiumIntentTest\" -t \"text/plain\"");
     Assert.AreEqual(driver.FindElementById("com.prgguru.android:id/textView1").Text,
                     "Welcome AppiumIntentTest");
 }
Example #26
0
        public void LogInHome()

        {
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));

            driver.FindElementById("com.pinterest:id/email_address").Click();
            driver.FindElementById("com.google.android.gms:id/cancel").Click();

            var inputEmail = driver.FindElementById("com.pinterest:id/email_address");

            inputEmail.SendKeys("*****@*****.**");

            var continue_email_bt = driver.FindElementById("com.pinterest:id/continue_email_bt");

            continue_email_bt.Click();

            var password = driver.FindElementById("com.pinterest:id/password");

            password.SendKeys("pinterest1");

            var next_bt = driver.FindElementById("com.pinterest:id/login_bt");

            next_bt.Click();

            var IsElementPresent = driver.FindElementById("com.pinterest:id/bottom_nav_home_icon").Displayed;


            Assert.IsTrue(IsElementPresent);
        }
        public void LocatingElementsTest()
        {
            AndroidElement button = _driver.FindElementById("button");

            button.Click();

            AndroidElement checkBox = _driver.FindElementByClassName("android.widget.CheckBox");

            checkBox.Click();

            AndroidElement secondButton = _driver.FindElementByAndroidUIAutomator("new UiSelector().textContains(\"BUTTO\");");

            secondButton.Click();

            AndroidElement thirdButton = _driver.FindElementByXPath("//*[@resource-id='com.example.android.apis:id/button']");

            thirdButton.Click();
        }
        public AppiumWebElement Create_a_NewNote()
        {
            AppiumWebElement new_note = driver.FindElementByAccessibilityId("New note");

            new_note.Tap(1, 1);
            AppiumWebElement new_note_screen = driver.FindElementById("android:id/action_bar_title");

            return(new_note_screen);
        }
        static void Main()
        {
            AndroidDriver <AndroidElement> driver;
            DesiredCapabilities            capability = DesiredCapabilities.Android();

            capability.SetCapability("browserstack.user", Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"));
            capability.SetCapability("browserstack.key", Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"));
            capability.SetCapability("build", "App Testing Android");
            capability.SetCapability("name", "sample csharp");
            capability.SetCapability("browserstack.debug", true);
            capability.SetCapability("platform", "android");
            capability.SetCapability("device", "Google Nexus 6");
            capability.SetCapability("realMobile", true);
            capability.SetCapability("app", Environment.GetEnvironmentVariable("ANDROID_APP_URL"));

            driver = new AndroidDriver <AndroidElement>(
                new Uri("http://hub-cloud.browserstack.com/wd/hub/"), capability
                );

            ((ITakesScreenshot)driver).GetScreenshot();

            AndroidElement samplelabel = driver.FindElementById("sampleLabel");

            Console.WriteLine(samplelabel.Text);

            var contexts = driver.Contexts;

            AndroidElement num1 = driver.FindElementById("num1");
            AndroidElement num2 = driver.FindElementById("num2");

            num1.SendKeys("12");
            num2.SendKeys("32");

            AndroidElement add_btn = driver.FindElementById("addBtn");

            add_btn.Tap(1, 1000);

            ((ITakesScreenshot)driver).GetScreenshot();
            Console.WriteLine(samplelabel.Text);

            driver.Quit();
        }
        public void EnterAs(string name)
        {
            if (name != null)
            {
                AndroidElement nameTextbox = driver.FindElementById(NameEdittextId);
                nameTextbox.SendKeys(name);
            }
            else
            {
                name = "Guest";
            }

            AndroidElement nextScreenButton = driver.FindElementByClassName(NextScreenButtonClass);

            nextScreenButton.Click();

            AndroidElement welcomeTextview = driver.FindElementById(WelcomeTextviewId);

            Assert.That(welcomeTextview.Text, Is.EqualTo("Welcome " + name), "Incorrect welcome text");
        }