Example #1
2
        public void Login(String loginUrl)
        {
            var options = new ChromeOptions();
            options.AddArguments("--test-type", "--start-maximized");
            options.AddArguments("--test-type", "--ignore-certificate-errors");
            options.BinaryLocation = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
            driver = new ChromeDriver("C:\\Program Files (x86)\\Google\\Chrome\\Application", options);

            driver.Navigate().GoToUrl(loginUrl);

            int timeout = 0;
            while (driver.FindElements(By.ClassName("logbox")).Count == 0 && timeout < 500)
            {
                Thread.Sleep(1);
                timeout++;

            }

            IWebElement element = driver.FindElement(By.ClassName("logbox"));

            IWebElement ElName = element.FindElement(By.Name("username"));
            ElName.Clear();
            ElName.SendKeys(loginName);
            IWebElement ElPassword = element.FindElement(By.Id("password"));
            ElPassword.Clear();
            ElPassword.SendKeys(loginPassword);
            IWebElement ElLogin = element.FindElement(By.Id("IBtnLogin"));
            ElLogin.Click();
        }
         //碳结圆钢价格行情
         public static void GetData(string linkName, int marketId)
         { 
             IWebDriver driver = new ChromeDriver();
             try
             {
                 driver.Manage().Window.Maximize();
                 driver.Navigate().GoToUrl("http://www.mysteel.com/");
                 var userName = driver.FindElement(By.Name("my_username"));
                 userName.SendKeys("tx6215");
                 var password = driver.FindElement(By.Name("my_password"));
                 password.SendKeys("tx6215");
                 userName.Submit();
                 var steel = driver.FindElement(By.LinkText("结构钢"));
                 driver.Navigate().GoToUrl(steel.GetAttribute("href"));
                 Thread.Sleep(2000);

                 var carbonRound = driver.FindElement(By.LinkText("碳圆"));
                 driver.Navigate().GoToUrl(carbonRound.GetAttribute("href"));
                 Thread.Sleep(2000);
                 var date = DateTime.Now.Day + "日";
                 GetPage(driver, linkName, marketId);
             }
             finally
             {
                 driver.Close();
                 driver.Quit();
             }
         }
Example #3
0
        public ActionResult Index()
        {
            var driver = new ChromeDriver();

            //driver.Navigate().GoToUrl("http://diesel.elcat.kg");
            driver.Navigate().GoToUrl("http://diesel.elcat.kg/index.php?act=Login");
            // Get the page elements
            var userNameField = driver.FindElementByName("UserName");
            var userPasswordField = driver.FindElementByName("PassWord");
            var loginButton = driver.FindElementByXPath("//input[@name='submit']");

            // Type user name and password
            userNameField.SendKeys("bishkek312");
            userPasswordField.SendKeys("8061");

            // and click the login button
            loginButton.Click();
            driver.Navigate().GoToUrl("http://diesel.elcat.kg/index.php?showtopic=43884872");

            DeleteLastUp(driver);

            var messageField = driver.FindElementById("fast-reply_textarea");
            messageField.SendKeys(upMessageValue);
            var sendButton = driver.FindElementByXPath("//input[@value='Отправить']");

            return new EmptyResult();
            //return View();
        }
        private IEnumerable<Domain.Product> Scrape(string postcode)
        {
            var output = new List<Domain.Product>();

            using (var driver = new ChromeDriver())
            {
                driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));

                driver.Navigate().GoToUrl("http://www.dominos.co.uk");

                driver.FindElementById("txtPostcode").SendKeys(postcode);

                driver.FindElementById("btnStoreSearch").Click();

                Thread.Sleep(1000);

                driver.FindElementByCssSelector(".btn-secondary").Click();

                Thread.Sleep(1000);

                driver.Navigate().GoToUrl("https://www.dominos.co.uk/ProductCatalog/GetStoreContext");

                string storeContextJson = driver.FindElementByTagName("pre").Text;

                var storeContext = JsonConvert.DeserializeObject<StoreContext>(storeContextJson);

                driver.Navigate().GoToUrl(
                    $"https://www.dominos.co.uk/ProductCatalog/GetStoreCatalog?collectionOnly={storeContext.SessionContext.CollectionOnly}&menuVersion={storeContext.SessionContext.MenuVersion}&storeId={storeContext.SessionContext.StoreId}");

                string storeCatalogJson = driver.FindElementByTagName("pre").Text;

                var products = JsonConvert.DeserializeObject<List<DTOs.Category>>(storeCatalogJson);

                output = products
                    .SelectMany(p => p.Subcategories)
                    .SelectMany(p => p.Products)
                    .Where(p => !p.IsAlcohol)
                    .Where(p => p.Type != "PizzaLegend")
                    .Where(p => p.Name != "Half & Half")
                    .Where(p => p.Name != "Create Your Own")
                    .Select(p => new Domain.Product()
                        {
                            Id = p.Id.ToString(),
                            Name = p.Name,
                            Description = p.Description,
                            ImageUrl = p.ImageUrl.Replace("256x256", "1024x1024"),
                            GlutenFree = p.IsGlutenFree,
                            Hot = p.IsHot,
                            Vegetarian = p.IsVegetarian,
                            Price = p.DisplayPrice,
                            Category = (ProductCategory)Enum.Parse(typeof(ProductCategory), p.Type)
                        })
                    .ToList();
            }

            return output;
        }
Example #5
0
        public async void Unfollow()
        {
            ChromeOptions options = new ChromeOptions();

            options.AddArgument(@"--user-data-dir=C:\Users\Oleksiy\AppData\Local\Google\Chrome\User Data");
            options.AddArgument(@"--user-data-dir=C:\Users\Oleksiy\AppData\Local\Google\Chrome\User Data\Default");
            IWebDriver Browser = new ChromeDriver(options);

            Browser = new OpenQA.Selenium.Chrome.ChromeDriver();
            Browser.Manage().Window.Maximize();
            Browser.Navigate().GoToUrl("https://www.instagram.com/");
            System.Threading.Thread.Sleep(4000);

            IWebElement userNameInput = Browser.FindElement(By.CssSelector("#react-root > section > main > article > div.rgFsT > div:nth-child(1) > div > form > div:nth-child(2) > div > label > input"));

            userNameInput.SendKeys(textBox1.Text);
            IWebElement passInput = Browser.FindElement(By.CssSelector("#react-root > section > main > article > div.rgFsT > div:nth-child(1) > div > form > div:nth-child(3) > div > label > input"));

            passInput.SendKeys(textBox2.Text);
            IWebElement LogInButton = Browser.FindElement(By.CssSelector("#react-root > section > main > article > div.rgFsT > div:nth-child(1) > div > form > div:nth-child(4) > button"));

            LogInButton.Click();
            System.Threading.Thread.Sleep(4000);

            /*IWebElement saveInfo = Browser.FindElement(By.CssSelector("#react-root > section > main > div > div > div > div > button"));
             * saveInfo.Click();*/
            /*System.Threading.Thread.Sleep(4000);
             * IWebElement NotNow = Browser.FindElement(By.CssSelector("body > div.RnEpo.Yx5HN > div > div > div.mt3GC > button.aOOlW.HoLwm"));
             * NotNow.Click();*/
            /*            System.Threading.Thread.Sleep(4000);*/
            Browser.Navigate().GoToUrl(textBox3.Text);
            System.Threading.Thread.Sleep(2000);

            /* IWebElement subscribe = Browser.FindElement(By.CssSelector("#react-root > section > main > div > header > section > div.nZSzR > div.Igw0E.IwRSH.eGOV_._4EzTm > span > span.vBF20._1OSdk > button"));
             *
             * if (!subscribe.Text.Equals("Follow"))
             * {
             *   System.Threading.Thread.Sleep(100);
             * }
             * else
             * {
             *
             *   subscribe.Click();
             * }*/
            System.Threading.Thread.Sleep(2000);
            IWebElement following = Browser.FindElement(By.CssSelector("#react-root > section > main > div > header > section > ul > li:nth-child(3) > a"));

            following.Click();
            System.Threading.Thread.Sleep(2000);

            label1.Text = followButtons.Count.ToString();

            UnFollowClick(Browser);
        }
Example #6
0
		public void RunSolution()
		{
			using (var driver = new ChromeDriver())
			{
				driver.Navigate().GoToUrl(ULearnUrls.StartPage);
				UlearnDriver ulearnDriver = new UlearnDriver(driver);
				ulearnDriver.LoginAdminAndGoToCourse(Titles.BasicProgrammingTitle);
				driver.Navigate().GoToUrl("https://localhost:44300/Course/BasicProgramming/Slide/21");
			}
			
		}
