Beispiel #1
0
        public override void Execute(Like4LikeManager mgr)
        {
            //var element = mgr.Driver.FindElement(By.XPath("//*[@id=\"result\"]/img"));
            ////var src = element.GetAttribute("src");

            //var htmlElement = mgr.Driver.FindElement(By.TagName("html"));
            ////Point viewPortLocation = ((ILocatable)htmlElement).Coordinates.onScreen();


            //var img = new GrayImageProcess(ScreenshotUtils.GetScreenshot(new Rectangle(element.Location, element.Size)));
            //img.Image.Save("D:/a.png");
            //var ls = img.Split(7);
            //var arr = GrayImageProcess.Process(ls).Select(x => x.Name).ToArray();
            //var w = ls[0].Width;

            //foreach (var i in GrayImageProcess.Process(ls))
            //{
            //    i.Image.Save("d:/" + i.Name + ".png", ImageFormat.Png);
            //}

            //var builder = new Actions(mgr.Driver);
            //builder.MoveByOffset(element.Location.X + (w * arr[0] + 20), element.Location.Y + 20).Click().Perform();
            //builder.MoveByOffset(element.Location.X + (w * arr[1] + 20), element.Location.Y + 20).Click().Perform();


            MessageBox.Show("Click bonus and ok");
            mgr.CurrentState = OldPage;
            //mgr.CurrentState = new LikeFacebookPage();
        }
Beispiel #2
0
        public override void Execute(Like4LikeManager mgr)
        {
            Login(mgr);

            while (true)
            {
                ReNavigateEarnUrl(mgr);
                var oldWindow = mgr.Driver.WindowHandles.First();

                if (mgr.Driver.Url == mgr.BonusUrl)
                {
                    var bonus = UnityFacade.Resolve <BonusPage>();
                    bonus.OldPage    = this;
                    mgr.CurrentState = bonus;

                    break;
                }

                mgr.Driver.SwitchTo().Window(oldWindow);
                var buttons = new ButtonGetter().Execute(mgr.Driver);

                foreach (var type in GetTypes())
                {
                    var arr = type.Split(new[] { "###" }, StringSplitOptions.RemoveEmptyEntries);
                    ProcessLike(mgr, buttons.Buttons, arr[0], arr[1]);
                }

                mgr.Driver.SwitchTo().Window(oldWindow);
                //mgr.Driver.Navigate().Refresh();
            }
        }
Beispiel #3
0
        protected override void Login(Like4LikeManager mgr)
        {
            mgr.Driver.Navigate().GoToUrl(LoginUrl);
            mgr.Driver.WaitUntilDocumentIsReady();

            var btnLogin = mgr.Driver.FindElements(By.XPath(ElementLoginButtonXPath));

            if (btnLogin.Count == 0)
            {
                return;
            }

            mgr.Driver.FindElement(By.XPath(ElementEmailId)).SendKeys(UserName);
            mgr.Driver.FindElement(By.XPath(ElementPassId)).SendKeys(Password);
            mgr.Driver.FindElement(By.XPath(ElementLoginButtonXPath)).Click();
            mgr.Driver.WaitUntilDocumentIsReady();
        }
Beispiel #4
0
        protected void ProcessLike(Like4LikeManager mgr, List <ButtonGetter.Button> buttons, string imgBackgroundUrl, string clickXPath)
        {
            var oldUrl = mgr.Driver.WindowHandles.First();

            foreach (var button in buttons.Where(x => x.BackgroundUrl == imgBackgroundUrl))
            {
                try
                {
                    mgr.Driver.WaitUntilDocumentIsReady();
                    System.Threading.Thread.Sleep(2000);
                    button.Element.Click();
                    System.Threading.Thread.Sleep(2000);
                    mgr.Driver.SwitchTo().Window(mgr.Driver.WindowHandles.Last());
                    mgr.Driver.WaitUntilDocumentIsReady();

                    foreach (var xpath in new[] { clickXPath })
                    {
                        var likes = mgr.Driver.FindElements(By.XPath(xpath));
                        likes.ToList().ForEach(x => { try { x.Click(); } catch { /* nothing */ } });
                        System.Threading.Thread.Sleep(5000);
                    }

                    try
                    {
                        while (mgr.Driver.WindowHandles.Count > 1)
                        {
                            mgr.Driver.SwitchTo().Window(mgr.Driver.WindowHandles[1]);
                            mgr.Driver.Close();
                        }
                    }
                    catch
                    {
                        //nothing
                    }
                    finally
                    {
                        mgr.Driver.SwitchTo().Window(oldUrl);
                        System.Threading.Thread.Sleep(1000);
                    }
                }
                catch (Exception)
                {
                    // nothing
                }
            }
        }
