browse by category or date

Couple of weeks back, my colleague mentioned about Selenium. It is a tool to automate UI testing which utilizes heavily on Java script. I gave it a short try but stumbled with problem on retrieving values from table (I had not read the documentation that time). So I stopped and was pondering on how to resolve the problem. Due to busy with other projects, I didn’t continue my exploration with Selenium.

When I attended Microsoft’s Mix-It-Up Session, one of the speakers highlighted the capability of Visual Studio 2008 to generate automatic UI testing. It immediately reminded me of Selenium. So I asked a question about the problem similar to what I had with Selenium. I asked, “Is there anyway to make the UI Testing dynamic so that we can supply list of input values and the expected output values, then it will automatically generate all the asserts?”. The speaker did not answer my question, but he feedback to Microsoft Team that what I asked is something that would be very nice to have in Visual Studio 2008.

Selenium IDE

I haven’t get my hands dirty with Visual Studio 2008, so I can’t really confirm with what the speaker implied in his feedback to Microsoft *grin*.

Anyway, last weekend I have quite of free time. So I decided to look deeper into Selenium. This time I thread through carefully the Selenium documentation. I finally found what I was looking for. The function is called “storeTable (TableCellAddress, VariableName)”.

To generate the test script, I used Selenium Firefox Add-On. Then I modified manually the script to suit my needs using Notepad++. From here, it’s quite smooth sailing with Selenium.

Few things that I learned:

When open a pop-up window, you need to have the windowID. WindowID is the variable that holding the reference to that window.

var myWindowID = window.open("http://window.url");

After you select the window using SelectWindow, you need to call waitForPageToLoad before accessing any elements inside it. Fail to do this; your test case might throw exception.

As you could see, I am quite late into this. There are myriads of articles (sample) and blog posts (sample) about Selenium available in internet. Google is your best friend 😀

GD Star Rating
loading...
ASP.NET UI Testing With Selenium, 3.0 out of 5 based on 1 rating

Possibly relevant:

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Incoming Search

.net, agile, asp.net, testing

4 comments so far

Add Your Comment
  1. hey bro, i will definitely try out this app. thank you for sharing the info. check my blog out when you find the time

  2. i all, i am using selenium remote control. i have a problem about it.
    Now i am considering about how to write selenium script in C# and get data from the database. You can take me a sample about it. many thank!

  3. @Amgad: Hi, thanks for the visit. Your blog is awesome.

    @Cong: I haven’t tried the Selenium RC. But it should be simpler than creating an aspx page that actually generates selenium HTML tags (which is what I did :P).

  4. public static void SelectInsertUpdateData(string qry)
    {
    try
    {
    SqlConnection thisConnection = new SqlConnection(ConfigurationSettings.AppSettings[\"PreConnStr\"].ToString());
    if (thisConnection.State == ConnectionState.Closed)
    { thisConnection.Open(); }
    SqlCommand cmd = new SqlCommand(qry, thisConnection);
    cmd.ExecuteNonQuery();

    }
    catch (Exception ex)
    {
    throw ex;
    }
    }

    public static DataSet GetDataSet(string query)
    {
    try
    {
    SqlConnection thisConnection = new SqlConnection(ConfigurationSettings.AppSettings[\"PreConnStr\"].ToString());
    if (thisConnection.State == ConnectionState.Closed)
    { thisConnection.Open(); }
    SqlDataAdapter adp = new SqlDataAdapter(query, thisConnection);
    DataSet dataset = new DataSet();
    adp.Fill(dataset);
    return dataset;
    }
    catch (Exception ex)
    {
    throw ex;
    }
    }