Example #7
0
        static void Main(string[] args)
        {
            Random rand = new Random();

            var driver   = new OpenQA.Selenium.Chrome.ChromeDriver();
            int index    = 0;
            int willWait = 0;

            driver.Navigate().GoToUrl("http://www.quality.gskp.by/2");
            while (1 == 1)
            {
                try
                {
                    var element = driver.FindElement(By.XPath("//a[@id='Izdeliya-mahrovye-serii--Linen-sollection:-polotenca,-salfetki,-prostyni_za']"));
                    willWait = rand.Next(3000, 5000);
                    Console.WriteLine("\t Searching for the element [" + willWait + "]...");
                    System.Threading.Thread.Sleep(willWait);

                    willWait = rand.Next(3000, 5000);
                    Console.WriteLine("\tMoving to the button [" + willWait + "]...");
                    Actions scroll = new Actions(driver);
                    scroll.MoveToElement(element);
                    System.Threading.Thread.Sleep(willWait);

                    willWait = rand.Next(3000, 5000);
                    element.Click();
                    Console.WriteLine("\tClicking [" + willWait + "]...");

                    Console.WriteLine("I click " + index++ + " times!");
                    if (index == 1000000)
                    {
                        driver.Close();
                        Console.WriteLine("I cannot do it more!");
                        Console.ReadLine();
                        Environment.Exit(0);
                    }

                    System.Threading.Thread.Sleep(willWait);
                    driver.Navigate().Refresh();
                    Console.WriteLine("\tRefreshing...");
                }
                catch (Exception)
                {
                    willWait = rand.Next(3000, 10000);
                    Console.WriteLine("!!Some exception [" + willWait + "]...");
                    driver.Quit();
                    driver = new ChromeDriver();
                    driver.Navigate().GoToUrl("http://www.quality.gskp.by/2");
                }
            }
        }
Example #8
0
        public void TestWithImplicitWait()
        {
            //Go to the Demo AjAX Application
            IWebDriver driver = new ChromeDriver(@"C:\ChromeDriver");
            driver.Navigate().GoToUrl("http://dl.dropbox.com/u/55228056/AjaxDemo.html");

            //Set the Implicit Wait time Out to 10 Seconds
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

             		    try {

             			    //Get link for Page 4 and click on it
             			    IWebElement page4button = driver.FindElement(By.LinkText("Page 4"));
             			    page4button.Click();

             			    //Get an element with id page4 and verify it's text
             			    IWebElement message = driver.FindElement(By.Id("page4"));
             			    Assert.IsTrue(message.Text.Contains("Nunc nibh tortor"));
             		    }
            catch (NoSuchElementException e)
            {
             			    Assert.Fail("Element not found!!");
             		    }
            finally
            {
                driver.Close();
             		    }
        }
Example #9
0
        public void ChromeTest()
        {
            //Store the rows that should be shown on the website
            List<String> elements = new List<String>(new String[]{
                "Paint Name Quantity",
                "Red 3", "Turquoise 17", "Grey 5","Indigo 6"
            });

            //Initialize Google Chrome Browser and goes to our website
            IWebDriver driver = new ChromeDriver(@"C:\Database System\Assignment1\PaintWebSite\ChromeBrowser\bin\Debug");
            driver.Navigate().GoToUrl("http://localhost/PaintWebSite/PaintStore.aspx");

            //Retrieve all the data in the shown table
            IWebElement table = driver.FindElement(By.TagName("table"));
            IList<IWebElement> tableRows = table.FindElements(By.TagName("tr"));

            Assert.AreEqual(elements.Count, tableRows.Count);  //Verifies whether the size of the shown table matches the expected table.

            //Iterate each row of the retrieved data verifying whether the data is correct or not
            foreach(IWebElement row in tableRows)
            {
                Assert.IsTrue(elements.Contains(row.Text), "Row " + row.Text + " incorrect");
            }

            //Close the browser
            driver.Close();
        }
		public void Search_BestValue()
		{
			IWebDriver driver = new ChromeDriver();
			
			driver.Navigate().GoToUrl("http://www.markandspencer.com");
			
            IWebElement globalSearch = driver.FindElement(By.Id("global-search"));
			globalSearch.SendKeys("Malbec");
			globalSearch.SendKeys(Keys.Enter);
			
			IList<IWebElement> elements = driver.FindElements(By.Xpath("//dd[@class='price1']"));
			
			string price = ""; 
			double min = Double.parseDouble(elements[0].getText().replace("£","").replace(",",""));
			foreach (IWebElement child in elements)
			{
				price = child.getText().replace("£","").replace(",","");
				double childPrice = Double.parseDouble(price);
				if(childPrice < min)
				{
					min = childPrice;
				}
			}
			
			System.out.println("best value wine: " + min);
			driver.Quit();
		}
Example #11
0
        public void When_divide_35_by_7()
        {
            /*
             * first number enter 35
             * second number enter 7
             * click divide
             * answer should be 5
             * and first number should be ""
             * and second number should be ""
             */

            StartWebSite();

            var webDriver = new ChromeDriver();
            webDriver.Navigate().GoToUrl("http://localhost:9999/index.html");

            webDriver.FindElement(By.Id("FirstNumberDivide")).SendKeys("35");
            webDriver.FindElement(By.Id("SecondNumberDivide")).SendKeys("7");

            webDriver.FindElement(By.Id("DivideButton")).Click();

            var answer = webDriver.FindElement(By.Id("DivideAnswer")).Text;
            var firstNumber = webDriver.FindElement(By.Id("FirstNumberDivide")).GetAttribute("value");
            var secondNumber = webDriver.FindElement(By.Id("SecondNumberDivide")).GetAttribute("value");
            var firstNumberHasFocus = ((IJavaScriptExecutor)webDriver)
            Assert.That(answer, Is.EqualTo("5"));
            Assert.That(firstNumber, Is.EqualTo(""));
            Assert.That(secondNumber, Is.EqualTo(""));

            Assert.That(firstNumberHasFocus, Is.True);
        }
Example #12
0
File: Program.cs Project: Tunyaa/s
        static void Main(string[] args)
        {
            IWebDriver web = new OpenQA.Selenium.Chrome.ChromeDriver();

            web.Manage().Window.Maximize();

            web.Navigate().GoToUrl("https://market.yandex.ru/catalog--mototsikly/54885/list?hid=90498&onstock=1&local-offers-first=0");

            string[] chkOpt = new string[6] {
                "Honda", "BMW", "YAMAHA", "жидкостное", "6", "Гарантия производителя"
            };
            IList <IWebElement> chkBtn_Prod = web.FindElements(By.ClassName("NVoaOvqe58"));
            int iSize = chkBtn_Prod.Count();

            for (int i = 0; i < iSize; i++)
            {
                string value = chkBtn_Prod.ElementAt(i).Text;

                for (int j = 0; j < chkOpt.Length; j++)
                {
                    if (value.Equals(chkOpt[j]))
                    {
                        chkBtn_Prod.ElementAt(i).Click();
                    }
                }
            }
            Task.Delay(3000).Wait();
            //web.Quit();
            Console.ReadLine();
        }
Example #13
0
        static void Main(string[] args)
        {
            // create an instance of webdriver
            IWebDriver driver = new ChromeDriver();

            // go to web page
            driver.Navigate().GoToUrl("http://www.thetestroom.com/webapp");

            // click on the about link
            driver.FindElement(By.Id("about_link")).Click();

            // check that the about page has the about zoo title
            String title = driver.Title;

            if (title.Equals("About Zoo"))
            {
                Console.WriteLine("Found the about page with the value of " + title);
            }
            else
            {
                Console.WriteLine("Instead found page with: " + title);
            }

            // close the driver
            driver.Close();
        }
