vendredi 25 décembre 2015

login into multiple accounts using the same loop statement

All I need is a more reliable and stable way of logging into multiple account (not all at once) using a loop that's all. I have already an example code that works but isn't all that stable.

        string email_1 = "email_1";
        string password_1 = "password_1";
        string email_2 = "email_2";
        string password_2 = "password_2";

        int k = 1;
        do
        {
            string e = null;
            string p = null;
            if (k == 1)
            {
                e = email_2;
                p = password_2;
            }
            if (k == 2)
            {
                e = email_1;
                p = password_1;
            }
        _driver.FindElement.(id("submit_email")).sendkeys(e);
        IWebElement s = _driver.FindElement.(id("submit_password"));
        s.Sendkeys(p);
        s.Submit();

        //do stuff

        _driver.FindElement(id("logout")).Click();
            k++;
        } while (k <= 2);

any ideas on how to make it more stable and reliable? or maybe a better approach to it?

Aucun commentaire:

Enregistrer un commentaire