Esempio n. 1
0
        public static void ImportContacts(AppiumDevice ap)
        {
            var el1 = ap.GetElementByID("com.google.android.gsf.login:id/skip_button");

            el1.Click();
            var el2 = ap.GetElementByID("com.android.contacts:id/import_contacts_button");

            el2.Click();
            var el3 = ap.GetElementByXpath("/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.ListView/android.widget.TextView[2]");

            el3.Click();
        }
Esempio n. 2
0
        public static async Task <bool> WriteMessages(DeviceController.DeviceController device)
        {
            AppiumDevice ap = device.AppiumDevice;

            NumberBase.NumberBase numberBase = device.NumberBase;
            Logger.log("NumberBase: " + numberBase.Name);
            try
            {
                foreach (var number in numberBase.PhoneNumbers)
                {
                    int iterations = 0;
                    while (iterations < 20)
                    {
                        try
                        {
                            var el17 = ap.GetElementByAccessibilityID("Search");
                            el17.Click();
                            break;
                        }
                        catch
                        {
                            iterations++;
                            await Task.Delay(1000);
                        }
                    }
                    iterations = 0;
                    while (iterations < 20)
                    {
                        try
                        {
                            var el19 = ap.GetElementByID("com.whatsapp:id/search_src_text");
                            el19.SendKeys(number.Number);
                            break;
                        }
                        catch
                        {
                            iterations++;
                            await Task.Delay(1000);
                        }
                    }

                    iterations = 0;
                    while (iterations < 25)
                    {
                        try
                        {
                            var el20 = ap.GetElementByXpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout[1]/androidx.viewpager.widget.ViewPager/android.widget.LinearLayout/android.widget.ListView/android.widget.RelativeLayout[1]");
                            el20.Click();
                            break;
                        }
                        catch
                        {
                            iterations++;
                            await Task.Delay(1000);
                        }
                    }
                    while (iterations < 20)
                    {
                        try
                        {
                            var el21 = ap.GetElementByID("com.whatsapp:id/entry");
                            el21.SendKeys(numberBase.Message.MessageText);
                            break;
                        }
                        catch
                        {
                            iterations++;
                            await Task.Delay(1000);
                        }
                    }
                    while (iterations < 20)
                    {
                        try
                        {
                            var el22 = ap.GetElementByAccessibilityID("Send");
                            el22.Click();

                            Logger.log("Message sent");
                            break;
                        }
                        catch
                        {
                            iterations++;
                            await Task.Delay(1000);
                        }
                    }
                    ap.Back();
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Esempio n. 3
0
        //Old
        public static async void WriteMessage(AppiumDevice ap, string number, string text)
        {
            Logger.log("New message to: " + number);
            int iterations = 0;

            while (iterations < 20)
            {
                try
                {
                    var el17 = ap.GetElementByAccessibilityID("Search");
                    el17.Click();
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }
            iterations = 0;
            while (iterations < 20)
            {
                try
                {
                    var el19 = ap.GetElementByID("com.whatsapp:id/search_src_text");
                    el19.SendKeys(number);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }

            iterations = 0;
            while (iterations < 25)
            {
                try
                {
                    var el20 = ap.GetElementByXpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout[1]/androidx.viewpager.widget.ViewPager/android.widget.LinearLayout/android.widget.ListView/android.widget.RelativeLayout[1]");
                    el20.Click();
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }
            while (iterations < 20)
            {
                try
                {
                    var el21 = ap.GetElementByID("com.whatsapp:id/entry");
                    el21.SendKeys(text);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }
            while (iterations < 20)
            {
                try
                {
                    var el22 = ap.GetElementByAccessibilityID("Send");
                    el22.Click();

                    Logger.log("Message sent");
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }
            ap.Back();
        }