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);
            }
        }
예제 #2
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();
        }
예제 #3
0
        public void IfEmailAddressIsNotValid_ShowValidationMessage()
        {
            using (var driver = new ChromeDriver())
            {
                driver.Navigate().GoToUrl("http://*****:*****@id='loginForm']/form/div[1]/div/span/span");
                Assert.AreEqual(0, loginErrorMessage1.Count);

                driver.FindElementByXPath("//*[@id='loginForm']/form/div[4]/div/input").Click();

                var loginErrorMessage = driver.FindElementByXPath("//*[@id='loginForm']/form/div[1]/div/span/span");

                Assert.True(loginErrorMessage.Displayed);
            }
        }
예제 #4
0
        public IWebElement findElement(TestStep ts)
        {
            IWebElement we    = null;
            String      xpath = ts.Xpath();

            if (ts.userXPath != null)
            {
                xpath = ts.userXPath;
            }
            if (ts.index > 0)
            {
                we = ch.FindElementsByXPath(xpath)[ts.index - 1];
            }
            else
            {
                we = ch.FindElementByXPath(xpath);
            }

            int y = we.Location.Y;

            String js = String.Format("window.scroll(0, {0})", y / 2);

            ((IJavaScriptExecutor)ch).ExecuteScript(js);
            return(we);
        }
예제 #5
0
파일: Program.cs 프로젝트: steelwolf180/BOS
        static void Main(string[] args)
        {
            //Declaration
                //l = phone numbers, quotation number, desc of the records, entity, submission date , submission time, name of user
                List<string> l = new List<string>();
                List<string> quotation = new List<string>();
                List<string> desc = new List<string>();
                List<string> entity = new List<string>();
                List<string> subDate = new List<string>();
                List<string> subTime = new List<string>();
                List<string> name = new List<string>();
                List<string> kw = new List<string>();
                Dictionary<string, string> dict = new Dictionary<string, string>();
                int numbrecords = 0;
                string filename = "";

                #region Load google chrome
                // Initialize the Chrome Driver
                using (var driver = new ChromeDriver())
                {
                    LoadFile(ref l, ref dict);

                    // Go to the home page
                    driver.Navigate().GoToUrl("http://www.gebiz.gov.sg/scripts/main.do?sourceLocation=openarea&select=tenderId");

                    #region autofill and extract data from GeBiz webpage
                    foreach (var val in l)
                    {
                        //Get the page elements

                        var fromdate = driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[2]/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr[5]/td[4]/input");
                        var todate = driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[2]/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr[5]/td[6]/input");
                        var keyword = driver.FindElementByName("searchByDesc");
                        new SelectElement(driver.FindElement(By.Name("dateType"))).SelectByIndex(1);
                        var submitbutton = driver.FindElementByName("submitAction");

                        fromdate.SendKeys(DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy"));
                        todate.SendKeys(DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy"));

                        keyword.SendKeys(val);

                        //click the submit button
                        submitbutton.Click();

                        if (driver.FindElements(By.XPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[2]/td")).Count == 1)
                        {
                            driver.Navigate().GoToUrl("http://www.gebiz.gov.sg/scripts/main.do?sourceLocation=openarea&select=tenderId");
                        }
                        else
                        {

                            if (driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[2]/td").Text.Equals("No data found"))
                            {
                                Console.WriteLine("No Data Found");
                                driver.Navigate().GoToUrl("http://www.gebiz.gov.sg/scripts/main.do?sourceLocation=openarea&select=tenderId");
                            }
                            else
                            {
                                #region Checking the number of records
                                for (int j = 11; j > 1; j--)
                                {
                                    //select the records by row
                                    if (driver.FindElements(By.XPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[" + j + "]")).Count == 1)
                                    {
                                        Console.WriteLine(driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[2]/td").Text);
                                        numbrecords = j + 1;
                                        #region Storing quotation and desc to list
                                        for (int i = 2; i < numbrecords; i++)
                                        {
                                            //get the record from the current row on the quotation col
                                            quotation.Add(driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[" + i + "]/td[2]/table/tbody/tr[1]/td/a/b").Text);
                                            //get the record from the current row on the description col
                                            desc.Add(driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[" + i + "]/td[3]/table/tbody/tr[1]/td").Text);
                                            //get the record from the current row on entity from description col
                                            entity.Add(RemoveWord(driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[" + i + "]/td[3]/table/tbody/tr[2]/td").Text));
                                            //get the record from the current row on submission date from closing date/time col
                                            subDate.Add(driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[" + i + "]/td[5]/table/tbody/tr[1]/td").Text);
                                            //get the record from the current row on submission time from closing date/time col
                                            subTime.Add(driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[" + i + "]/td[5]/table/tbody/tr[2]/td").Text);
                                            //add the name of the organisation that the keyword belong to
                                            name.Add(dict[val]);
                                            //add the keyword
                                            kw.Add(val);
                                        }
                                        driver.Navigate().GoToUrl("http://www.gebiz.gov.sg/scripts/main.do?sourceLocation=openarea&select=tenderId");
                                        break;
                                        #endregion
                                    }
                                }
                                #endregion
                            }
                        }
                    }
                    #endregion
                }
                #endregion
                //saving to excel file
                filename = SaveExcel();

                ExportData(filename, ref quotation, ref desc, ref entity, ref subDate, ref subTime, ref name, ref kw);
        }
예제 #6
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."); }
                    }
                }
            }
        }         //
예제 #7
0
 public void InputInfo(string path, string information, ChromeDriver driver)
 {
     driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));
     var Input = driver.FindElementByXPath(path);
     Input.SendKeys(information);
 }
예제 #8
0
 public void Button(string path, ChromeDriver driver)
 {
     var button = driver.FindElementByXPath(path);
     driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));
     button.Click();
 }