Esempio n. 1
0
        public void Click_AfterMouseUpAndMouseDownEvents_ExpectedJavascriptHandlerRun()
        {
            browser.TestLoadHtml(
                @"<input type=""text"" id=""txtbox"" value=""text"" onmousedown=""this.value = 'mousedowned';"" onmouseup=""this.value = 'mouseuped';"" onclick=""this.value = 'clicked';""/>");

            GeckoInputElement element = (GeckoInputElement)browser.Document.GetHtmlElementById("txtbox");


            DomEventArgs ev       = browser.Document.CreateEvent("MouseEvent");
            var          webEvent = new Event(browser.Window.DomWindow, ev.DomEvent as nsISupports);

            webEvent.InitEvent("mousedown", true, true);
            element.GetEventTarget().DispatchEvent(ev);

            Assert.AreEqual("mousedowned", element.Value);

            webEvent.InitEvent("mouseup", true, true);
            element.GetEventTarget().DispatchEvent(ev);

            Assert.AreEqual("mouseuped", element.Value);

            element.Click();

            Assert.AreEqual("clicked", element.Value);
        }
Esempio n. 2
0
        private void Login()
        {
            GeckoInputElement  username = null;
            GeckoInputElement  password = null;
            GeckoButtonElement signIn   = null;

            if (Browser.Document.GetElementsByName("username").Count() > 0)
            {
                username = Browser.Document.GetElementsByName("username")[0] as GeckoInputElement;
            }
            if (Browser.Document.GetElementsByName("password").Count() > 0)
            {
                password = Browser.Document.GetElementsByName("password")[0] as GeckoInputElement;
            }
            if (Browser.Document.GetElementsByClassName("styles__SignInButton-dSRDTk").Count() > 0)
            {
                signIn = Browser.Document.GetElementsByClassName("styles__SignInButton-dSRDTk")[0] as GeckoButtonElement;
            }

            if (username != null && password != null && signIn != null)
            {
                Browser.Focus();

                username.Click();
                username.Focus();
                username.Value = txt_Username.Text;
                password.Click();
                password.Focus();
                password.Value = txt_Password.Text;
                SendKeys.SendWait("\t");
                SendKeys.SendWait("\n");
            }
        }
Esempio n. 3
0
        void web_DienMatKhau(object sender, Gecko.Events.GeckoDocumentCompletedEventArgs e)
        {
            btnLogin.Enabled = true;
            try
            {
                web1.DocumentCompleted -= web_DienMatKhau;

                var _input_Email = web1.Document.GetElementsByName("txtLoginId")[0];
                _input_Email.SetAttribute("value", txtUsename.Text);

                var _input_Pass = web1.Document.GetElementsByName("txtPassword")[0];
                _input_Pass.SetAttribute("value", txtPass.Text);

                GeckoInputElement enter = (GeckoInputElement)web1.Document.GetElementsByTagName("INPUT")
                                          .First(inp => ((GeckoInputElement)inp).Value == "Đăng nhập");
                enter.Click();
                web1.DocumentCompleted += new EventHandler <Gecko.Events.GeckoDocumentCompletedEventArgs>(web_DangNhapThanhCong);

                var uri = new Uri(URL_LOGIN);
                //often cookies are stored on domain level, so ".google.com", not "www.google.com" (leading dot is important)
                string host    = uri.Host.Replace("www", "");
                var    cookies = CookieManager.GetCookiesFromHost(host);


                while (cookies.MoveNext())
                {
                    var c = cookies.Current;
                    cookiesText += c.Name + "=" + c.Value + ";";
                }
            }
            catch (Exception)
            {
                web1.Navigate(URL_LOGIN);
            }
        }
Esempio n. 4
0
        public void SelectionEnd_NoSelection_ReturnsZero()
        {
            browser.TestLoadHtml(@"<input type=""text"" id=""txtbox"" value=""text""/>");

            GeckoInputElement element = (GeckoInputElement)browser.Document.GetHtmlElementById("txtbox");

            Assert.AreEqual(0, element.SelectionEnd);
        }
