Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4266756
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:48:17+00:00 2026-05-21T06:48:17+00:00

I am using Visual Studio 2010 to write Selenium 2 Webdriver automated tests in

  • 0

I am using Visual Studio 2010 to write Selenium 2 Webdriver automated tests in C#.
I have searched high and low for examples of using variables as selectors and have found nothing that seems to work. The one example I have found of a variable used as a selector had the variable with $ prefix and enclosed in {}.
An example of what I am trying to do is below:

string surveyName = "Selenium test survey";
Driver.FindElement(By.CssSelector("tr[svd='${surveyName}']"))

I get the error:

OpenQA.Selenium.WebDriverException : Unexpected error. Unable to find element using     css: tr[svd='${surveyName}']

If I ‘hard code’ the selector like this:

Driver.FindElement(By.CssSelector("tr[svd='Selenium test survey']"))

it finds the element.

svd is an attribute of the tr element. I am trying to select a row within a table by the value of this attribute. The text will be different for each test and so must be a variable.

I have tried expressing the variable a number of different ways but had no luck making this work. Any help would be much appreciated.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T06:48:17+00:00Added an answer on May 21, 2026 at 6:48 am
    string surveyName = "Selenium test survey";
    Driver.FindElement(By.CssSelector(String.Format("tr[svd='{0}']", surveyName))
    

    will do what you want. This is c# so when it takes a string you can do all kinds of things to get that string

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using MS Test with Visual Studio 2010 to write unit Tests. When
I am using Visual Studio 2010 and suppose I have to write some program.
I'm using Visual Studio 2010 to write a simple C#/.NET GUI app, wherein I
I'm trying to write an Outlook Addin in C# using Visual Studio 2010 and
I'm using Visual Studio 2010, and have the tangibleT4EditorPlusModellingTools installed. I'm just playing around
I'm using Visual Studio 2010. I'm trying to write simple Camera class in OpenGL.
I’m using Visual Studio 2010 to write unmanaged C++ code. When debugging, anything printed
How can I write C# application using Visual Studio 2010 that runs in background?
I am using Visual Studio 2010 Professional Edition, and Windows Vista. Firstly, I have
Using Visual Studio 2008 / C# / VS Unit Testing. I have a very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.