Beispiel #1
0
        public void LoadAnimeList(bool needSynopsis = false)
        {
            var width = EpisodesFlowPanel.Width;

            EpisodesFlowPanel.Controls.Clear();
            AnimeSynopsis.Text = CleanSynopsis(AnimeSynopsis.Text);

            _phantomObject.Navigate().GoToUrl(AnimeUrl);
            if (needSynopsis)
            {
                AnimeSynopsis.Text = CleanSynopsis(_phantomObject.FindElementsByTagName("p")[2].Text);
            }
            var myTable = _phantomObject.FindElementsByClassName("episode");

            foreach (var node in myTable)
            {
                var epcontrol = new EpisodeControl
                {
                    Text = node.Text.Trim(),
                    Tag  = node.GetAttribute("data-value")
                };
                if (StaticsClass.MyAnimeListObject != null)
                {
                    epcontrol.RateIcon.Click += RateIcon_Click;
                }
                else
                {
                    epcontrol.RateIcon.Visible = false;
                }
                EpisodesFlowPanel.Controls.Add(epcontrol);
                EpisodesFlowPanel.Controls.SetChildIndex(epcontrol, 0);
            }
            BringToFront();
        }
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            if (User.Text == "" || Password.Password == "")
            {
                MessageBox.Show("Insert user and password");
                return;
            }

            PhantomJSDriverService srv = PhantomJSDriverService.CreateDefaultService();

            srv.SuppressInitialDiagnosticInformation = true;
            srv.HideCommandPromptWindow = true;
            using (PhantomJSDriver chrDriver = new PhantomJSDriver(srv))
            {
                try
                {
                    chrDriver.Manage().Window.Minimize();
                }
                catch (Exception ex)
                {
                    //Evbb
                }
                chrDriver.Url = "https://idp.polito.it/idp/x509mixed-login";
                chrDriver.Navigate();
                IWebElement element = chrDriver.FindElementById("j_username");
                element.SendKeys(User.Text);
                element = chrDriver.FindElementById("j_password");
                element.SendKeys(Password.Password);
                element = chrDriver.FindElementsByTagName("button").Where((x) =>
                {
                    try
                    {
                        x.FindElement(By.Id("usernamepassword"));
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        return(false);
                    }
                }).First();

                element.Click();
                chrDriver.Url = "https://didattica.polito.it/portal/page/portal/home/Studente";
                chrDriver.Navigate();
                if (chrDriver.Manage().Cookies.GetCookieNamed("ShibCookie") != null)
                {
                    chrDriver.Manage().Cookies.AllCookies.ToList()
                    .ForEach(x =>
                             jar.Add(new System.Net.Cookie(x.Name, x.Value, x.Path, x.Domain)));
                    this.DialogResult = true;
                }
                else
                {
                    jar = null;
                    this.DialogResult = false;
                }
                this.Close();
            }
        }
        public void LoadAnimeList(bool needSynopsis = false)
        {
            var width = EpisodesFlowPanel.Width;

            EpisodesFlowPanel.Controls.Clear();
            AnimeSynopsis.Text = CleanSynopsis(AnimeSynopsis.Text);

            var splitData = AnimeUrl.Split('/');

            splitData[splitData.Length - 1] = System.Web.HttpUtility.UrlEncode(splitData.Last(), System.Text.Encoding.UTF8);
            AnimeUrl = string.Join("/", splitData);

            _phantomObject.Navigate().GoToUrl(AnimeUrl);
            if (needSynopsis)
            {
                AnimeSynopsis.Text = CleanSynopsis(_phantomObject.FindElementsByTagName("p")[2].Text);
            }
            var myTable = _phantomObject.FindElementsByClassName("episode");

            foreach (var node in myTable)
            {
                var epcontrol = new EpisodeControl
                {
                    Text = node.Text.Trim(),
                    Tag  = node.GetAttribute("data-value")
                };
                if (StaticsClass.MyAnimeListObject != null)
                {
                    epcontrol.RateIcon.Click += RateIcon_Click;
                }
                else
                {
                    epcontrol.RateIcon.Visible = false;
                }
                EpisodesFlowPanel.Controls.Add(epcontrol);
                EpisodesFlowPanel.Controls.SetChildIndex(epcontrol, 0);
            }
            BringToFront();
        }
Beispiel #4
0
        /// <summary>
        /// select shoe size and add to cart
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="wait"></param>
        public void SelectShoeSize(PhantomJSDriver driver, WebDriverWait wait)
        {
            var SizeDropDown = driver.FindElementById("pdp_size_select");

            SizeDropDown.Click();

            wait.Until((_driver) => { return(ExpectedConditions.ElementIsVisible(By.ClassName("product_sizes_content"))); });

            var ShoeSize         = new List <IWebElement>(driver.FindElementsByTagName("a"));
            var SelectedShoeSize = ShoeSize.Find((ele) => { return(ele.GetAttribute("data-modelsize") == "11_0"); });//TODO Select from File
            var AddToCart        = new List <IWebElement>(driver.FindElementsByTagName("button")).Find((ele) => { return(ele.GetAttribute("title") == "Add To Cart"); });

            if (SelectedShoeSize != null)
            {
                //Add To cart
                SelectedShoeSize.Click();

                Thread.Sleep(TimeSpan.FromSeconds(2));

                AddToCart.Click();

                Console.WriteLine("Added to Cart! ");
            }
        }