コード例 #1
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");
            }
        }
コード例 #2
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);
        }
コード例 #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);
            }
        }
コード例 #4
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;
     }
 }
コード例 #5
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");
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: nowonbun/nowonbunstore
        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;
                }
            }
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: mohanncterode/quikrpost
        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");
            }
        }