Selenium RC - Connecting Spread Sheet

How to Connect excel Sheet in Selenium RC
Given the C# approach to connect the Excel sheet.
Steps:
1.Add Reference -->From .Net Tab Select System.Data
2.Add Reference -->From .Net Tab Select System.XML
3.using System.Data;
4.using System.IO;
5.using System.Xml;

6.using System.Xml.Serialization;
7.using System.Data.OleDb;

Sample Code:
 public void ConnectExcel()
        {
            String url = "http://ApplicationUnderTest.com/OpenPage.aspx";
            String txtLogin = "ctl00_mainContentPlaceHolder_txt_LoginName";
            String txtPassword = "ctl00_mainContentPlaceHolder_txt_Password";
            String btnLogin = "ctl00_mainContentPlaceHolder_btn_login";
            string strConn;
            strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=F:\\Sample.xls;" +
            "Extended Properties=Excel 8.0;";
            //You must use the $ after the object you reference in the spreadsheet
            OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn);
            DataSet myDataSet = new DataSet();
            myCommand.Fill(myDataSet, "ExcelInfo");
            foreach (DataRow dr in myDataSet.Tables[0].Rows)
            {
                selenium.Open(url);
                selenium.WaitForPageToLoad("100000");
                selenium.Type(txtLogin, dr[13].ToString());
                selenium.Type(txtPassword, dr[14].ToString());
                selenium.Click(btnLogin);
                selenium.WaitForPageToLoad("100000");
                //Assert.IsTrue(selenium.IsTextPresent(h));
                //Assert.IsTrue(selenium.IsTextPresent(h));
                if (selenium.IsTextPresent("Logout"))
                {
                    selenium.Click("a1");
                    selenium.WaitForPageToLoad("100000");
                }
    }
}

17 comments:

  1. Hii Vijay....just to let you know...the info you shared is very useful for beginners....and it helped me a lot in my career...
    Thank you so much and keep doing the good work..

    ReplyDelete
  2. Hi Vijay,

    Thanks a lot for sharing these info.
    Can you please send us code which will check TestDataID and then returns respected row for specific testcase/testdata instead of all rows.

    WAITING FOR UR REPLY.

    Thanks
    Anand S.
    somanianands@gmail.com

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

    ReplyDelete
  4. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete
  5. Selenium Testing Real Time Hands on Training in Chennai…

    Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

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

    If You need a Best Trainer in Selenium Testing??? Then be ready for a DEMO From the Trainer MR.Karthick
    CONTACT:8122241286

    Both Classroom/Online Training is Available!!!!!!

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

    ReplyDelete
  7. Few months back i was searching for SELENIUM training, and i attended demo session with some of the trainers in CHENNAI, but did not get a clear picture of whom to get trained with?

    Later i came across THE CREATING EXPERTS.The demo class was up-to the mark with satisfying my needs and requirements and here i got placed in a concern.

    Thanks to their in-depth hands on training with real time scenarios.For training inquiries

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

    contact info - Mr.Karthick 8122241286

    ReplyDelete
  8. Thanks for sharing this blog.Creating Experts provides Best training in selenium

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

    contact 8122241286

    ReplyDelete
  9. Thanks for sharing great information in your blog.

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

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


    contact-8122241286

    ReplyDelete
  10. Thanks for sharing this blog.Creating Experts provides Best training in selenium

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

    contact 8122241286

    ReplyDelete
  11. 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
  12. 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
  13. The Creating Experts provides training in SELENIUM

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

    contact +91-08122241286

    ReplyDelete
  14. 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
  15. 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
  16. 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