Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript: Modify code to add elements to an array/list
    primarykey
    data
    text
    <p>Hey Guys, Javascript newbie here. I'm trying to modify some existing to code to instead of returning the <strong>count</strong> of elements, to actually add each of the specified elements to an array/list</p> <p>here is the original code from <a href="http://www.eviltester.com/index.php/2010/03/13/a-simple-getcsscount-helper-method-for-use-with-selenium-rc/" rel="nofollow">Selenium CSS counter</a></p> <pre><code>private int getCSSCount(String aCSSLocator){ String jsScript = "var cssMatches = eval_css(\"%s\", window.document);cssMatches.length;"; return Integer.parseInt(selenium.getEval(String.format(jsScript, aCSSLocator))); </code></pre> <p>} </p> <p>I then have to convert the code to python, which I am far more familiar with</p> <pre><code> 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)) </code></pre> <p>But changing the original code to return the array instead of an integer is where I get stuck.</p> <p>Thanks for the help and the below is the error I get when I tried to run it in Python.</p> <p>Traceback (most recent call last): "D:\Temp\1TestingApps\Selenium\SeleniumRC\selenium-python-client-driver-1.0.1\selenium.py", line 1218, in get_eval return self.get_string("getEval", [script,]) File "D:\Temp\1TestingApps\Selenium\SeleniumRC\selenium-python-client-driver-1.0.1\selenium.py", line 219, in get_string result = self.do_command(verb, args) File "D:\Temp\1TestingApps\Selenium\SeleniumRC\selenium-python-client-driver-1.0.1\selenium.py", line 215, in do_command raise Exception, data Exception: ERROR: Threw an exception: missing ) after argument list</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload