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 790503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:41:33+00:00 2026-05-14T21:41:33+00:00

I’ve been using XPath with Selenium quite happily and even using getEval with a

  • 0

I’ve been using XPath with Selenium quite happily and even using getEval with a but of Javascript, but a colleague said wouldn’t it be great to be able to use JQuery selectors in Selenium.

I’ve googled it, but can’t find any articles that seem to work for me. Could anyone provide a comprehensive guide on how to use JQuery syntax to extract doc elements and their respective values out of selenium.

I’m using C# to write my selenium tests, so if any examples could be from a C# perspective that’d be great.

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-14T21:41:34+00:00Added an answer on May 14, 2026 at 9:41 pm

    Karl Swedberg wrote an excellent blog entry about it which can be found at http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet

    We adapted this and basically in the Selenium Server jar file we modified RemoteRunner.html to include the jquery JavaScript (obtained from http://code.jquery.com/jquery-latest.min.js):

            <script language="JavaScript" type="text/javascript" src="jquery.min.js"></script>
            <script language="JavaScript" type="text/javascript">
                function openDomViewer() {
                    var autFrame = document.getElementById('selenium_myiframe');
                    var autFrameDocument = new SeleniumFrame(autFrame).getDocument();
                    this.rootDocument = autFrameDocument;
                    var domViewer = window.open(getDocumentBase(document) + 'domviewer/domviewer.html');
                    return false;
                }
            </script>
    

    Then to enable this for use in Selenium we add the location strategy:

    mySelenium.addLocationStrategy("jquery",
                "var loc = locator; " +
                "var attr = null; " +
                "var isattr = false; " +
                "var inx = locator.lastIndexOf('@'); " +
    
                "if (inx != -1){ " +
                "   loc = locator.substring(0, inx); " +
                "   attr = locator.substring(inx + 1); " +
                "   isattr = true; " +
                "} " +
    
                "var found = jQuery(inDocument).find(loc); " +
                "if (found.length >= 1) { " +
                "   if (isattr) { " +
                "       return found[0].getAttribute(attr); " +
                "   } else { " +
                "       return found[0]; " +
                "   } " +
                "} else { " +
                "   return null; " +
                "}"
            );
    

    Note the above addition of locator strategy is in Java but its just a string so should be easily replicated in C#.
    JQuery does make things a lot faster, especially in Internet Explorer!

    To modify the jar you can use the java command line tool to update the downloaded selenium server jar. Make a folder at the same level as the jar called “core” and put the modified RemoteRunner.html and jquery.min.js files there. Then run something like:

    jar -uf selenium-server-standalone-2.0b3-APT.jar core\RemoteRunner.html
    jar -uf selenium-server-standalone-2.0b3-APT.jar core\jquery.min.js
    

    If jar isn’t in your path you can use the full path, for example on windows you could execute it with something like:

    "C:\Program Files\Java\jdk1.6.0_22\bin\jar.exe" <arguments>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:

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.