protected void Login()
        {
            using (TestLog.BeginSection("Go to sharpcms adminpage"))
            {
                Ie.GoTo("http://localhost:17267/cleansite/login.aspx");
                Assert.IsTrue(Ie.ContainsText("Login"), "Unable to load adminpage! Ensure that the webserver is started");
            }

            using (TestLog.BeginSection("Enter the password and press login"))
            {
                Ie.TextField(Find.ByName("data_login")).TypeText("admin");
                Ie.TextField(Find.ByName("data_password")).TypeText("admin");
                Ie.Button(Find.ByValue("Login")).Click();
                Assert.IsTrue(Ie.ContainsText("Pages"), "Expected to find \"Pages\" on the page.");
            }
        }
Exemplo n.º 2
0
        public override bool Verify()
        {
            bool retValue = false;

            try
            {
                IE iepop = IE.AttachToIE(Find.ByTitle(new Regex(title)));
                if (iepop.ContainsText(Text))
                {
                    Wxs.Instance.Log.InfoFormat("Test : {0} passed", Text);
                    retValue = true;
                }
                else
                {
                    Wxs.Instance.Log.WarnFormat("Test : {0} failed", Text);
                }
                iepop.Close();
            }
            catch (Exception ex)
            {
                Wxs.Instance.Log.ErrorFormat("Error: Exception {0} thrown executing Popup Test {1}!", ex.Message, Name);
                return(false);
            }
            return(retValue);
        }
Exemplo n.º 3
0
        public void Should_save_a_visit()
        {
            new DatabaseTester().Clean();

            var url = "http://localhost:1234/";

            using (var ie = new IE(url))
            {
                ie.TextField("PathAndQuerystring").TypeText("/MyUrl");
                ie.TextField("LoginName").TypeText("SomeComputer\\ThisUser");
                ie.Button("submit").Click();

                ie.ContainsText("/MyUrl");
                ie.ContainsText("SomeComputer\\ThisUser").ShouldBeTrue();
            }
        }
Exemplo n.º 4
0
        // https://sourceforge.net/tracker/?func=detail&aid=2897406&group_id=167632&atid=843727
        public void Search_for_watin_on_google_using_page_class()
        {
            using (var browser = new IE("http://www.google.com"))
            {
                var searchPage = browser.Page <GoogleSearchPage>();
                searchPage.SearchCriteria.TypeText("WatiN");
                searchPage.SearchButton.Click();

                Assert.IsTrue(browser.ContainsText("WatiN"));
                browser.Back();

                //This line throws UnauthorizedAccessException.
                searchPage.SearchCriteria.TypeText("Search Again");
                searchPage.SearchButton.Click();
                Assert.IsTrue(browser.ContainsText("Glenn"));
            }
        }
Exemplo n.º 5
0
        public void Login_WithoutUsernameAndPassword_Should_Have_ErrorMessage()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Admin")).Click();

                browser.Element(Find.BySelector("input.LogOn")).Click();

                Assert.IsTrue(browser.ContainsText("The User name field is required"));

                Assert.IsTrue(browser.ContainsText("The Password field is required."));
            }
        }
Exemplo n.º 6
0
 public void TestFollowLink()
 {
     _ie.GoTo(_webServer.BaseUrl + "Home/Index");
     Assert.That(_ie.Url.EndsWith("Home/Index"), "Should open with index");
     _ie.Link(Find.ById("link_to_about")).Click();
     Assert.That(_ie.Url.EndsWith("Home/About"), "Expected change in url");
     Assert.That(_ie.ContainsText("About Page"), "Site should contain 'About page'");
 }
        public void Page_with_an_action()
        {
            using (var browser = new IE("http://www.google.com"))
            {
                browser.Page <GoogleSearchPage>().SearchFor("WatiN");

                Assert.IsTrue(browser.ContainsText("WatiN"));
            }
        }
