<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: A simple getCSSCount for use with Selenium-RC</title>
	<atom:link href="http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-simple-getcsscount-helper-method-for-use-with-selenium-rc</link>
	<description>A different view of software testing</description>
	<lastBuildDate>Fri, 10 Feb 2012 08:37:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: Sam S</title>
		<link>http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/#comment-2138</link>
		<dc:creator>Sam S</dc:creator>
		<pubDate>Fri, 18 Feb 2011 07:07:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/#comment-2138</guid>
		<description>oops sorry forgot to put back the int conversion   
return int(self.selenium.get_eval(java_script_code))

So the code is :


def count_css_matches(self, css_locator):
java_script_code = ”’
var cssMatches = eval_css(”%s”, window.document);
cssMatches.length;”’ % css_locator
return int(self.selenium.get_eval(java_script_code))

print self.count_css_matches(”[id=’listGuests’] &gt; option”) # where option is the name of the options elements in dropdown with id=’listGuests’</description>
		<content:encoded><![CDATA[<p>oops sorry forgot to put back the int conversion<br />
return int(self.selenium.get_eval(java_script_code))</p>
<p>So the code is :</p>
<p>def count_css_matches(self, css_locator):<br />
java_script_code = ”’<br />
var cssMatches = eval_css(”%s”, window.document);<br />
cssMatches.length;”’ % css_locator<br />
return int(self.selenium.get_eval(java_script_code))</p>
<p>print self.count_css_matches(”[id=’listGuests’] &gt; option”) # where option is the name of the options elements in dropdown with id=’listGuests’</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam S</title>
		<link>http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/#comment-2137</link>
		<dc:creator>Sam S</dc:creator>
		<pubDate>Fri, 18 Feb 2011 06:41:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/#comment-2137</guid>
		<description>Thank you for the attempt to help, but I couldn&#039;t get that extension to work.
However--there is some good news. the kind folks at the google python user group have helped convert your original function into python. So now if anyone wants to use it, they would just place this code within their unittest class.

    def count_css_matches(self, css_locator):
        java_script_code = &#039;&#039;&#039;
            var cssMatches = eval_css(&quot;%s&quot;, window.document);
            cssMatches.length;&#039;&#039;&#039; % css_locator
        return self.selenium.get_eval(java_script_code)

print self.count_css_matches(&quot;[id=&#039;listGuests&#039;] &gt; option&quot;) # where option is the name of the  options elements in dropdown with id=&#039;listGuests&#039;


Suweeeeet!!! :)</description>
		<content:encoded><![CDATA[<p>Thank you for the attempt to help, but I couldn&#8217;t get that extension to work.<br />
However&#8211;there is some good news. the kind folks at the google python user group have helped convert your original function into python. So now if anyone wants to use it, they would just place this code within their unittest class.</p>
<p>    def count_css_matches(self, css_locator):<br />
        java_script_code = &#8221;&#8217;<br />
            var cssMatches = eval_css(&#8220;%s&#8221;, window.document);<br />
            cssMatches.length;&#8221;&#8217; % css_locator<br />
        return self.selenium.get_eval(java_script_code)</p>
<p>print self.count_css_matches(&#8220;[id='listGuests'] &gt; option&#8221;) # where option is the name of the  options elements in dropdown with id=&#8217;listGuests&#8217;</p>
<p>Suweeeeet!!! :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam S</title>
		<link>http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/#comment-2136</link>
		<dc:creator>Sam S</dc:creator>
		<pubDate>Thu, 17 Feb 2011 09:26:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/#comment-2136</guid>
		<description>hi, thank you for this. Can you please also explain how to add &quot;Get CSS count&quot; into the userextensions.js file so that it can be its own function within selenium?

best,
S

&lt;em&gt;I don&#039;t use the IDE or userextensions.js so everything I do is based around simple Java. I&#039;ve approved your comment in case someone else sees it and can help.

But looking at the official docs http://seleniumhq.org/docs/08_user_extensions.html

It looks like it might be as simple as adding 

&lt;code&gt;Selenium.prototype.getCSSCount = function(locator, text) {
    var cssMatches = eval_css(locator, window.document);
    return cssMatches.length;
};&lt;/code&gt;

or possibly 

&lt;code&gt;Selenium.prototype.getCSSCount = function(locator, text) {
    var cssMatches = eval_css(locator, this.browserbot.getDocument());
    return cssMatches.length;
};&lt;/code&gt;

But I haven&#039;t tried either of those code snippets so I&#039;m coding blind based on the docs and based on Aditya&#039;s blog post.
&lt;/em&gt;</description>
		<content:encoded><![CDATA[<p>hi, thank you for this. Can you please also explain how to add &#8220;Get CSS count&#8221; into the userextensions.js file so that it can be its own function within selenium?</p>
<p>best,<br />
S</p>
<p><em>I don&#8217;t use the IDE or userextensions.js so everything I do is based around simple Java. I&#8217;ve approved your comment in case someone else sees it and can help.</p>
<p>But looking at the official docs <a href="http://seleniumhq.org/docs/08_user_extensions.html" rel="nofollow">http://seleniumhq.org/docs/08_user_extensions.html</a></p>
<p>It looks like it might be as simple as adding </p>
<p><code>Selenium.prototype.getCSSCount = function(locator, text) {<br />
    var cssMatches = eval_css(locator, window.document);<br />
    return cssMatches.length;<br />
};</code></p>
<p>or possibly </p>
<p><code>Selenium.prototype.getCSSCount = function(locator, text) {<br />
    var cssMatches = eval_css(locator, this.browserbot.getDocument());<br />
    return cssMatches.length;<br />
};</code></p>
<p>But I haven&#8217;t tried either of those code snippets so I&#8217;m coding blind based on the docs and based on Aditya&#8217;s blog post.<br />
</em></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: angrydot</title>
		<link>http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/#comment-1576</link>
		<dc:creator>angrydot</dc:creator>
		<pubDate>Tue, 16 Mar 2010 21:04:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/#comment-1576</guid>
		<description>Awesome! Your posts on CSS selectors are very timely for me.

So the C# version is:
private int getCSSCount(String aCSSLocator)
        { 
            String jsScript = &quot;var cssMatches = eval_css(\&quot;&quot; + aCSSLocator + &quot;\&quot;, window.document);cssMatches.length;&quot;;
            return int.Parse(browser.GetEval(jsScript));
        }

Where I call the following C# to return the number of options in a  element named &quot;realm&quot;:
int numOptions = getCSSCount(&quot;select[name=&#039;realm&#039;] option&quot;);
or
int numOptions = getCSSCount(&quot;select[name=&#039;realm&#039;]&gt;option&quot;);

&lt;em&gt;Thanks for converting it into C#, I hope that can help someone else too.&lt;/em&gt;</description>
		<content:encoded><![CDATA[<p>Awesome! Your posts on CSS selectors are very timely for me.</p>
<p>So the C# version is:<br />
private int getCSSCount(String aCSSLocator)<br />
        {<br />
            String jsScript = &#8220;var cssMatches = eval_css(\&#8221;" + aCSSLocator + &#8220;\&#8221;, window.document);cssMatches.length;&#8221;;<br />
            return int.Parse(browser.GetEval(jsScript));<br />
        }</p>
<p>Where I call the following C# to return the number of options in a  element named &#8220;realm&#8221;:<br />
int numOptions = getCSSCount(&#8220;select[name='realm'] option&#8221;);<br />
or<br />
int numOptions = getCSSCount(&#8220;select[name='realm']&gt;option&#8221;);</p>
<p><em>Thanks for converting it into C#, I hope that can help someone else too.</em></p>
]]></content:encoded>
	</item>
</channel>
</rss>