Beispiel #5
0
 private void CheckForNavigate(Like4LikeManager mgr, IWebDriver driver)
 {
     if (driver.FindElements(By.XPath(ElementCheckLoginSuccessXPath)).Count > 0)
     {
         mgr.CurrentState = UnityFacade.Resolve <LogedInPage>();
     }
     else
     if (driver.FindElements(By.XPath(ElementCheckFailedXPath)).Count > 0)
     {
         mgr.CurrentState = UnityFacade.Resolve <EnterCodePage>();
     }
     else
     {
         Thread.Sleep(2000);
         throw new Exception("Unknown page");
     }
 }
Beispiel #6
0
        }                                                   //= "//*[@id='adcopy-outer']";

        public override void Execute(Like4LikeManager mgr)
        {
            var driver = mgr.Driver;

            Common.Try(() =>
            {
                driver.Navigate().GoToUrl(LoginUrl);
                var myField = driver.FindElement(By.XPath(ElementUserNameXPath));
                myField.SendKeys(UserName);

                myField = driver.FindElement(By.XPath(ElementPasswordXPath));
                myField.SendKeys(Password);

                myField = driver.FindElement(By.XPath(ElementSubmitXPath));
                myField.Click();
                Thread.Sleep(3000);

                driver.WaitUntilDocumentIsReady();

                CheckForNavigate(mgr, driver);
            });
        }
Beispiel #7
0
        }                                   //= {
        //    "url(http://www.like4like.org/img/icon/earn-facebook-post-like.png)###//a[@class=\"UFILikeLink _4x9- _4x9_ _48-k\"]",
        //    "url(http://www.like4like.org/img/icon/earn-facebook-like.png)###//button[@class=\"likeButton _4jy0 _4jy4 _517h _51sy _42ft\"]",
        //    "url(http://www.like4like.org/img/icon/earn-facebook-photo-like.png)###//a[@class=\"UFILikeLink _4x9- _4x9_ _48-k\"]"
        //};


        protected override void ReNavigateEarnUrl(Like4LikeManager mgr)
        {
            ReNavigateEarnUrl(mgr, EarnUrl);
        }
Beispiel #8
0
 internal void ReNavigateEarnUrl(Like4LikeManager mgr, string earnUrl)
 {
     mgr.Driver.WaitUntilDocumentIsReady();
     mgr.Driver.Navigate().GoToUrl(earnUrl);
     mgr.Driver.WaitUntilDocumentIsReady();
 }
Beispiel #9
0
 protected abstract void Login(Like4LikeManager mgr);
Beispiel #10
0
 protected abstract void ReNavigateEarnUrl(Like4LikeManager mgr);
Beispiel #11
0
 public override void Execute(Like4LikeManager mgr)
 {
     throw new NotImplementedException();
 }
Beispiel #12
0
 private static void ToFacebookLike(Like4LikeManager mgr)
 {
     mgr.CurrentState = UnityFacade.Resolve <LikeFacebookPage>();//new LikeFacebookPage();
 }
Beispiel #13
0
 private static void ToYoutubeLike(Like4LikeManager mgr)
 {
     mgr.CurrentState = UnityFacade.Resolve <LikeYoutubePage>();// new LikeYoutubePage();
 }
Beispiel #14
0
 private void Process(Like4LikeManager mgr)
 {
     ToYoutubeLike(mgr);
     // ToFacebookLike(mgr);
 }
Beispiel #15
0
 public override void Execute(Like4LikeManager mgr)
 {
     Common.Try(() => { Process(mgr); });
 }