Exemplo n.º 8
0
        public void Home_HasMvcStoreHasTitle_True()
        {
            var browser = new IE("http://localhost:1100/");

            browser.BringToFront();
            Assert.IsTrue(browser.ContainsText("ASP.NET MVC MUSIC STORE"));

            browser.Close();
        }
Exemplo n.º 9
0
        public void HelloWatin(string search)
        {
            using (var browser = new IE("http://www.google.com"))
            {
                browser.TextField(Find.ByName("q")).TypeText(search);
                browser.Button(Find.ByName("btnG")).Click();

                Assert.IsTrue(browser.ContainsText(search));
            }
        }
Exemplo n.º 10
0
 public void RunSmokeTest()
 {
     using (var browser = new IE("http://www.google.com"))
     {
         const string search = "WatiN";
         browser.TextField(Find.ByName("q")).TypeText(search);
         browser.Button(Find.ByName("btnG")).Click();
         Assert.IsTrue(browser.ContainsText(search));
     }
 }
        public void Search_for_watin_on_google_the_old_way()
        {
            using (var browser = new IE("http://www.google.com"))
            {
                browser.TextField(Find.ByName("q")).TypeText("WatiN");
                browser.Button(Find.ByName("btnG")).Click();

                Assert.IsTrue(browser.ContainsText("WatiN"));
            }
        }
Exemplo n.º 12
0
        public void Home_ClickOnRockContainsRockAlbumText_True()
        {
            using (var browser = new IE("http://localhost:1100/"))
            {
                browser.BringToFront();

                browser.Link(Find.ByText("Rockssss")).Click();
                Assert.IsTrue(browser.ContainsText("Rock Albums"));
            }
        }
