Exemple #1
0
        public static void WriteName(AppiumDevice ap, string name)
        {
            var el1 = ap.GetElementByID("com.whatsapp:id/registration_name");

            el1.SendKeys(name);
            var el2 = ap.GetElementByID("com.whatsapp:id/register_name_accept");

            el2.Click();
            var el3 = ap.GetElementByID("com.whatsapp:id/instruction_badge");

            el3.Click();
            var el4 = ap.GetElementByAccessibilityID("New chat");

            el4.Click();
        }
Exemple #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);
        }
Exemple #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();
        }