Selnium RC - Connecting MySql

Stpes:
1.Add Reference --> MySql.Data From the path C:\Program Files\MySql\My Sql Connect Net 5.0.81\Binaries\.NET2.0\MySql.Data.dll
2.using MySql.Data.MySqlClient;
3.Here is a Sample Code for Connect the MySql:

public void ConnectMySQL() //Mysql connectivity
        {
            try
            {
                MySqlConnection con = new MySqlConnection("server=localhost;database=yourdb;uid=yourid;pwd=yourpwd");
                String url = "http://applicationundertest.com/openingpage.aspx";
                String txtLogin = "ctl00_mainContentPlaceHolder_txt_LoginName";
                String txtPassword = "ctl00_mainContentPlaceHolder_txt_Password";
                String btnLogin = "ctl00_mainContentPlaceHolder_btn_login";

                MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM users", con);
                DataSet ds = new DataSet("users");

                da.Fill(ds);

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    selenium.Open(url);
                    selenium.WaitForPageToLoad("100000");
                    selenium.Type(txtLogin, dr[2].ToString());
                    selenium.Type(txtPassword, dr[3].ToString());
                    selenium.Click(btnLogin);
                    selenium.WaitForPageToLoad("100000");
                                        if (selenium.IsTextPresent("Logout"))
                    {
                        selenium.Click("link=My Account");
                        Assert.AreEqual(dr[1], selenium.GetValue("ctl00_mainContentPlaceHolder_txt_firstname"));
                        selenium.WaitForPageToLoad("100000");

                    }

                }
                //con.Close(); 
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
        }

10 comments:

  1. Hello Vijay

    How to validate login ( username and password) using selenium

    dhairya

    ReplyDelete
  2. Thanks for the great information in your blog Selenium

    ReplyDelete
  3. Looking for best training in SELENIUM, take a glance at http://thecreatingexperts.com/selenium-training-in-chennai/

    ReplyDelete
  4. I was looking for Selenium and Appium training in Chennai and got a link,it was the CREATING EXPERTS.

    If you are looking for one click the link below and contact 8122241286.

    http://thecreatingexperts.com/appium-training-in-chennai/
    http://thecreatingexperts.com/selenium-training-in-chennai/

    ReplyDelete
  5. THE CREATING EXPERTS is one of the leading training provider in SELENIUM they provide hands on training with real time scenario

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact +91-08122241286

    ReplyDelete
  6. The Creating Experts provides training in SELENIUM

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact +91-08122241286

    ReplyDelete
  7. Nice blog...

    Selenium training institute which provides Real Time Hands on Training…THE CREATING EXPERTS

    http://thecreatingexperts.com/selenium-training-in-chennai/


    contact-8122241286

    ReplyDelete
  8. SELENIUM training in Chennai by TE CREATING EXPERTS ,they provide you hands on training with real time scenarios

    http://thecreatingexperts.com/selenium-training-in-chennai/

    contact 8122241286

    ReplyDelete
  9. Hi, all nice blog for a long time i was searching for a real time trainer and landed with my trainer in selenium
    SELENIUM training is provided by THE CREATING EXPERTS in CHENNAI

    http://thecreatingexperts.com/selenium-training-in-chennai/

    Contact 8122241286 for more info

    ReplyDelete