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

  • Home
  • SEARCH
  • 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 8891309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:42:32+00:00 2026-06-14T22:42:32+00:00

I am migrating test scripts from Selenium RC to WebDriver. The biggest issue so

  • 0

I am migrating test scripts from Selenium RC to WebDriver. The biggest issue so far is that our extension classes are having to be rewritten to use the WebDriver API, which I don’t mind, but the By class is giving me issues, mostly because you have to explicitly state what type of element you are using when you call the FindElements method. So, instead of a single click method that implicitly determines the element type, I made a method for each element type (css, XPath, name, id, etc.), which look like this:

public void ClickByXPath(string xpath) { _driver.FindElement(By.XPath(xpath)).Click(); }

This works, but I am having to create separate methods for each element type a lot (for GetText, IsElementPresent, etc.). When writing the scripts it gets old typing the names for each method, since they are long and I have to check to see what type of element is being used as a parameter. I would like to have something like this…

public void Click(XPath locator) { ... }
public void Click(Name locator) { ... }

However, I am not sure the best way to go about this with WebDriver. Any suggestions would be greatly appreciated. Thanks in advance.

  • 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-06-14T22:42:34+00:00Added an answer on June 14, 2026 at 10:42 pm

    You can use an Enum SelectorType{Xpath, Css, etc..} and use one click method which has (String argument, SelectorType type) and usingswitch-case to perform different actions depending on the type.

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

Sidebar

Related Questions

I'm migrating our Selenium test to WebDriver and there is a test which use
We're finally migrating our unit test code base from JUnit 3 to JUnit 4.
We are migrating our test report data (unit, regression, integration, etc..) from an XML
I am in the process of migrating my test suite from the Selenium 1
Background: Migrating an application from ball of mud to MVC. Many classes contain HTML
On migrating our code to Scala 2.9 we've found large swathes of it that
We have custom code that wipes and initializes our test database by creating a
I have a test server that uses data from a test database. When I'm
Migrating app from php. and have this in the view: <%=render :partial => jt-test,
I am migrating from a test SQLite database to a PostgreSQL database. I have

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.