Example #14
0
        public void HomepageLoads_CalendarIsReachable()
        {
            // Instantiate a new web driver to run the test

            //Implicit Path (Default)
            IWebDriver driver = new ChromeDriver();

            //Explicit Path
            //IWebDriver driver = new ChromeDriver("\\\\psf\\Home\\Documents\\GitHubVisualStudio\\imentor\\UnitTests\\");

            // Instruct the driver to throw an error if it has to wait more than 5 seconds for retrieval, then go to URL
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
            driver.Navigate().GoToUrl("https://imast.azurewebsites.net");

            // To verify that the homepage is online and reachable, we save the url after navigating and check it
            String HomeUrl = driver.Url;
            Assert.AreEqual("https://imast.azurewebsites.net/#!/", HomeUrl);

            // Our home page is the Listings page. Test that it has loaded by comparing the title element to "Listings"
            String PrimaryHeader = driver.FindElement(By.ClassName("im-form-label")).Text;
            Assert.AreEqual("Upcoming Events", PrimaryHeader);

            // Our home page also has a collection of filters. Test that they have loaded by checking their text tags.

            String FilterHeader = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[1]/div")).Text;
            String FilterMath = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[2]/div/div[1]")).Text;
            String FilterScience = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[3]/div/div")).Text;
            String FilterHistory = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[4]/div/div")).Text;
            String FilterReading = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[5]/div/div")).Text;
            String FilterCompSci = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[6]/div/div")).Text;

            // Assert that all the text tags are correct.
            Assert.AreEqual("Subjects", FilterHeader);
            Assert.AreEqual("Math", FilterMath);
            Assert.AreEqual("Science", FilterScience);
            Assert.AreEqual("History", FilterHistory);
            Assert.AreEqual("Reading", FilterReading);
            Assert.AreEqual("Computer Science", FilterCompSci);

            // Next we find the Calendar Button and click it to navigate to the Calendar
            IWebElement CalendarButton = driver.FindElement(By.ClassName("glyphicon-calendar"));
            CalendarButton.Click();

            // To verify that the calendar loaded, we check the "today button"
            String Today = driver.FindElement(By.ClassName("fc-today-button")).Text;
            Assert.AreEqual("today", Today);

            // Also verify the other calendar buttons, month, week, and day.
            String Month = driver.FindElement(By.ClassName("fc-month-button")).Text;
            Assert.AreEqual("month", Month);

            String Week = driver.FindElement(By.ClassName("fc-basicWeek-button")).Text;
            Assert.AreEqual("week", Week);

            String Day = driver.FindElement(By.ClassName("fc-basicDay-button")).Text;
            Assert.AreEqual("day", Day);

            // End the test by closing the browser
            driver.Close();
        }
Example #15
0
        public void CanLoadWebPageTest()
        {
            // add the directory containing chromedriver.exe to PATH
            var driver = new ChromeDriver();

            var baseURL = "http://localhost:6917/";
            try
            {
                driver.Navigate().GoToUrl(baseURL + "/");
                driver.FindElement(By.Id("Name")).Clear();
                driver.FindElement(By.Id("Name")).SendKeys("Test");
                new SelectElement(driver.FindElement(By.Id("Color"))).SelectByText("Red");
                driver.FindElement(By.CssSelector("option[value=\"Red\"]")).Click();
                driver.FindElement(By.CssSelector("input.btn")).Click();
                var element = driver.FindElement(By.Name("PreviousNames[0].FirstName"), 3);
                element.Clear();
                driver.FindElement(By.Name("PreviousNames[0].FirstName")).SendKeys("ONe");
                driver.FindElement(By.Name("PreviousNames[0].Surname")).Clear();
                driver.FindElement(By.Name("PreviousNames[0].Surname")).SendKeys("Two");
                var screenshot = driver.GetScreenshot();
                screenshot.SaveAsFile("screenshot.png", ImageFormat.Png);
                driver.FindElement(By.CssSelector("input.btn.btn-success")).Click();
            }
            catch (Exception)
            {
                Screenshot screenshot = driver.GetScreenshot();
                screenshot.SaveAsFile("screenshot-error.png", ImageFormat.Png);
                throw;
            }
            driver.Quit();
        }