Exemplo n.º 13
0
 public void DoScreenshotTest()
 {
     Assert.IsNotNull(ie);
     using (TestLog.BeginSection("Go to Google, enter MbUnit as a search term and click I'm Feeling Lucky"))
     {
         ie.GoTo("http://www.google.com");
         ie.TextField(Find.ByName("q")).TypeText("MbUnit");
         ie.Button(Find.ByName("btnI")).Click();
     }
     Assert.IsTrue(ie.ContainsText("NUnit"), "Expected to find NUnit on the page.");
 }
        public void Search_for_watin_on_google_using_page_class()
        {
            using (var browser = new IE("http://www.google.com"))
            {
                var searchPage = browser.Page <GoogleSearchPage>();
                searchPage.SearchCriteria.TypeText("WatiN");
                searchPage.SearchButton.Click();

                Assert.IsTrue(browser.ContainsText("WatiN"));
            }
        }
 public static bool isBusy(this IE ie)
 {
     if (ie.Visible && ie.ContainsText("Home"))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemplo n.º 16
0
        public void Demonstrate_speed()
        {
            new DatabaseTester().Clean();

            var url = "http://localhost:1234/";

            using (var ie = new IE(url))
            {
                for (int i = 0; i < 50; i++)
                {
                    ie.GoTo("http://localhost:1234/");
                    ie.TextField("PathAndQuerystring").Value = "/MyUrl";
                    ie.TextField("LoginName").Value          = "SomeComputer\\ThisUser";
                    ie.Button("submit").Click();

                    ie.ContainsText("/MyUrl");
                    ie.ContainsText("SomeComputer\\ThisUser").ShouldBeTrue();
                }
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// Determines whether [is internet error].
 /// </summary>
 /// <returns>
 ///     <c>true</c> if [is internet error]; otherwise, <c>false</c>.
 /// </returns>
 public bool IsInternetError()
 {
     if (browser.Html.Contains("<BODY>disabled</BODY>"))
     {
         return(false);
     }
     try
     {
         if (browser.ContainsText("500 Internal Server Error") || browser.ContainsText("504 Gateway Time-out") ||
             !browser.Image(Find.BySrc(UrlImageDeleloperLogo)).Exists
             )
         {
             AppCore.LogSystem.Warn("Ошибка сервера ботвы");
             return(true);
         }
     }
     catch (UnauthorizedAccessException)
     {
     }
     return(false);
 }
Exemplo n.º 18
0
        public void SetUp()
        {
            bool IsWebStarted;

            rootUrl = string.Format("http://*****:*****@".UnitTest"));

                //Environment.CurrentDirectory.Substring(0,Environment.CurrentDirectory.LastIndexOf('\\'));
                string commandArgs = string.Format(" /path:\"{0}\" /port:{1} /vapth:\"/{2}\"", rootPhyPath, devServerPort, rootpath);

                cmdProcess = new Process();
                cmdProcess.StartInfo.Arguments        = commandArgs;
                cmdProcess.StartInfo.CreateNoWindow   = true;
                cmdProcess.StartInfo.FileName         = command;
                cmdProcess.StartInfo.UseShellExecute  = false;
                cmdProcess.StartInfo.WorkingDirectory = command.Substring(0, command.LastIndexOf('\\'));
                if (!cmdProcess.Start())
                {
                    throw new Exception("Cannot start webserver");
                }

                // .. and try one more time to see if the server is up
                ie.GoTo(rootUrl);
            }
            Assert.IsTrue(ie.ContainsText("Directory Listing -- /"));

            // Give some time to crank up
            Thread.Sleep(1000);
        }
Exemplo n.º 19
0
        private bool isRegisteredEmail()
        {
            bool isRegistered = false;

            if (isInRegistrationPage())
            {
                ie = IE.AttachTo <IE>(Find.ByUrl(accountRegistrationUrl));
            }
            if (ie.ContainsText(Constants.BlueBirdConstants.ACCOUNT_EXCEEDED_MESSAGE))
            {
                throw new ValidationLimitExceededException();
            }

            List ul = ie.List(Find.BySelector(Constants.BlueBirdConstants.ERROR_ELEMENT_SELECTOR));

            if (isInRegistrationPage() && !ul.Exists)
            {
                if (ie.ContainsText(Constants.BlueBirdConstants.EMAIL_ERROR_MESSAGE))
                {
                    isRegistered = true;
                }
            }
            else if (ul != null)
            {
                foreach (var li in ul.ListItems)
                {
                    if (li.InnerHtml.ToLower() == Constants.BlueBirdConstants.EMAIL_ERROR_MESSAGE.ToLower())
                    {
                        isRegistered = true;
                        break;
                    }
                }
            }

            return(isRegistered);
        }
        public void After_update_should_show_confirm_message()
        {
            var callback = new Callback {
                CallerPhone = "4732606000", Comment = "Офис"
            };

            session.Save(callback);

            using (var browser = new IE(BuildTestUrl("default.aspx"))) {
                ClickLink(CallbackLinkText);
                browser.FindRow(callback).Input <Callback[]>(callbacks => callbacks[0].CheckDate, true);
                ClickButton("Сохранить");

                Assert.That(browser.ContainsText("Обновление успешно завершено."), Is.True, "Нет сообщения об успешном сохранении");
            }
        }
        public void UnsuccessfulAdministrationLogin()
        {
            bool result;

            using (var browser = new IE("http://localhost:1200/"))
            {
                browser.Link(Find.ByText("Admin")).Click();
                browser.TextField(Find.ById("UserName")).TypeText("admin");
                browser.TextField(Find.ById("Password")).TypeText("admin");

                browser.Element(Find.ByValue("Log On")).Click();

                result = browser.ContainsText("Login was unsuccessful.");
            }

            Assert.That(result, "Browser Url is incorrect");
        }
Exemplo n.º 22
0
        public void Adding_Items_ToCart()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Pop")).Click();

                browser.Link(Find.ByText("Frank")).Click();

                browser.Link(Find.ByText("Add to cart")).Click();

                Assert.IsTrue(browser.ContainsText("8.99"));
            }
        }
Exemplo n.º 23
0
        public void RemoveItemsFromCart()
        {
            using (var browser = new IE())
            {
                browser.GoTo("http://localhost:1100/");

                browser.BringToFront();

                browser.Link(Find.ByText("Pop")).Click();

                browser.Link(Find.ByText("Frank")).Click();

                browser.Link(Find.ByText("Add to cart")).Click();

                browser.Link(Find.BySelector("a.RemoveLink")).Click();

                Assert.IsTrue(browser.ContainsText("0"));
            }
        }
Exemplo n.º 24
0
        public void Login_UnSuccessful_Should_Have_Error()
        {
            var browser = new IE();


            browser.GoTo("http://localhost:1100/");

            browser.BringToFront();

            browser.Link(Find.ByText("Admin")).Click();

            browser.TextField(Find.ById("UserName")).TypeText("admin");

            browser.TextField(Find.ById("Password")).TypeText("1234");

            browser.Element(Find.BySelector("input.LogOn")).Click();

            Assert.IsTrue(browser.ContainsText("Login was unsuccessful."));
        }
Exemplo n.º 25
0
        public void TestViewCallHistory()
        {
            using (var browser = new IE(BuildTestUrl("default.aspx"))) {
                ClickLink("История звонков");
                browser.TextField(Find.ByName("SearchBy.BeginDate")).TypeText("01.01.2009");
                ClickButton("Найти");

                Assert.That(browser.ContainsText("Дата звонка"));
                Assert.That(browser.ContainsText("Куда звонил"));
                Assert.That(browser.ContainsText("Кому звонил"));
                Assert.That(browser.ContainsText("Тип звонка"));
                Assert.That(browser.ContainsText("Номер звонившего"));
                Assert.That(browser.ContainsText("Имя звонившего"));
            }
        }
Exemplo n.º 26
0
        public void Should_be_able_to_edit_conference()
        {
            using (var ie = new IE("http://localhost:8084"))
            {
                var conferencesLink = ie.Link(Find.ByText("Conferences"));
                conferencesLink.Click();

                var editCodeMashLink = ie.Link(Find.ByText("Edit"));
                editCodeMashLink.Click();

                var nameBox = ie.TextField(Find.ByName("Name"));
                nameBox.TypeText("CodeMashFoo");

                var submitBtn = ie.Button(Find.ByValue("Save"));
                submitBtn.Click();

                ie.Url.ShouldEqual("http://localhost:8084/Conference");

                ie.ContainsText("CodeMashFoo").ShouldBeTrue();
            }
        }
Exemplo n.º 27
0
        public override void Do(IE ie)
        {
            if (ie == null)
            {
                ie = Wxs.Instance.Ie;
            }
            int numCycles = 0;

            while (true)
            {
                System.Threading.Thread.Sleep(500);
                if (ie.ContainsText(condition))
                {
                    return;
                }
                if (numCycles > timeOut * 2) // convert to seconds
                {
                    string message = string.Format("Timeout ({1} s) reached, condition {0} not met",
                                                   condition, timeOut);
                    Wxs.Instance.Log.Error(message);
                    throw new ApplicationException(message);
                }
            }
        }
Exemplo n.º 28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ie">The navigator to operate</param>
        public override void Do(IE ie)
        {
            if (ie == null)
            {
                ie = Wxs.Instance.Ie;
            }
            if ((path == null) || (path == String.Empty))
            {
                path = "C:\\";
            }
            string[] splt = ie.Url.Split(new char[] { '/' });
            if (splt.Length < 3)
            {
                throw new ApplicationException("Invalid url to retrive test page");
            }
            ie.GoTo(splt[0] + "//" + splt[2] + "/test.aspx");
            if (ie.ContainsText("Session State"))
            {
                Dictionary <String, String> valuesToSave = new Dictionary <string, string>();
                string[] lines = ie.Text.Split(new char[] { '\n' });
                foreach (string line in lines)
                {
                    string[] splLine = line.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (splLine.Length == 2)
                    {
                        string key = splLine[0].Replace("+", String.Empty);
                        key = key.Replace("|", " ").Trim();
                        string value = splLine[1].Trim();
                        if (!valuesToSave.ContainsKey(key))
                        {
                            valuesToSave.Add(key, value);
                        }
                    }
                }
                string fileName;
                if ((valuesToSave.ContainsKey("UserName")) & valuesToSave.ContainsKey("SponsorID"))
                {
                    fileName = String.Format("{0}\\{2}_{1}.txt", path, valuesToSave["UserName"], valuesToSave["SponsorID"]);
                }
                else if (valuesToSave.ContainsKey("PersonID"))
                {
                    fileName = String.Format("{0}\\{1}.txt", path, valuesToSave["PersonID"]);
                }
                else
                {
                    fileName = String.Format("{0}\\{1}.txt", path, Name);
                }
                Wxs.Instance.Log.InfoFormat("Saving test page results to file : {0}", fileName);
                using (StreamWriter sw = new StreamWriter(fileName))
                {
                    sw.WriteLine("Test executed on {0}", DateTime.Now.ToString("g"));
                    sw.WriteLine("On : {0}\n\t\t***************", Wxs.Instance.Ie.Url);
                    foreach (KeyValuePair <string, string> kvp in valuesToSave)
                    {
                        sw.WriteLine(kvp.Key + " = " + kvp.Value);
                    }
                }
                ie.Back();
            }

            else
            {
                Wxs.Instance.Log.Error("Test page not available?");
            }
        }
Exemplo n.º 29
0
 public bool HasText(string text)
 {
     return(_browser.ContainsText(text));
 }
Exemplo n.º 30
0
        public void Leboncoin(BackgroundWorker worker, int z)
        {
            if (!log.Text.Contains("Chargement..."))
            {
                worker.ReportProgress(0, "Chargement...");
            }
            browser.GoTo("https://www.leboncoin.fr/");
            browser.WaitForComplete();
            worker.ReportProgress(1);
            if (browser.Div(Find.ByClass("clearfix")).Exists)
            {
                if (!log.Text.Contains("- Connecté"))
                {
                    worker.ReportProgress(0, "- Connecté");
                }
            }
            else
            {
                worker.ReportProgress(0, "- En cours de connexion...");
                browser.Button(Find.ByClass("button-flat button-secondary popin-open trackable custom-small-hidden")).Click();
                browser.ElementOfType <TextFieldExtended>(Find.ByName("st_username")).Value = mail;
                browser.TextField(Find.ByName("st_passwd")).Value = pwd;
                try
                {
                    browser.Button(Find.ByValue("Se connecter")).Click();
                    browser.WaitForComplete();
                    if (browser.Div(Find.ByClass("create")).Exists)
                    {
                        if (!log.Text.Contains("Connecté"))
                        {
                            worker.ReportProgress(0, "- Connecté");
                        }
                    }
                    else if (browser.ContainsText("Votre identifiant ou mot de passe est incorrect") || browser.ContainsText("Aucun compte ne correspond à cette adresse e-mail"))
                    {
                        worker.ReportProgress(0, " ");
                        worker.ReportProgress(0, "-- Votre identifiant ou mot de passe est incorrect --");
                        Kill("connection");
                    }
                }catch {
                    worker.ReportProgress(0, "- Erreur lors de la connection.");
                    Kill("connection");
                }
            }
            if (error != "connection")
            {
                worker.ReportProgress(1);
                browser.GoTo("https://compteperso.leboncoin.fr/account/index.html?ca=12_s");
                // Suppression de l'annonce
                if (browser.Link(Find.ByText(titrelbc)).Exists)
                {
                    browser.Link(Find.ByText(titrelbc)).Click();
                    worker.ReportProgress(0, " ");
                    worker.ReportProgress(0, "- Suppression de \"" + titrelbc + "\" en cours...");
                    browser.Link(Find.ByTitle("Supprimer l'annonce")).Click();
                    worker.ReportProgress(1);
                    browser.WaitForComplete();
                    browser.Button(Find.ByName("continue")).Click();
                    if (browser.ContainsText("L'annonce ci-dessous ne peut pas être supprimée, soit parce qu'elle a déjà été supprimée soit parce qu'elle est en cours de suppression ou de validation") || browser.Text.Contains("Cette annonce est désactivée"))
                    {
                        worker.ReportProgress(0, "- L'annonce a déjà été supprimée!");
                    }
                    else
                    {
                        browser.Button(Find.ByValue("Valider")).Click();
                        if (browser.ContainsText("Votre demande de suppression a bien été prise en compte"))
                        {
                            worker.ReportProgress(0, "- L'annonce a été supprimée");
                        }
                        else
                        {
                            worker.ReportProgress(0, "- Erreur lors de la suppression de l'annonce");
                        }
                    }
                    worker.ReportProgress(1);
                }
                // Mise en ligne de l'annonce
                browser.GoTo("https://compteperso.leboncoin.fr/account/index.html?ca=12_s");
                worker.ReportProgress(0, " ");
                worker.ReportProgress(0, "- Mise en ligne de \"" + titrelbc + "\"...");
                browser.WaitForComplete();
                browser.Link(Find.ByText("Déposez une annonce")).Click();
                worker.ReportProgress(1);
                browser.WaitForComplete();
                Invoke(new Action(() =>
                {
                    browser.RunScript("$('#category option').filter(function(i, e) { return $(e).text() == '" + catégorie + "'}).prop('selected', 'selected').trigger('change');");
                    browser.TextField(Find.ById("subject")).Value = titrelbc;
                    browser.TextField(Find.ById("body")).Value    = textelbc;
                    browser.ElementOfType <TextFieldExtended>(Find.ById("price")).Value = prixlbc.ToString();
                    browser.TextField(Find.ByName("zipcode")).Value = zip;
                    browser.TextField(Find.ByName("city")).Value    = ville;
                    if (browser.ElementOfType <TextFieldExtended>(Find.ById("phone")).Value == "")
                    {
                        browser.ElementOfType <TextFieldExtended>(Find.ById("phone")).Value = phone;
                    }
                    if (checké == true)
                    {
                        browser.Label("phone_hidden").Click();
                    }
                    for (int i = 0; i < souscategory.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(souscategory[i]))
                        {
                            try { browser.RunScript("$('#" + souscategoryname[i] + " option').filter(function(i, e) { return $(e).text() == \"" + souscategory[i] + "\"}).prop('selected', 'selected').trigger('change');"); }
                            catch { }
                            if (catégorie == "Voitures" && souscategoryname[i] == "brand")
                            {
                                browser.RunScript("$('#brand option[value=\"" + souscategory[i] + "\"]').prop('selected', true).trigger('change');");
                                browser.SelectList(Find.ById("model")).WaitUntil("disabled", false.ToString());
                                browser.RunScript("$('#model option[value=\"" + model + "\"]').prop('selected', true).trigger('change');");
                            }
                        }
                    }
                    if (browser.ElementOfType <TextFieldExtended>(Find.ById("mileage")).Parent.Parent.Parent.Parent.ClassName == "field")
                    {
                        browser.ElementOfType <TextFieldExtended>(Find.ById("mileage")).Value = mileage;
                    }
                    if (browser.ElementOfType <TextFieldExtended>(Find.ById("cubic_capacity")).Parent.Parent.Parent.Parent.ClassName == "field")
                    {
                        browser.ElementOfType <TextFieldExtended>(Find.ById("cubic_capacity")).Value = cc;
                    }
                    if (browser.ElementOfType <TextFieldExtended>(Find.ById("square")).Parent.Parent.Parent.Parent.ClassName == "field")
                    {
                        browser.ElementOfType <TextFieldExtended>(Find.ById("square")).Value = surface;
                    }
                    if (browser.ElementOfType <TextFieldExtended>(Find.ById("rooms")).Parent.Parent.ClassName == "field")
                    {
                        browser.ElementOfType <TextFieldExtended>(Find.ById("rooms")).Value = piece;
                    }
                }));
                worker.ReportProgress(1);
                if (photo1 != "")
                {
                    if (File.Exists(photo1))
                    {
                        browser.FileUpload(Find.ById("image0")).Set(photo1);
                        Invoke(new Action(() => { FocusToPreviousWindow(); }));
                        worker.ReportProgress(0, "Téléchargement de l'image 1...");
                        browser.Div("uploadPhoto-0").WaitUntil <Element>(element => element.GetAttributeValue("data-state").Equals("uploaded"));
                    }
                    else
                    {
                        worker.ReportProgress(0, "Image 1 non trouvée!");
                    }
                    worker.ReportProgress(1);
                }
                if (photo2 != "")
                {
                    if (File.Exists(photo2))
                    {
                        browser.FileUpload(Find.ById("image1")).Set(photo2);
                        Invoke(new Action(() => { FocusToPreviousWindow(); }));
                        worker.ReportProgress(0, "Téléchargement de l'image 2...");
                        browser.Div("uploadPhoto-1").WaitUntil <Element>(element => element.GetAttributeValue("data-state").Equals("uploaded"));
                    }
                    else
                    {
                        worker.ReportProgress(0, "Image 2 non trouvée!");
                    }
                    worker.ReportProgress(1);
                }
                if (photo3 != "")
                {
                    if (File.Exists(photo3))
                    {
                        browser.FileUpload(Find.ById("image2")).Set(photo3);
                        Invoke(new Action(() => { FocusToPreviousWindow(); }));
                        worker.ReportProgress(0, "Téléchargement de l'image 3...");
                        browser.Div("uploadPhoto-2").WaitUntil <Element>(element => element.GetAttributeValue("data-state").Equals("uploaded"));
                    }
                    else
                    {
                        worker.ReportProgress(0, "Image 3 non trouvée!");
                    }
                    worker.ReportProgress(1);
                }

                browser.CheckBox(Find.ById("phone_hidden")).Click();
                //Valider
                if (browser.Button(Find.ById("newadSubmit")).Exists)
                {
                    browser.Button(Find.ById("newadSubmit")).Click();
                }
                browser.CheckBox(Find.ById("accept_rule")).Click();
                if (browser.Button(Find.ById("lbc_submit")).Exists)
                {
                    browser.Button(Find.ById("lbc_submit")).Click();
                }
                if (browser.ContainsText("Nous avons bien reçu votre annonce. Nous vous remercions pour votre confiance."))
                {
                    worker.ReportProgress(0, "- Annonce mise en ligne!");
                }
                else
                {
                    worker.ReportProgress(0, "- Problème lors de la mise en ligne");
                }
                worker.ReportProgress(1);
                // FIN

                if (rang != 0)
                {
                    if (z == 1)
                    {
                        Click1();
                    }
                    else if (z == 2)
                    {
                        Click2();
                    }
                    worker.CancelAsync();
                }
                else
                {
                    worker.ReportProgress(100);
                    worker.ReportProgress(0, " ");
                    worker.ReportProgress(0, "--  MISE EN LIGNE TERMINÉE --");
                    Invoke(new Action(() =>
                    {
                        browser.ForceClose();
                        browser.Dispose();
                        notifyIcon1.BalloonTipTitle = "Mise en ligne terminée!";
                        notifyIcon1.BalloonTipText  = "LeBOTcoin a bien renouvelé vos annonces.";
                        notifyIcon1.ShowBalloonTip(3500);
                    }));
                }
            }
            worker.Dispose();
        }