14 Kasım 2016 Pazartesi

c# selenium youtube

 var dir1 = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            //var dir = dir1 + "\\Default\\cookies";
            //File.Copy(yol, dir, true);

            //var chromedir = @"C:/Users/" + username + "/AppData/Local/Google/Chrome/User Data/";
            //copy(yol,dir);

            //MessageBox.Show(dir1);
            //Yeni.TopMost = true;

            ChromeOptions opt = new ChromeOptions();
            opt.AddArguments("--user-data-dir=" + dir1);
            var driver = new ChromeDriver(opt);



            driver.Navigate().GoToUrl("https://www.youtube.com/watch?v=YprmIsKN4XI&nohtml5=False");

            //driver.FindElement(By.ClassName("yt-uix-button-content")).Click();
            driver.FindElement(By.XPath("//span[contains(., \"Daha fazla\")]")).Click();

            //driver.FindElement(By.LinkText("Report")).Click();

            Thread.Sleep(5000);

            driver.FindElement(By.XPath("//span[contains(., \"Bildir\")]")).Click();
            Thread.Sleep(5000);

         
            driver.FindElement(By.XPath("//span[contains(., \"Cinsel içerik\")]")).Click();

            Thread.Sleep(5000);

            //driver.FindElement(By.XPath("//span[contains(., \"Birini seçin\")]")).Click();

            //Thread.Sleep(5000);
            //driver.FindElement(By.Id("id_dropdown_menu")).Click();

            //IWebElement sTag = driver.FindElement(By.Id("sel123"));
            //OpenQA.Selenium.Support.UI.SelectElement selectTag = new OpenQA.Selenium.Support.UI.SelectElement(sTag);
            //selectTag.SelectByValue("admin");
            //selectTag.SelectByIndex(3);

            driver.FindElement(By.ClassName("options-renderer-type-select")).FindElement(By.CssSelector("option[value='3']"));


            //driver.FindElement(By.XPath("//span[contains(., \"Müstehcen, ancak çıplaklık içermiyor\")]")).Click();

            Thread.Sleep(5000);


            driver.FindElement(By.XPath("//span[contains(., \"Gönder\")]")).Click();