Esempio n. 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            GeckoInputElement Username = new GeckoInputElement(geckoWebBrowser1.Document.GetElementsByName("login")[0].DomObject);

            Username.Value = textBox1.Text;
            GeckoInputElement Password = new GeckoInputElement(geckoWebBrowser1.Document.GetElementsByName("password")[0].DomObject);

            Password.Value = textBox2.Text;
        }
Esempio n. 6
0
 void timer_Tick(object sender, EventArgs e)
 {
     if (execute)
     {
         var dnschangebutton = new GeckoInputElement(browser.Document.GetElementsByClassName("smallBtn primaryColor")[1].DomObject);
         dnschangebutton.Click();
         lst_logs.Items.Add("dns changed...");
         execute = false;
     }
 }
Esempio n. 7
0
        void login()
        {
            //webBrowser1.ScriptErrorsSuppressed = true;
            //Website öffnen
            //webBrowser1.Navigate(new Uri(link));

            browser.DocumentCompleted += OnDocumentCompleted;
            if (pageloaded)
            {
                pageloaded = false;
                detectpage();
                if (pagenumber == 1)//loginpage
                {
                    lst_logs.Items.Add("page loaded - ready");

                    /*if (cb_remember.Checked)
                     * {
                     *  var browser_login_rememberme = new GeckoInputElement(browser.Document.GetElementById("rememberMe").DomObject);
                     *  browser_login_rememberme.Click();
                     *  lst_logs.Items.Add("remember me checked");
                     * }*/
                    var browser_login_id = new GeckoInputElement(browser.Document.GetElementById("username").DomObject);
                    //new GeckoInputElement(browser.Document.GetElementsByName("username")[0].DomObject).Value = email;
                    browser_login_id.Value = email;
                    lst_logs.Items.Add("entered login");

                    var browser_login_pw = new GeckoInputElement(browser.Document.GetElementById("password").DomObject);
                    browser_login_pw.Value = password;
                    lst_logs.Items.Add("entered password");

                    var buttonAnmelden = new GeckoInputElement(browser.Document.GetElementsByClassName("largeBtn primaryColor pullRight")[0].DomObject);
                    buttonAnmelden.Click();
                    lst_logs.Items.Add("Logging in...");
                }
                else
                {
                    if (pagenumber == 2 && loggedin)//dns-managment
                    {
                        update();
                    }
                    else
                    {
                        lst_logs.Items.Add("exception pagenumber unknown:" + pagenumber);
                    }
                }
            }
            else
            {
                browser.Navigate(website);
                lst_logs.Items.Add("page not loaded");
            }
        }
Esempio n. 8
0
        void browser_DocumentCompleted(object sender, System.EventArgs e)
        {
            //unsubscribe
            _browser.DocumentCompleted -= browser_DocumentCompleted;

            XPathResult xpathResult = _browser.Document.EvaluateXPath("//div/input");
            var         foundNodes  = xpathResult.GetNodes();

            foreach (var node in foundNodes)
            {
                GeckoInputElement txtbox = new GeckoInputElement(node.DomObject);
                txtbox.Value = "Mona Lisa";     //add the search term
            }
            (_browser.Document.GetElementsByTagName("form").First() as GeckoFormElement).submit();
        }