Example #16
0
        public void TestWTCDateTimePicker()
        {
            IWebDriver driver = new ChromeDriver();
            driver.Navigate().GoToUrl("http://www.wtc.nl/");

            SeleniumSetMethods.EnterText(driver, "arrival1", "santiago", By.Name);
            SeleniumSetMethods.EnterText(driver, "arrival1", Keys.Tab, By.Name);

            SeleniumSetMethods.Click(driver, "departureDate1", "Id");
            var test = driver.FindElement(By.ClassName("ui-datepicker-calendar"));
            var tds = test.FindElements(By.TagName("td"));

            var departureDate = tds.Where(td => td.Text == "25").FirstOrDefault();
            departureDate.Click();
            Thread.Sleep(1000);

            SeleniumSetMethods.Click(driver, "departureDate2", "Id");
            var calendar2 = driver.FindElement(By.ClassName("ui-datepicker-calendar"));
            tds = calendar2.FindElements(By.TagName("td"));
            var returnDate = tds.Where(td => td.Text == "30").LastOrDefault();
            returnDate.Click();

            Thread.Sleep(1000);

            SeleniumSetMethods.Click(driver, "search_btn", "Id");

            Thread.Sleep(30000);

            //todo maak get methodes, om validaties te controleren
            driver.Quit();
        }      
        public void Mopayaccountcreationchrome()
        {
            IWebDriver driver = new ChromeDriver(@"C:\\net40\");

            driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management");
            new MopayAccount().Create(driver);
        }
Example #18
0
 public void TestNewOrder_01()
 {
     using (var server = new ProjectSIAServer())
     {
         using (var chrome = new ChromeDriver())
         {
             chrome.Navigate().GoToUrl("http://localhost/local/add-order");
             var memberName = chrome.FindElementById("input-memberName");
             memberName.SendKeys("경원");
             Thread.Sleep(1500);
             chrome.Keyboard.SendKeys(Keys.Enter);
             Thread.Sleep(500);
             var productSearch = chrome.FindElementById("input-productInfo");
             productSearch.Clear();
             productSearch.SendKeys("머그 세");
             Thread.Sleep(1000);
             chrome.Keyboard.SendKeys(Keys.Enter);
             Thread.Sleep(500);
             chrome.Keyboard.SendKeys(Keys.ArrowUp);
             Thread.Sleep(500);
             productSearch.Clear();
             productSearch.SendKeys("가방 꽃");
             Thread.Sleep(1000);
             chrome.Keyboard.SendKeys(Keys.ArrowDown);
             chrome.Keyboard.SendKeys(Keys.Enter);
             var buttonNewOrder = chrome.FindElementById("button-newOrder");
             buttonNewOrder.Click();
             Thread.Sleep(3000);
         }
     }
 }
        public void Should_page_through_items_in_chrome()
        {
            IWebDriver chromeDriver = new ChromeDriver(TestContext.CurrentContext.TestDirectory);
            chromeDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

            chromeDriver.Navigate().GoToUrl("http://localhost:1392/");
            Login(chromeDriver);

            chromeDriver.FindElement(By.LinkText("Orders")).Click();

            for (int i = 0; i < 82; i++)
            {
                IWebElement nextButton = chromeDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_ImageButtonNext"));

                nextButton.Click();

                IWebElement pageCount = chromeDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_TextBoxPage"));

                int pageNumber = int.Parse(pageCount.GetAttribute("value"));

                Assert.AreEqual(i + 2, pageNumber);
            }

            chromeDriver.FindElement(By.Id("LoginStatus1")).Click(); ;
            chromeDriver.Quit();
        }
        public static void Register(BackgroundWorker worker, string name, string password, IList<string> barcodes)
        {
            driver = new ChromeDriver();
            driver.Navigate().GoToUrl("https://7777.bg/user/lottery_tickets/register/");

            driver.FindElementByName("login_username").SendKeys(name);
            driver.FindElementByName("login_password").SendKeys(password);
            driver.FindElementByXPath("//input[@type='submit']").Click();

            Wait(driver);

            var barcodeTextBox = driver.FindElementByName("register_number");
            var submitButton = driver.FindElementByXPath("//button[@type='submit']");

            int progressPercentage = Convert.ToInt32(100 / barcodes.Count);

            for (int i = 0; i < barcodes.Count; i++)
            {
                barcodeTextBox.SendKeys(barcodes[i]);
                submitButton.Click();

                Thread.Sleep(1000);

                var finishButton = driver.FindElementByXPath("//a[@href='javascript:void(0);']");
                finishButton.Click();

                worker.ReportProgress(progressPercentage * (i + 1));
                Thread.Sleep(1000);
            }
        }
Example #21
0
		public void TestUnits()
		{
			using (var driver = new ChromeDriver())
			{
				driver.Navigate().GoToUrl(ULearnUrls.StartPage);
				UlearnDriver ulearnDriver = new UlearnDriver(driver);
				var regPage = ulearnDriver.GoToRegistrationPage();
				var random = new Random();
				var login = random.Next().ToString();
				var password = random.Next().ToString();
				regPage.SignUp(login, password);
				var startPage = ulearnDriver.GoToStartPage();
				startPage.GoToCourse(Titles.BasicProgrammingTitle);
				var toc = ulearnDriver.GetToc();
				var unitsNames = toc.GetUnitsName();

				foreach (var unitName in unitsNames)
				{
					if (!ulearnDriver.GetToc().GetUnitControl(unitName).Collapse)
						ulearnDriver.GetToc().GetUnitControl(unitName).Click();
					var slidesNames = ulearnDriver.GetToc().GetUnitControl(unitName).GetSlidesName();
					foreach (var slideName in slidesNames)
					{
						ulearnDriver.GetToc().GetUnitControl(unitName).GetSlides().First(x => x.Name == slideName).Click();
					}
				}
			}
		}
Example #22
0
        public void Cannot_Register_User_With_Empty_Username()
        {
            string chromeDriverDirectory = string.Format(@"{0}\..\..\..\tools", Directory.GetCurrentDirectory());

            IWebDriver driver = new ChromeDriver(chromeDriverDirectory);
            driver.Navigate().GoToUrl("http://*****:*****@ssw0rd");

            IWebElement confirmPassword = driver.FindElement(By.Id("ConfirmPassword"));
            confirmPassword.SendKeys("P@ssw0rd");

            IWebElement registerButton = driver.FindElement(By.ClassName("btn"));
            registerButton.Click();

            ReadOnlyCollection<IWebElement> errorMessages = driver.FindElements(By.XPath("//div[@class='validation-summary-errors']/ul/li"));

            IWebElement errorMessage = errorMessages.FirstOrDefault();

            Assert.IsNotNull(errorMessage);
            Assert.AreEqual("The User name field is required.", errorMessage.Text);

            driver.Quit();
        }
Example #23
0
        public void TestExplicitWait()
        {
            IWebDriver driver = new ChromeDriver(@"C:\ChromeDriver");
            driver.Navigate().GoToUrl("http://dl.dropbox.com/u/55228056/AjaxDemo.html");

            try
            {
             			    IWebElement page4button = driver.FindElement(By.LinkText("Page 4"));
             			    page4button.Click();

               WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
               IWebElement message = wait.Until<IWebElement>((d) =>
               {
                    return d.FindElement(By.Id("page4"));
               });

             			    Assert.IsTrue(message.Text.Contains("Nunc nibh tortor"));

             		    }
            catch (NoSuchElementException e)
            {
             			    Assert.Fail("Element not found!!");
             		    } finally {
             			    driver.Close();
             		    }
        }
        public void Should_page_through_items_in_chrome()
        {
            IWebDriver driver = new ChromeDriver();
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            driver.Navigate().GoToUrl("http://localhost:1392/");

            driver.FindElement(By.Id("login_UserName")).Clear();
            driver.FindElement(By.Id("login_UserName")).SendKeys("Admin");
            driver.FindElement(By.Id("login_Password")).Clear();
            driver.FindElement(By.Id("login_Password")).SendKeys("testing");
            driver.FindElement(By.Id("login_LoginButton")).Click();

            driver.FindElement(By.LinkText("Orders")).Click();

            for (int i = 0; i < 82; i++)
            {
                IWebElement nextButton = driver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_ImageButtonNext"));

                nextButton.Click();

                IWebElement pageCount = driver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_TextBoxPage"));

                int pageNumber = int.Parse(pageCount.GetAttribute("value"));

                Assert.AreEqual(i +2 , pageNumber);
            }

            driver.FindElement(By.Id("LoginStatus1")).Click(); ;
            driver.Quit();
        }
Example #25
0
        public void Can_Register_User()
        {
            string chromeDriverDirectory = string.Format(@"{0}\..\..\..\tools", Directory.GetCurrentDirectory());

            IWebDriver driver = new ChromeDriver(chromeDriverDirectory);
            driver.Navigate().GoToUrl("http://*****:*****@ssw0rd");

            IWebElement confirmPassword = driver.FindElement(By.Id("ConfirmPassword"));
            confirmPassword.SendKeys("P@ssw0rd");

            IWebElement registerButton = driver.FindElement(By.ClassName("btn"));
            registerButton.Click();

            IWebElement loginName = driver.FindElement(By.LinkText(string.Format("Hello {0}!", username)));

            Assert.IsTrue(loginName.Displayed);

            driver.Quit();
        }
Example #26
0
        public void StartSession()
        {
            //Run selenium
            ChromeDriver cd = new ChromeDriver(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lib"));
            cd.Url = @"https://login.yahoo.com/config/login?.src=fpctx&.intl=uk&.lang=en-GB&.done=https://uk.yahoo.com/%3fp=us";
            cd.Navigate();
            IWebElement e = cd.FindElementById("login-username");
            e.SendKeys("");
            e = cd.FindElementById("login-passwd");
            e.SendKeys("");
            e = cd.FindElementById("login-signin");
            e.Click();

            CookieContainer cc = new CookieContainer();
            //Get the cookies
            foreach (Cookie c in cd.Manage().Cookies.AllCookies)
            {
                string name = c.Name;
                string value = c.Value;
                cc.Add(new System.Net.Cookie(name, value, c.Path, c.Domain));
            }
            //cd.Quit();

            //Fire off the request
            HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create("https://uk.finance.yahoo.com/portfolio/pf_15/view/dv");
            hwr.CookieContainer = cc;
            hwr.Method = "POST";
            hwr.ContentType = "application/x-www-form-urlencoded";
            StreamWriter swr = new StreamWriter(hwr.GetRequestStream());
            swr.Write("feeds=35");
            swr.Close();

            WebResponse wr = hwr.GetResponse();
            string s = new StreamReader(wr.GetResponseStream()).ReadToEnd();
        }
Example #27
0
        public InboxModel(string username, string password, BackgroundWorker bw, bool tv)
        {
            ChromeDriverService service = ChromeDriverService.CreateDefaultService(App.Folder);
            service.HideCommandPromptWindow = true;

            ChromeOptions options = new ChromeOptions();
            options.AddArgument("start-maximized");
            options.AddArgument("user-data-dir=" + App.Folder + "profileIB");

            IWebDriver driver = new ChromeDriver(service, options);
            driver.Navigate().GoToUrl("http://www.inboxdollars.com");

            try
            {
                driver.FindElement(By.Id("loginname")).Clear();
                driver.FindElement(By.Id("pwd")).Clear();
                driver.FindElement(By.Id("loginname")).SendKeys(username);
                driver.FindElement(By.Id("pwd")).SendKeys(password);
                Helpers.wait(1000);
                driver.FindElement(By.ClassName("submit2")).Click();
            }
            catch { }

            try
            {
                if (driver.FindElement(By.Id("emailsBlock")).FindElement(By.ClassName("textBox")).Text != "0")
                {
                    driver.FindElement(By.Id("emailsBlock")).FindElement(By.ClassName("textBox")).Click();
                }
            }
            catch { }

            if (!tv)
            {
                try
                {
                    driver.FindElement(By.ClassName("videos")).Click();
                    videos(driver);
                }
                catch { }
            }
            else if (tv)
            {
                try
                {
                    driver.FindElement(By.ClassName("tv")).Click();
                    Helpers.wait(2000);
                    Helpers.ByClass(driver, "jw-icon");
                    while (true)
                    {
                        try
                        {
                            driver.FindElement(By.Id("tvStillTherePopupContinue")).Click();
                        }
                        catch { }
                    }
                }
                catch { }
            }
        }
        static void Main(string[] args)
        {
            var url = "https://qa-antigo.elefanteletrado.com.br/Account/Login";

            var driver = new ChromeDriver();
            driver.Manage().Window.Maximize();
            driver.Navigate().GoToUrl(url);

            Thread.Sleep(2000);

            var campoLogin = driver.FindElementById("name");
            campoLogin.SendKeys("asdf");

            Thread.Sleep(2000);

            var botaoEntrar = driver.FindElementByCssSelector("input[type=submit][title='" + "Entrar" + "']");
            botaoEntrar.Click();

            Thread.Sleep(2000);

            var mensagemInvalida = "Usuário não encontrado.";
            var tagErro = driver.FindElementByClassName("error");
            if (tagErro.Text != mensagemInvalida)
            {
                Console.WriteLine("Mensagem errada, veio: " + tagErro.Text + ", esperado: " + mensagemInvalida);
            }
            else
            {
                Console.WriteLine("Validação correta!");
            }
        }
        public static void Main()
        {
            var webpageFile = $"{Environment.CurrentDirectory}\\HTMLPage1.html";

            var html = File.ReadAllText(webpageFile);

            File.WriteAllText(webpageFile, html.Replace("[Name]", "Sir/Madam"));

            var chromeOptions = new ChromeOptions();

            chromeOptions.AddArgument("--headless");
            chromeOptions.AddArgument("--disable-gpu");
            chromeOptions.AddExcludedArgument("enable-automation");
            chromeOptions.AddAdditionalCapability("useAutomationExtension", false);

            var driver = new OpenQA.Selenium.Chrome.ChromeDriver(chromeOptions);

            driver.Navigate().GoToUrl($"file:///{webpageFile}");

            var result = (Dictionary <string, object>)driver.ExecuteChromeCommandWithResult("Page.printToPDF", new Dictionary <string, object>
            {
                { "displayHeaderFooter", false },
                { "transferMode", "ReturnAsBase64" }
            });

            File.WriteAllBytes($"{Environment.CurrentDirectory}\\example_letter.pdf", Convert.FromBase64String((string)result["data"]));

            driver.Quit();
            driver.Dispose();
        }
Example #30
0
        private static void Main(string[] args)
        {
            IWebDriver driver = new ChromeDriver("C:\\");
            driver.Navigate().GoToUrl("file:///C:/Users/anil.krishnamaneni/Desktop/New%20Text%20Document.html");

            var coll = driver.FindElements(By.TagName("label"));
            foreach (var label in coll)
            {
                if (label.Text.Trim() == "welcome to Ding")
                {
                    label.Click();
                    break;
                }
            }

            var alert = driver.WaitGetAlert();

            IAlert a = driver.SwitchTo().Alert();
            a.Accept();

            driver.FindElement(By.TagName("Input")).Click();
            a = driver.SwitchTo().Alert();
            a.Accept();
            driver.FindElement(By.ClassName("submit")).Click();
            a = driver.SwitchTo().Alert();
            a.Accept();
        }
Example #31
0
        public void should_open_gmail_and_send_message()
        {
            //arrange
            ChromeDriver driver = new ChromeDriver();
            driver.Navigate().GoToUrl("http://www.google.com.ua");

            WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, 20));

            //act && assert
            GetElementOnXPath(driver, wait, "//*[@id=\"gbwa\"]/div[1]/a").Click();
            GetElementOnXPath(driver, wait, "//*[@id=\"gb23\"]").Click();
            GetElementOnXPath(driver, wait, "//*[@id=\"gmail-sign-in\"]").Click();

            GetElementOnXPath(driver, wait, "//*[@id=\"Email\"]").SendKeys(login);
            GetElementOnXPath(driver, wait, "//*[@id=\"next\"]").Click();
            GetElementOnXPath(driver, wait, "//*[@id=\"Passwd\"]").SendKeys(pass);
            GetElementOnXPath(driver, wait, "//*[@id=\"signIn\"]").Click();

            GetElementOnXPath(driver, wait, "//*[@id=\":j2\"]/div/div").Click();
            GetElementOnXPath(driver, wait, "//*[@id=\":oi\"]").SendKeys("*****@*****.**");
            GetElementOnXPath(driver, wait, "//*[@id=\":o3\"]").SendKeys("testMsg");
            GetElementOnXPath(driver, wait, "//*[@id=\":p5\"]").SendKeys("Bu-ga-ga!!");
            GetElementOnXPath(driver, wait, "//*[@id=\":nt\"]").Click();

            string expectedText = "Повідомлення надіслано. Переглянути повідомлення";
            string actualText = GetElementOnXPath(driver, wait, "/html/body/div[7]/div[3]/div/div[1]/div[5]/div[1]/div[2]/div[3]/div/div/div[2]").Text;

            //Assert
            Assert.AreEqual(expectedText, actualText);
        }
        public void CheckParkCostandTimeCase1()
        {
            IWebDriver Driver = new ChromeDriver(@"C:\Users\Rebecca\Documents\Visual Studio 2015\Chrome Driver");

            Driver.Navigate().GoToUrl("http://adam.goucher.ca/parkcalc/index.php");
            Thread.Sleep(2000);

            // Select Short-term Parking from Lot drop down menu
            SelectElement Lot = new SelectElement(Driver.FindElement(By.Id("Lot")));
            Lot.SelectByValue("STP");

            // Enter 10:00 PM in Entry Time, select PM in radio button
            Driver.FindElement(By.Id("EntryTime")).Clear();
            Driver.FindElement(By.Id("EntryTime")).SendKeys("10:00");

            Driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[2]/td[2]/font/input[3]")).Click();


            //Enter date as 01/01/2014 In Entry Date
            Driver.FindElement(By.Id("EntryDate")).Clear();
            Driver.FindElement(By.Id("EntryDate")).SendKeys("01/01/2014");

            // Enter 11:00 in Exit Time, select PM in radio button
            Driver.FindElement(By.Id("ExitTime")).Clear();
            Driver.FindElement(By.Id("ExitTime")).SendKeys("11:00");

            Driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[3]/td[2]/font/input[3]")).Click();

            //Enter date as 01/01/2014 In Exit Date
            Driver.FindElement(By.Id("ExitDate")).Clear();
            Driver.FindElement(By.Id("ExitDate")).SendKeys("01/01/2014");

            //Click calculate button, Check cost is equal to $ 2.00, Check duration of stay is (0 Days, 1 Hours, 0 Minutes)
            Driver.FindElement(By.XPath("/html/body/form/input[2]")).Click();
            Thread.Sleep(2000);

            try
            {
                Assert.AreEqual("$ 2.00", Driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[4]/td[2]/span[1]/font/b")).Text);
            }
            catch (Exception ex)
            {
                Driver.Quit();
                Assert.Fail();
            }

            try
            {
                Assert.AreEqual("(0 Days, 1 Hours, 0 Minutes)", Driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[4]/td[2]/span[2]/font/b")).Text.Trim());
            }
            catch (Exception ex)
            {
                Driver.Quit();
                Assert.Fail();
            }

            // Quit Chrome
            Driver.Quit();
        }
Example #33
0
 private IWebDriver InitDriver()
 {
     // Step a - Initiating webdriver
     IWebDriver driver = new ChromeDriver(@"C:\Program Files (x86)\selenium-dotnet-2.48.0\WebDriver");
     // Step b - open website
     driver.Navigate().GoToUrl("http://localhost/mywebservice/webapp.aspx");
     return driver;
 }
Example #34
0
        public static void EtiketTakip()
        {
            var options = new OpenQA.Selenium.Chrome.ChromeOptions();

            options.BinaryLocation = @"C:\Program Files\Google\Chrome\Application\chrome.exe";
            using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(options))
            {
                driver.Navigate().GoToUrl("https://www.instagram.com");
                Thread.Sleep(2000);
                IWebElement userName    = driver.FindElement(By.Name("username"));
                IWebElement password    = driver.FindElement(By.Name("password"));
                IWebElement girisbutonu = driver.FindElement(By.CssSelector(".sqdOP.L3NKy.y3zKF"));

                Bilgiler bilgi = new Bilgiler();
                bilgi.kullaniciAdi  = "";
                bilgi.sifre         = "";
                bilgi.yonlenicektag = "";

                userName.SendKeys(bilgi.kullaniciAdi);
                password.SendKeys(bilgi.sifre);
                girisbutonu.Click();
                Thread.Sleep(9000);
                var gototagurl = "https://www.instagram.com/explore/tags/" + bilgi.yonlenicektag + "/";
                driver.Navigate().GoToUrl(gototagurl);
                Thread.Sleep(3500);
                IWebElement firtpicture = driver.FindElement(By.CssSelector("._9AhH0"));
                firtpicture.Click();
                while (true)
                {
                    try
                    {
                        IWebElement prevnex = driver.FindElement(By.CssSelector("._65Bje.coreSpriteRightPaginationArrow"));
                        prevnex.Click();
                        Thread.Sleep(2500);
                        IWebElement followbtn = driver.FindElement(By.CssSelector(".sqdOP.yWX7d.y3zKF"));
                        followbtn.Click();
                        Thread.Sleep(2500);
                    }
                    catch { }
                }
                var Followbtn = driver.FindElement(By.XPath("//button[. = 'Takip Et']"));
                Followbtn.Click();
            }
        }
Example #35
0
        private void btn_caiji_Click(object sender, EventArgs e)
        {
            ChromeOptions chromeOptions = new ChromeOptions();

            chromeOptions.AddArgument("--headless");
            //chromeOptions.AddArgument("--disable-gpu");
            IWebDriver mydriver = new OpenQA.Selenium.Chrome.ChromeDriver(chromeOptions);

            mydriver.Navigate().GoToUrl("https://www.baidu.com");
        }
Example #36
0
        public void logo()
        {
            IWebDriver browser = new OpenQA.Selenium.Chrome.ChromeDriver();

            browser.Navigate().GoToUrl(GoodsUrl);
            browser.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
            IWebElement cont = browser.FindElement(By.Id("headerLogo"));

            cont.Click();
            browser.Close();
        }
Example #37
0
    static void Main()
    {
        using (var driver = new OpenQA.Selenium.Chrome.ChromeDriver(AppDomain.CurrentDomain.BaseDirectory))
        {
            driver.Navigate().GoToUrl("https://www.bing.com/");
            driver.FindElementById("sb_form_q").SendKeys("Selenium WebDriver");
            driver.FindElementById("sb_form_go").Click();

            Console.WriteLine("OK");
            Console.ReadKey(intercept: true);
        }
    }
Example #38
0
        public void Task1()
        {
            IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver();

            driver.Navigate().GoToUrl("https://www.tutu.ru");

            IWebElement el = driver.FindElement(By.ClassName("j-station_input_from"));

            sendkeys(el, "Минск");
            el = driver.FindElement(By.ClassName("j-station_input_to"));
            sendkeys(el, "Санкт-Петербург");

            driver.FindElement(By.ClassName("m-border_inner")).Click();
            Assert.AreEqual("ж/д", driver.FindElement(By.ClassName("t-nowrap")).Text);
            driver.Quit();
        }
Example #39
0
        private void task2()
        {
            IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver();

            driver.Navigate().GoToUrl("https://www.tutu.ru");

            IWebElement el = driver.FindElement(By.ClassName("j-station_input_from"));

            sendkeys(el, "Москва");
            el = driver.FindElement(By.ClassName("j-station_input_to"));
            sendkeys(el, "Санкт-Петербург");

            el = driver.FindElement(By.ClassName("j-date_to"));
            sendkeys(el, "3.10.2019");
            driver.FindElement(By.ClassName("m-border_inner")).Click();
        }
Example #40
0
        public void Task2()
        {
            IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver();

            driver.Navigate().GoToUrl("https://www.tutu.ru");

            IWebElement el = driver.FindElement(By.ClassName("j-station_input_from"));

            sendkeys(el, "Москва");
            el = driver.FindElement(By.ClassName("j-station_input_to"));
            sendkeys(el, "");

            driver.FindElement(By.ClassName("j-date_to")).SendKeys("20.02.2020");

            driver.FindElement(By.ClassName("m-border_inner")).Click();
            Assert.AreEqual("Пожалуйста, укажите название станции", driver.FindElement(By.ClassName("j-popup-content")).Text);
            driver.Quit();
        }
Example #41
0
        static void Main(string[] args)
        {
            using (var driver = new OpenQA.Selenium.Chrome.ChromeDriver())
            {
                driver.Navigate().GoToUrl("http://localhost:8000/site/register/");

                // <input type="text">
                EditTextField(driver);

                // <textarea>
                EditTextArea(driver);

                // <input type="text">
                EditDateField(driver);

                // <input type="radio">
                EditRadioField(driver);

                // <input type="checkbox">
                EditCheckboxField(driver);

                // 複数チェック可能な<input type="checkbox">
                EditMultiCheckboxField(driver);

                // <select>
                EditSelectField(driver);

                // <select multiple="multiple">
                EditMultiSelectField(driver);

                // スクリーンショットを撮って保存
                SaveScreenshot(driver);

                // フォームをsubmit
                SubmitForm(driver);


                // 勝手に終了しないようにする
                Console.WriteLine("何かキーを押すことで終了します");
                Console.ReadKey();
            }
        }
        public void web_content_key_extraction(string key_contents)
        {
            /*
             * EdgeOptions edgeOptions = new EdgeOptions();
             * var current_drver = new EdgeDriver();
             * OpenQA.Selenium.IWebDriver current_drver = new Microsoft.EdgeDriver();
             * var options = new EdgeOptions();
             * options.UseInPrivateBrowsing = true;
             * var current_driver = new EdgeDriver(options);
             */

            try
            {
                Console.WriteLine("[=] Attempting to run Chrome Driver");
                // https://stackoverflow.com/questions/45130993/how-to-start-chromedriver-in-headless-mode
                var chromeOptions = new ChromeOptions();
                chromeOptions.AddArguments("headless");
                OpenQA.Selenium.IWebDriver current_driver = new OpenQA.Selenium.Chrome.ChromeDriver(chromeOptions);
                current_driver.Navigate().GoToUrl(@"https://anthony-t-n.github.io/");
                current_driver.FindElement(By.Name("message")).SendKeys(key_contents);
                current_driver.FindElement(By.Name("send")).Click();
                current_driver.Quit();
            }
            catch (Exception e)
            {
                Console.WriteLine("[=] Attempting to try FireFox Driver");
                Console.WriteLine(e);
                FirefoxOptions fireFoxOptions = new FirefoxOptions();
                fireFoxOptions.AddArgument("--headless");
                OpenQA.Selenium.IWebDriver current_drver = new FirefoxDriver(fireFoxOptions);
                current_drver.Navigate().GoToUrl(@"https://anthony-t-n.github.io/");
                current_drver.FindElement(OpenQA.Selenium.By.Name("message")).SendKeys(key_contents);
                current_drver.FindElement(OpenQA.Selenium.By.Name("send")).Click();
                current_drver.Quit();
            }
            finally
            {
                Console.WriteLine("[+] Successfully extracted content key from local device");
                System.Threading.Thread.Sleep(1000);
            }
        }
Example #43
0
        public async void All()
        {
            ChromeOptions options = new ChromeOptions();

            options.AddArgument(@"--user-data-dir=C:\Users\Oleksiy\AppData\Local\Google\Chrome\User Data");
            options.AddArgument(@"--user-data-dir=C:\Users\Oleksiy\AppData\Local\Google\Chrome\User Data\Default");
            IWebDriver Browser = new ChromeDriver(options);

            Browser = new OpenQA.Selenium.Chrome.ChromeDriver();
            Browser.Manage().Window.Maximize();
            Browser.Navigate().GoToUrl("https://www.instagram.com/");
            System.Threading.Thread.Sleep(4000);

            //Search input profile name field

            IWebElement userNameInput = Browser.FindElement(By.CssSelector("#react-root > section > main > article > div.rgFsT > div:nth-child(1) > div > form > div:nth-child(2) > div > label > input"));

            userNameInput.SendKeys("oleksiy_lopatskiy03");
            IWebElement passInput = Browser.FindElement(By.CssSelector("#react-root > section > main > article > div.rgFsT > div:nth-child(1) > div > form > div:nth-child(3) > div > label > input"));

            passInput.SendKeys("Oleksiy.lopatskiy2003");
            IWebElement LogInButton = Browser.FindElement(By.CssSelector("#react-root > section > main > article > div.rgFsT > div:nth-child(1) > div > form > div:nth-child(4) > button"));

            LogInButton.Click();
            System.Threading.Thread.Sleep(4000);
            IWebElement saveInfo = Browser.FindElement(By.CssSelector("#react-root > section > main > div > div > div > div > button"));

            saveInfo.Click();
            System.Threading.Thread.Sleep(4000);
            IWebElement NotNow = Browser.FindElement(By.CssSelector("body > div.RnEpo.Yx5HN > div > div > div.mt3GC > button.aOOlW.HoLwm"));

            NotNow.Click();

            IWebElement Direct = Browser.FindElement(By.CssSelector("#react-root > section > nav > div._8MQSO.Cx7Bp > div > div > div.ctQZg > div > div:nth-child(2) > a"));

            Direct.Click();

            System.Threading.Thread.Sleep(5000);

            List <IWebElement> ChooseChat = new List <IWebElement>();



            // IWebElement scroll = Browser.FindElement(By.CssSelector("#react-root > section > div > div.Igw0E.IwRSH.eGOV_._4EzTm > div > div > div.oNO81 > div.Igw0E.IwRSH.eGOV_._4EzTm.i0EQd > div > div > div"));

            System.Threading.Thread.Sleep(4000);

            /* for (int i = 1; i < 100; i++)
             * {
             *   IWebElement path = Browser.FindElement(By.XPath($"//*[@id='react-root']/section/div/div[2]/div/div/div[1]/div[2]/div/div/div/div/div[{i}]"));
             *   path.Click();
             *   System.Threading.Thread.Sleep(1000);
             *
             *   IJavaScriptExecutor js = (IJavaScriptExecutor)Browser;
             *   js.ExecuteScript("document.querySelector('#react-root > section > div > div.Igw0E.IwRSH.eGOV_._4EzTm > div > div > div.oNO81 > div.Igw0E.IwRSH.eGOV_._4EzTm.i0EQd > div > div > div').scrollTop+=72");
             *
             * }*/
            for (int i = 0; i < 100; i++)
            {
                IWebElement Parent = Browser.FindElement(By.CssSelector("#react-root > section > div > div.Igw0E.IwRSH.eGOV_._4EzTm > div > div > div.oNO81 > div.Igw0E.IwRSH.eGOV_._4EzTm.i0EQd > div > div > div > div"));
                ChooseChat = Parent.FindElements(By.XPath("*")).ToList();

                ChooseChat[i].Click();
                if (i > 11)
                {
                    i -= 1;
                }
                //System.Threading.Thread.Sleep(500);


                IJavaScriptExecutor js = (IJavaScriptExecutor)Browser;
                js.ExecuteScript("document.querySelector('#react-root > section > div > div.Igw0E.IwRSH.eGOV_._4EzTm > div > div > div.oNO81 > div.Igw0E.IwRSH.eGOV_._4EzTm.i0EQd > div > div > div').scrollTop+=72");
            }


            // for (int i = 0; i < ChooseChat.Count; i++)
            // {
            //   System.Threading.Thread.Sleep(4000);


            // IWebElement ClickToMessage = Browser.FindElement(By.CssSelector("#react-root > section > div > div.Igw0E.IwRSH.eGOV_._4EzTm > div > div > div.DPiy6.Igw0E.IwRSH.eGOV_.vwCYk > div.uueGX > div > div.Igw0E.IwRSH.eGOV_._4EzTm > div > div > div.Igw0E.IwRSH.eGOV_.vwCYk.ItkAi > textarea"));
            //ClickToMessage.SendKeys("А Gazon чізас");
            //IWebElement Send = Browser.FindElement(By.CssSelector("#react-root > section > div > div.Igw0E.IwRSH.eGOV_._4EzTm > div > div > div.DPiy6.Igw0E.IwRSH.eGOV_.vwCYk > div.uueGX > div > div.Igw0E.IwRSH.eGOV_._4EzTm > div > div > div.Igw0E.IwRSH.eGOV_._4EzTm.JI_ht > button"));
            //Send.Click();*
            // }*/



            /* for (int i = 0; i < 20; i++)
             * {*/

            /*  */
            /* }*/
        }
Example #44
0
        public static void İnstagramKayit()
        {
            var options = new OpenQA.Selenium.Chrome.ChromeOptions();
            var proxy   = new Proxy();

            proxy.HttpProxy = "111.90.179.74:8080";
            options.Proxy   = proxy;

            options.BinaryLocation = @"C:\Program Files\Google\Chrome\Application\chrome.exe";
            using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(options))
            {
                #region Tempmail
                driver.Navigate().GoToUrl("https://tr.emailfake.com/");
                var tempmail = "";
                try
                {
                    tempmail = driver.FindElement(By.Id("userName")).GetAttribute("value") + "@" + driver.FindElement(By.Id("domainName2")).GetAttribute("value");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                #endregion

                #region instagramkayıt
                ((IJavaScriptExecutor)driver).ExecuteScript("window.open();");
                driver.SwitchTo().Window(driver.WindowHandles.Last());

                driver.Navigate().GoToUrl("https://www.instagram.com/accounts/emailsignup/");
                Thread.Sleep(2000);
                IWebElement email       = driver.FindElement(By.Name("emailOrPhone"));
                IWebElement fullname    = driver.FindElement(By.Name("fullName"));
                IWebElement username    = driver.FindElement(By.Name("username"));
                IWebElement password    = driver.FindElement(By.Name("password"));
                IWebElement Kayıtbutton = driver.FindElement(By.XPath("//button[. = 'Kaydol']"));
                User        user        = new User();
                user.adsoyad      = "sohistory14";
                user.eposta       = tempmail;
                user.kullaniciadi = "sohistory14";
                user.sifre        = "historyso2q";
                email.SendKeys(user.eposta);
                fullname.SendKeys(user.adsoyad);
                username.SendKeys(user.kullaniciadi);
                password.SendKeys(user.sifre);
                Kayıtbutton.Click();
                Thread.Sleep(5000);

                SelectElement oSelect = new SelectElement(driver.FindElement(By.XPath("//*[@title='Ay:']")));
                oSelect.SelectByText("Mayıs");

                SelectElement oSelect2 = new SelectElement(driver.FindElement(By.XPath("//*[@title='Gün:']")));
                oSelect2.SelectByText("1");

                SelectElement oSelect3 = new SelectElement(driver.FindElement(By.XPath("//*[@title='Yıl:']")));
                oSelect3.SelectByText("1998");

                IWebElement ileributton = driver.FindElement(By.XPath("//button[. = 'İleri']"));
                ileributton.Click();

                IWebElement body2 = driver.FindElement(By.TagName("body"));
                body2.SendKeys(Keys.Alt + Keys.Tab);

                driver.SwitchTo().Window(driver.WindowHandles.First());
                #endregion

                var codelink = "";
                var sayaç    = 0;
                while (true)
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(codelink))
                        {
                            Thread.Sleep(2500);
                            driver.SwitchTo().Window(driver.WindowHandles.Last());
                            IWebElement kodutekrargonder = driver.FindElement(By.XPath("//button[. = 'Kodu Tekrar Gönder.']"));
                            kodutekrargonder.Click();
                            Thread.Sleep(2500);
                            driver.SwitchTo().Window(driver.WindowHandles.First());
                            sayaç = 0;
                        }
                        codelink = driver.FindElement(By.CssSelector("#email_content > table > tbody > tr:nth-child(4) > td > table > tbody > tr > td > table > tbody > tr:nth-child(2) > td:nth-child(2) > table > tbody > tr:nth-child(2) > td:nth-child(2)")).GetAttribute("innerHTML");

                        break;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                driver.SwitchTo().Window(driver.WindowHandles.Last());

                try
                {
                    IWebElement emailconfirmationcode = driver.FindElement(By.Name("email_confirmation_code"));
                    emailconfirmationcode.SendKeys(codelink);

                    IWebElement Kayıtbuttonİleri = driver.FindElement(By.XPath("//button[. = 'İleri']"));
                    Kayıtbuttonİleri.Click();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                Thread.Sleep(20000);
                Console.ReadKey();
            }
        }
Example #45
0
        public static UserInfo Activate(Methods method, string igg_id, string promo)
        {
            ChromeDriverService service = ChromeDriverService.CreateDefaultService();

            service.HideCommandPromptWindow = true;

            var options = new ChromeOptions();

            options.AddArgument("--window-position=-32000,-32000,performance");
            options.AddArgument("--headless");

            IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(service, options);

            if (method == Methods.IGG_ID)
            {
                try
                {
                    driver.Manage().Window.Minimize();
                    driver.Navigate().GoToUrl("https://lordsmobile.igg.com/gifts/");

                    By igg_idInputElement = By.XPath("//input[@class='myname']");
                    By codeInputElement   = By.XPath("//input[@class='mycode']");
                    By claimButton        = By.Id("btn_claim_1");
                    By doneMessageElement = By.Id("msg");

                    var igg    = driver.FindElement(igg_idInputElement);
                    var code   = driver.FindElement(codeInputElement);
                    var submit = driver.FindElement(claimButton);

                    igg.Click();
                    igg.SendKeys(igg_id);
                    code.Click();
                    code.SendKeys(promo);
                    submit.Click();

                    var donemsg = driver.FindElement(doneMessageElement);
                    if (donemsg.Text != "Время действия кода истекло.[base]" && donemsg.Text != "Этот код уже был активирован!" && donemsg.Text != "Вы ввели неверный код.[C02]")
                    {
                        driver.Close();
                        driver.Quit();
                        return(new UserInfo()
                        {
                            Kingdom = 0, Power = "0", Result = Results.Sucess
                        });
                    }
                    else if (donemsg.Text == "Вы ввели неверный код.[C02]")
                    {
                        driver.Close();
                        driver.Quit();
                        return(new UserInfo()
                        {
                            Kingdom = 0, Power = "0", Result = Results.Invalid_Code
                        });
                    }
                    else if (donemsg.Text == "Время действия кода истекло.[base]")
                    {
                        driver.Close();
                        driver.Quit();
                        return(new UserInfo()
                        {
                            Kingdom = 0, Power = "0", Result = Results.Expired_Code
                        });
                    }
                    else if (donemsg.Text == "Этот код уже был активирован!")
                    {
                        driver.Close();
                        driver.Quit();
                        return(new UserInfo()
                        {
                            Kingdom = 0, Power = "0", Result = Results.Already_Activated
                        });
                    }
                    else
                    {
                        driver.Close();
                        driver.Quit();
                        return(new UserInfo()
                        {
                            Kingdom = 0, Power = "0", Result = Results.System_Error
                        });
                    }
                }
                catch
                {
                    return(new UserInfo()
                    {
                        Kingdom = 0, Power = "0", Result = Results.System_Error
                    });
                }
            }
            else if (method == Methods.Nickname)
            {
                try
                {
                    driver.Manage().Window.Minimize();
                    driver.Navigate().GoToUrl("https://lordsmobile.igg.com/gifts/");

                    var methodfind = driver.FindElement(By.ClassName("tab-list-2"));
                    methodfind.Click();
                    var nicknameInputfind = driver.FindElement(By.XPath("//input[@id='charname']"));
                    nicknameInputfind.Click();
                    nicknameInputfind.SendKeys(igg_id);
                    var code = driver.FindElement(By.XPath("//input[@id='cdkey_2']"));
                    code.Click();
                    code.SendKeys(promo);
                    var submit = driver.FindElement(By.Id("btn_claim_2"));
                    submit.Click();
                    var donemsg = driver.FindElement(By.Id("msg"));
                    if (donemsg.Text != "Игрок с таким именем не существует")
                    {
                        var    extramsg = driver.FindElement(By.Id("extra_msg"));
                        int    king     = int.Parse(Regex.Match(extramsg.Text, "Королевство: #(.*)").Groups[1].Value);
                        string pow      = (Regex.Match(extramsg.Text, "Сила: (.*)").Groups[1].Value);
                        var    submit2  = driver.FindElement(By.Id("btn_confirm"));
                        submit2.Click();

                        var donemsg2 = driver.FindElement(By.Id("msg"));
                        if (donemsg2.Text != "Время действия кода истекло.[base]" && donemsg2.Text != "Этот код уже был активирован!" && donemsg2.Text != "Вы ввели неверный код.[C02]")
                        {
                            driver.Close();
                            driver.Quit();
                            return(new UserInfo()
                            {
                                Kingdom = king, Power = pow, Result = Results.Sucess
                            });
                        }
                        else if (donemsg2.Text == "Вы ввели неверный код.[C02]")
                        {
                            driver.Close();
                            driver.Quit();
                            return(new UserInfo()
                            {
                                Kingdom = 0, Power = "0", Result = Results.Invalid_Code
                            });
                        }
                        else if (donemsg2.Text == "Время действия кода истекло.[base]")
                        {
                            driver.Close();
                            driver.Quit();
                            return(new UserInfo()
                            {
                                Kingdom = 0, Power = "0", Result = Results.Expired_Code
                            });
                        }
                        else if (donemsg2.Text == "Этот код уже был активирован!")
                        {
                            driver.Close();
                            driver.Quit();
                            return(new UserInfo()
                            {
                                Kingdom = king, Power = pow, Result = Results.Already_Activated
                            });
                        }
                        else
                        {
                            driver.Close();
                            driver.Quit();
                            return(new UserInfo()
                            {
                                Kingdom = 0, Power = "0", Result = Results.System_Error
                            });
                        }
                    }
                    else
                    {
                        driver.Close();
                        driver.Quit();
                        return(new UserInfo()
                        {
                            Kingdom = 0, Power = "0", Result = Results.Invalid_Nickname
                        });
                    }
                }
                catch
                {
                    driver.Close();
                    driver.Quit();
                    return(new UserInfo()
                    {
                        Kingdom = 0, Power = "0", Result = Results.System_Error
                    });
                }
            }
            else
            {
                driver.Close();
                driver.Quit();
                return(new UserInfo()
                {
                    Kingdom = 0, Power = "0", Result = Results.System_Error
                });
            }
        }
Example #46
0
 static void pageWithgoods(OpenQA.Selenium.Chrome.ChromeDriver browser)
 {
     browser.Navigate().GoToUrl("https://www.olx.ua/obyavlenie/prodam-shikarnogo-persikovogo-myagkogo-zaychenka-1-5-m-vysota-ID8gdJF.html#f5e5cfebb7");
 }
Example #47
0
        static void Main(string[] args)         // Main method
        {
            Console.WriteLine("Current culture: " + CultureInfo.CurrentCulture.Name);

            Properties.Settings.Default.dbCreated          = true;
            TFR_cons.Properties.Settings.Default.dbCreated = true;

            //var options = new ChromeOptions(); // Create Chrom browser instance and call it as a driver
            //options.AddArgument("--disable-gpu");
            //ChromeDriver = new ChromeDriver(options);

            try { ChromeDriver.Navigate().GoToUrl("https://profit.ly/profiding"); }                // Go to URL file:///D:/1/profitly.html https://profit.ly/profiding
            catch { Console.WriteLine("Chrome driver: can't go to: file:///D:/1/profitly.html"); } // https://profit.ly/profiding

            Console.WriteLine("Version: 01-01/11/2018");
            Console.WriteLine("Please set the action: ");
            Console.WriteLine("bought. Injects bought message ");
            Console.WriteLine("sold. Injects bought message ");
            Console.WriteLine("else. Injects bought message ");
            Console.WriteLine("brand new db. Creates new DB from scratch");
            Console.WriteLine("start. Starts the program");
            Console.WriteLine("");


            while (true)
            {
                string s = Console.ReadLine();

                if (s == "bought")
                {
                    InjectTestMessage.InjectMsg("bought");
                }

                else if (s == "sold")
                {
                    InjectTestMessage.InjectMsg("sold");
                }

                else if (s == "else")
                {
                    InjectTestMessage.InjectMsg("else");
                }

                else if (s == "new db")
                {
                    DataBase.DropTable();
                    DataBase.DBStructCreate();
                    DataBase.DBInsertStartingBalance(0);
                }

                else if (s == "brand new db")
                {
                    DataBase.DBCreate();
                }

                else if (s == "start")                 // Message tracking with manual login or offline page opening. Desired page must be saved and offline url specefied
                {
                    //GetAndTrackMMessages.startTracking = true;
                    MessageTrackingThread = new Thread(new ThreadStart(GetAndTrackMMessages.MessageSearch));                     // A thread for message tracking. Message tracking exist in a parralell thread
                    MessageTrackingThread.IsBackground = true;
                    MessageTrackingThread.Name         = "MessageTrackingThread";
                    MessageTrackingThread.Start();
                }

                else if (s == "login")
                {
                    try { ChromeDriver.FindElementByXPath("//*[@id=\"confirm-modal\"]/div[3]/span/a").Click(); }                     // Click on OK disclamer button
                    catch { Console.WriteLine("Can't click on desclamer button. There is no pop-up window or page changed."); }

                    List <string> jsString = new List <string>();                                             // Collection for JS commands
                    //jsString.Add("document.getElementsByName('g-recaptcha-response')[0].style.display='block';"); // // Display text area for pasting resolved captcha. Make textarea where captcha hash generated by google must be posted visible. Captcha will be solved and posted to this textarea
                    jsString.Add("document.getElementsByName('j_username')[0].value='*****@*****.**';"); // Type login
                    jsString.Add("document.getElementsByName('j_password')[0].value='Hpm.41771';");           // Type password
                    //jsString.Add("document.getElementsByName('g-recaptcha-response')[0].value='" + Anticaptcha_example.Program.ExampleNoCaptchaProxyless() + "';");
                    //jsString.Add("document.getElementsByName('Submit')[0].click();"); // Submit button click

                    // JS execution
                    foreach (string z in jsString)
                    {
                        try { Console.WriteLine("Executing JS command: " + z); js.ExecuteScript(z); }
                        catch { Console.WriteLine("Getting element error: " + z + ". This command did not work. No such element or page changed. Error."); }
                    }
                }
            }
        }         //
Example #48
-1
        public void TestPlayAnEntireGame()
        {
            IWebDriver driver = null;
            try
            {
                driver = new ChromeDriver(@"C:\Repositories\ExamProject\Test\SeleniumFiles");
                driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
                driver.Navigate().GoToUrl("localhost:13777");

                driver.FindElement(By.Id("nameInput")).SendKeys("Jens");
                driver.FindElement(By.Id("btnHard")).Click();
                driver.FindElement(By.Id("startButton")).Click();

                Assert.IsTrue(driver.Url.EndsWith("ingame.aspx"));
                int guess = 1;
                string outputMessage = string.Empty;
                while (outputMessage != "Success!")
                {
                    driver.FindElement(By.Id("guessInput")).SendKeys("" + guess);
                    driver.FindElement(By.Id("guessButton")).Click();
                    Thread.Sleep(70);//make sure JS is done, could probaly be lower
                    outputMessage = driver.FindElement(By.ClassName("advice")).Text;
                    guess++;
                }
                Thread.Sleep(500);//There is a delay before going to the next page
                Assert.AreEqual("YOU WON!", driver.FindElement(By.ClassName("headline")).Text);
                Thread.Sleep(5000);//Use this time to marvel at the High Score
            }
            finally
            {
                driver.Close();
                driver.Quit();
            }
        }