Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to develop a selenium application (using c# win forms). So, while the application starts, the users will enter an app name in the text box. I have many fields such as cost, validity etc corresponding to each app.

Example webpage:

description  appname  cost  validity  xyzattribute
some desc     app1     10      30     someattribute

I want selenium to search the entire page for that given app name and if it finds any, I want selenium to retrieve all the attributes (cost, validity) and store those in a variable. How can I achieve this?

Please note that none of these fields have a unique attribute (such as name/id/any other).

share|improve this question

If I were you, I would take advantage of Seliniums ability to run and get results from arbitrary javascript commands. Let's assume you have a structure something like this:

<table id="mytable">
       <td>description 1</td>
       <td>appname 1</td>
       <td>description 2</td>
       <td>appname 2</td>

To get the the description column value on the second row, you could run this javascript code:

var secondDescription = document.getElementById("mytable").rows[1].children[0].innerHtml

In C#, you first create an instance of IJavascriptExecutor (

IWebDriver driver = new FirefoxDriver(); //or whatever
IJavascriptExecutor jsDriver = (IJavaScriptExecutor) driver;

Then to get a value in C#, you simply run the javascript command:

string secondDescription = jsDriver.ExecuteScript("document.getElementById(\"mytable\").rows[1].children[0].innerHtml");
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.