Esempio n. 9
0
        private void SearchNext()
        {
            if (queuedSearches.Count == 0)
            {
                ExportToExcel();
                MessageBox.Show("Search Completed! Data Exported to Selected Location.", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                currentSearch++;
                UpdateSearchStatus();

                string strKeyword = queuedSearches[0].Split(':')[0];
                string strCountry = queuedSearches[0].Split(':')[1];

                if (!string.IsNullOrEmpty(strKeyword) && !string.IsNullOrEmpty(strCountry))
                {
                    Log.Information("Searching for Keyword '{0}' in Country '{1}'", strKeyword, strCountry);

                    lbl_Search_Keyword.Text = strKeyword;
                    lbl_Search_Country.Text = strCountry;
                    currentCountry          = strCountry;

                    GeckoInputElement keyword = (GeckoInputElement)Browser.Document.GetElementById("memberKeywords");
                    GeckoHtmlElement  country = (GeckoHtmlElement)Browser.Document.GetElementById("memberIdCountry");
                    GeckoHtmlElement  submit  = (GeckoHtmlElement)Browser.Document.GetElementById("searchConnections");

                    keyword.Click();
                    keyword.Focus();
                    keyword.Value = strKeyword;

                    this.Focus();
                    Browser.Focus();
                    country.Focus();
                    SendKeys.SendWait(strCountry);

                    submit.Focus();
                    submit.Click();
                }

                queuedSearches.RemoveAt(0);
            }
        }
Esempio n. 10
0
        void webBrowser1_DocumentCompleted(object sender, Gecko.Events.GeckoDocumentCompletedEventArgs e)
        {
            if (e.Uri == null)
            {
                return;
            }
            if (e.Uri.ToString().IndexOf("login.html") != -1)
            {
                GeckoDocument doc = webBrowser1.Document;

                /*GeckoInputElement element = doc.GetElementsByName("nosave_Username").Single() as GeckoInputElement;
                 * element.Value = "admin";*/
                GeckoInputElement element = doc.GetElementById("id_nosave_Password") as GeckoInputElement;
                if (element != null)
                {
                    element.Value = "password";
                    element       = doc.GetElementById("id_login") as GeckoInputElement;
                    element.Click();
                }
            }
            if (e.Uri.ToString().IndexOf("index_pc.html") != -1)
            {
                webBrowser1.Navigate("http://192.168.0.7/init.html");
            }
            if (e.Uri.ToString().IndexOf("init.html") != -1)
            {
                GeckoDocument     doc     = webBrowser1.Document;
                GeckoInputElement element = doc.GetElementById("id_rebootBtn") as GeckoInputElement;
                if (element != null)
                {
                    element.Click();
                    Timer timer = new Timer();
                    timer.Interval = 1000 * 60;
                    timer.Tick    += (s, a) =>
                    {
                        this.Close();
                    };
                    timer.Enabled = true;
                }
            }
        }
Esempio n. 11
0
        void update()
        {
            browser.DocumentCompleted += OnDocumentCompleted;
            detectpage();
            if (pagenumber == 2)//loginpage
            {
                string[] formdata = { "records[0][name]", "records[0][value]", "records[1][name]", "records[1][value]" };
                string[] postdata = { subdomain0, ip0, subdomain1, ip1 };

                var browser_entry_subdomain0 = new GeckoInputElement(browser.Document.GetElementsByName(formdata[0])[0].DomObject);
                browser_entry_subdomain0.Value = postdata[0];
                lst_logs.Items.Add("subdomain0 entered");

                var browser_entry_ip0 = new GeckoInputElement(browser.Document.GetElementsByName(formdata[1])[0].DomObject);
                browser_entry_ip0.Value = postdata[1];
                lst_logs.Items.Add("ip0 entered");

                var browser_entry_subdomain1 = new GeckoInputElement(browser.Document.GetElementsByName(formdata[2])[0].DomObject);
                browser_entry_subdomain1.Value = postdata[2];
                lst_logs.Items.Add("subdomain1 entered");

                var browser_entry_ip1 = new GeckoInputElement(browser.Document.GetElementsByName(formdata[3])[0].DomObject);
                browser_entry_ip1.Value = postdata[3];
                lst_logs.Items.Add("ip1 entered");

                System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
                //to stop The Timer: t.Stop();
                t.Interval = 2000; // specify interval time as you want
                t.Tick    += new EventHandler(timer_Tick);
                t.Start();
                if (execute == false)
                {
                    t.Stop();
                    execute = true;
                }
            }
        }
Esempio n. 12
0
        public override int LogIn()
        {
            Navigate_Client(login_path);
            string body = Document.Body.InnerHtml;

            GeckoInputElement username_TextBox = new GeckoInputElement(Document.GetElementById("username").DomObject);

            username_TextBox.Value = "piotex";
            GeckoInputElement pwd_TextBox = new GeckoInputElement(Document.GetElementById("password").DomObject);

            pwd_TextBox.Value = "start12345";

            IsCompleted();

            GeckoButtonElement button = new GeckoButtonElement(Document.GetElementsByClassName("sbutton large")[0].DomObject);

            if (button != null)
            {
                button.Click();
            }

            MessageBox.Show("Loaded");
            return(1);
        }
Esempio n. 13
0
        private void button_Load_Webpage_Click(object sender, EventArgs e)
        {
            //if (Cith_Label.Text.Trim() == String.Empty || Title_textBox1.Text.Trim() == String.Empty || Desc_textBox2.Text.Trim() == String.Empty || Name_textBox1.Text.Trim() == String.Empty || Email_textBox2.Text.Trim() == String.Empty || Mobile_textBox1.Text.Trim() == String.Empty)
            //{
            //    MessageBox.Show("All fields are required!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //}
            //else
            //{

            try
            {
                //Declare the Excel Application
                Excel.Application xlApp;
                Excel.Workbook    xlWorkBook;
                Excel.Worksheet   xlWorkSheet;
                Excel.Range       range;

                int rCnt = 0;

                xlApp       = new Excel.Application();
                xlWorkBook  = xlApp.Workbooks.Open(pathinfo, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                range       = xlWorkSheet.UsedRange;

                for (rCnt = 1; rCnt <= range.Rows.Count; rCnt++)
                {
                    excelcellpath = (string)(range.Cells[rCnt, 1] as Excel.Range).Value;
                    string url1 = "http://";
                    string url2 = ".quikr.com/post-classifieds-ads/";
                    string url  = String.Concat(url1 + excelcellpath.ToLower() + url2);

                    geckoWebBrowser1.Navigate(url);

                    while (geckoWebBrowser1.IsBusy)
                    {
                        Application.DoEvents();
                    }

                    HtmlWeb hw = new HtmlWeb();
                    HtmlAgilityPack.HtmlDocument doc = hw.Load(url);
                    HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[@title='Services'] //div //ul //li[@title='Business Offers'] //a");

                    string imgSrc = node.Attributes["onclick"].Value;
                    var    result = imgSrc.Substring(imgSrc.LastIndexOf('=') + 1);
                    var    number = result.Replace(@"'", "");

                    string uri = String.Concat(url + "?postadcategoryid=" + number);

                    geckoWebBrowser1.Navigate(uri);

                    while (geckoWebBrowser1.IsBusy)
                    {
                        Application.DoEvents();
                    }

                    HtmlWeb hwcity = new HtmlWeb();
                    HtmlAgilityPack.HtmlDocument city = hwcity.Load(uri);
                    HtmlNode nodecity   = city.DocumentNode.SelectSingleNode("//div[@class='formfield'] //div //div[@class='customSingleSelLoc_cont'] //span[1]");
                    string   imgSrccity = nodecity.Attributes["locname"].Value;

                    //string title = Title_textBox1.Text;
                    //string contactname = Name_textBox1.Text;
                    //string emailid = Email_textBox2.Text;
                    //string mobile = Mobile_textBox1.Text;
                    //string textarea = Desc_textBox2.Text;

                    string title       = "Non Voice Projects from Direct MNC Signup";
                    string contactname = "Mohan";
                    string emailid     = "*****@*****.**";
                    string mobile      = "7418832519";
                    string textarea    = "We Provide Genuine Projects which pay high amount and you can get better benefit. We are dealing in Voice, Non Voice, Inbound, Outbound, and Government - Non Government Projects, Online & Offline Processes with Legal Procedure. We also Provide Direct end-client Contact details as an Outsourcing Service Provider company. You have to pay just nominal Security Deposit.Currently we have more than 15 Processes to outsource and Direct MNC sign up. We update our site weekly basis and as per status of process vailability. Interested companies send their company profiles to [email protected] / Skype id: mohanskype43(Mohan)";

                    geckoWebBrowser1.Document.GetElementById("title").SetAttribute("value", title);
                    geckoWebBrowser1.Document.GetElementById("adlocality").SetAttribute("value", imgSrccity);
                    geckoWebBrowser1.Document.GetElementById("contactName").SetAttribute("value", contactname);
                    geckoWebBrowser1.Document.GetElementById("emailid").SetAttribute("value", emailid);
                    geckoWebBrowser1.Document.GetElementById("mobile").SetAttribute("value", mobile);
                    geckoWebBrowser1.Document.GetElementsByTagName("textarea")[0].InnerHtml = textarea;

                    GeckoInputElement checkbox = new GeckoInputElement(geckoWebBrowser1.Document.GetElementsByName("usrprivacypostad")[0].DomObject);
                    checkbox.Click();

                    try
                    {
                        while (geckoWebBrowser1.IsBusy)
                        {
                            Application.DoEvents();
                        }

                        GeckoElementCollection newadpost = geckoWebBrowser1.Document.GetElementsByTagName("button");
                        foreach (GeckoElement currentTag in newadpost)
                        {
                            if (currentTag.GetAttribute("onclick") == "quikrNewPostAd()")
                            {
                                ((GeckoHtmlElement)currentTag).Click();
                            }
                        }
                        while (geckoWebBrowser1.IsBusy)
                        {
                            Application.DoEvents();
                        }
                    }
                    catch (Exception)
                    {
                        while (!geckoWebBrowser1.IsBusy)
                        {
                            Application.DoEvents();
                        }
                        while (geckoWebBrowser1.IsBusy)
                        {
                            Application.DoEvents();
                        }
                    }

                    try
                    {
                        while (geckoWebBrowser1.IsBusy)
                        {
                            Application.DoEvents();
                        }

                        string nowurl = geckoWebBrowser1.Url.ToString();
                        if (uri == nowurl.ToString())
                        {
                            GeckoElementCollection photoskip = geckoWebBrowser1.Document.GetElementsByTagName("a");
                            foreach (GeckoElement phototag in photoskip)
                            {
                                if (phototag.GetAttribute("class") == "submit grey")
                                {
                                    ((GeckoHtmlElement)phototag).Click();
                                }
                            }

                            while (!geckoWebBrowser1.IsBusy)
                            {
                                Application.DoEvents();
                            }
                            while (geckoWebBrowser1.IsBusy)
                            {
                                Application.DoEvents();
                            }

                            string  latesturl  = geckoWebBrowser1.Url.ToString();
                            HtmlWeb hwalinkweb = new HtmlWeb();
                            HtmlAgilityPack.HtmlDocument hwalinkdoc = hwalinkweb.Load(latesturl.ToString());
                            HtmlNode hwlinknode    = hwalinkdoc.DocumentNode.SelectSingleNode("//div[@id='main_textarea'] //div //div //div //div[@id='skip-link'] //a");
                            string   hwllinksource = hwlinknode.Attributes["href"].Value;

                            if (latesturl == geckoWebBrowser1.Url.ToString())
                            {
                                GeckoElementCollection skippost = geckoWebBrowser1.Document.GetElementsByTagName("a");
                                foreach (GeckoElement skiptag in skippost)
                                {
                                    if (skiptag.GetAttribute("href") == hwllinksource.ToString())
                                    {
                                        ((GeckoHtmlElement)skiptag).Click();
                                    }
                                }
                            }

                            while (geckoWebBrowser1.IsBusy)
                            {
                                Application.DoEvents();
                            }
                            while (!geckoWebBrowser1.IsBusy)
                            {
                                Application.DoEvents();
                            }
                            while (geckoWebBrowser1.IsBusy)
                            {
                                Application.DoEvents();
                            }
                        }
                        else if (uri != nowurl.ToString())
                        {
                            while (geckoWebBrowser1.IsBusy)
                            {
                                Application.DoEvents();
                            }
                            string  latesturl  = geckoWebBrowser1.Url.ToString();
                            HtmlWeb hwalinkweb = new HtmlWeb();
                            HtmlAgilityPack.HtmlDocument hwalinkdoc = hwalinkweb.Load(latesturl.ToString());
                            HtmlNode hwlinknode    = hwalinkdoc.DocumentNode.SelectSingleNode("//div[@id='main_textarea'] //div //div //div //div[@id='skip-link'] //a");
                            string   hwllinksource = hwlinknode.Attributes["href"].Value;

                            if (latesturl == geckoWebBrowser1.Url.ToString())
                            {
                                GeckoElementCollection skippost = geckoWebBrowser1.Document.GetElementsByTagName("a");
                                foreach (GeckoElement skiptag in skippost)
                                {
                                    if (skiptag.GetAttribute("href") == hwllinksource.ToString())
                                    {
                                        ((GeckoHtmlElement)skiptag).Click();
                                    }
                                }
                            }

                            while (geckoWebBrowser1.IsBusy)
                            {
                                Application.DoEvents();
                            }
                            while (!geckoWebBrowser1.IsBusy)
                            {
                                Application.DoEvents();
                            }
                            while (geckoWebBrowser1.IsBusy)
                            {
                                Application.DoEvents();
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                    geckoWebBrowser1.Navigate("http://www.quikr.com/");
                    while (geckoWebBrowser1.IsBusy)
                    {
                        Application.DoEvents();
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("All Cities Posted Successfully");
            }
        }
Esempio n. 14
0
        private void initializeElements()
        {
            usernameElement = (GeckoElement)browser.Document.GetElementsByClassName("username")[0];
            creditElement   = (GeckoElement)browser.Document.GetElementsByClassName("credits")[0];

            GeckoElement textboxParent = (GeckoElement)browser.Document.GetElementsByClassName("bet_system")[0];

            foreach (GeckoNode child in textboxParent.ChildNodes)
            {
                if (child.NodeName.ToLower() == "input")
                {
                    textboxElement = (GeckoInputElement)child;
                }
            }

            GeckoNode redDiv = browser.Document.GetElementsByClassName("table")[0];

            foreach (GeckoNode child in redDiv.ChildNodes)
            {
                if (NodeType.Element == child.NodeType)
                {
                    GeckoElement convert = (GeckoElement)child;
                    if (convert.GetAttribute("data-color") == "red")
                    {
                        redButton = (GeckoHtmlElement)child;
                        Console.WriteLine("Got Red");
                    }
                }
            }

            GeckoNode blackDiv = browser.Document.GetElementsByClassName("table")[2];

            foreach (GeckoNode child in blackDiv.ChildNodes)
            {
                if (NodeType.Element == child.NodeType)
                {
                    GeckoElement convert = (GeckoElement)child;
                    if (convert.GetAttribute("data-color") == "black")
                    {
                        blackButton = (GeckoHtmlElement)child;
                        Console.WriteLine("Got Black");
                    }
                }
            }

            GeckoNode resultListParent = browser.Document.GetElementsByClassName("winner_history")[0];

            foreach (GeckoNode child in resultListParent.ChildNodes)
            {
                if (NodeType.Element == child.NodeType)
                {
                    GeckoElement convert = (GeckoElement)child;
                    if (convert.GetAttribute("class") == "holder")
                    {
                        resultList = (GeckoElement)child;
                    }
                }
            }

            GeckoNode statusTextParent = browser.Document.GetElementsByClassName("roll_timer")[0];

            foreach (GeckoNode child in statusTextParent.ChildNodes)
            {
                if (NodeType.Element == child.NodeType)
                {
                    GeckoElement convert = (GeckoElement)child;
                    if (convert.GetAttribute("class") == "bg")
                    {
                        statusText = (GeckoElement)child;
                    }
                }
            }

            betRedStatusText   = (GeckoElement)browser.Document.GetElementsByClassName("your")[0];
            betBlackStatusText = (GeckoElement)browser.Document.GetElementsByClassName("your")[2];
        }