title: Using Spynner module in Python (need to select a Javascript element)
body: <p>Trying to select a Javascript element using the Python module Spynner.</p>
  
  <p>(NOTE: Username and Password not real)</p>
  
  <p>Here's the list I am trying to pull it from:</p>
  
  <pre><code>&lt;tr&gt;
  &lt;td valign="middle" align="right"&gt;
  &lt;select onkeypress="javascript:if ( event.keyCode == 13 ){valid();}" style="font-family:Tahoma; font-size:11px;FONT-WEIGHT :normal;height:20px;" name="mkt"&gt;
  &lt;option value="0"&gt;All Markets&lt;/option&gt;
  &lt;option value="IBESLA~AR"&gt;Argentina &lt;/option&gt;
  &lt;option value="IBESAA~AU"&gt;Australia &lt;/option&gt;
  &lt;option value="IBESEA~AT"&gt;Austria &lt;/option&gt;
  &lt;option value="IBESEB~BE"&gt;Belgium &lt;/option&gt;
  &lt;option value="IBESLB~BR"&gt;Brazil &lt;/option&gt;
  &lt;option value="IBESNC~CA"&gt;Canada &lt;/option&gt;
  &lt;option value="IBESLC~CL"&gt;Chile &lt;/option&gt;
  &lt;option value="IBESFC~CN"&gt;China &lt;/option&gt;
  &lt;option value="IBESLL~CO"&gt;Colombia &lt;/option&gt;
  &lt;option value="IBESDC~HR"&gt;Croatia &lt;/option&gt;
  &lt;option value="IBESEC~CZ"&gt;Czech Republic &lt;/option&gt;
  &lt;option value="IBESSD~DK"&gt;Denmark &lt;/option&gt;
  &lt;option value="IBESKE~EG"&gt;Egypt &lt;/option&gt;
  &lt;option value="IBESDE~EE"&gt;Estonia &lt;/option&gt;
  &lt;option value="IBESSF~FI"&gt;Finland &lt;/option&gt;
  &lt;option value="IBESEF~FR"&gt;France &lt;/option&gt;
  &lt;option value="IBESED~DE"&gt;Germany &lt;/option&gt;
  &lt;option value="IBESEH~GR"&gt;Greece &lt;/option&gt;
  &lt;option value="IBESFH~HK"&gt;Hong Kong &lt;/option&gt;
  &lt;option value="IBESEM~HU"&gt;Hungary &lt;/option&gt;
  &lt;option value="IBESFI~IN"&gt;India &lt;/option&gt;
  &lt;option value="IBESFL~ID"&gt;Indonesia &lt;/option&gt;
  &lt;option value="IBESEZ~IE"&gt;Ireland &lt;/option&gt;
  &lt;option value="IBESFZ~IL"&gt;Israel &lt;/option&gt;
  &lt;option value="IBESEI~IT"&gt;Italy &lt;/option&gt;
  &lt;option value="IBESFJ~JP"&gt;Japan &lt;/option&gt;
  &lt;option value="IBESFR~JO"&gt;Jordan &lt;/option&gt;
  &lt;option value="IBESFM~MY"&gt;Malaysia &lt;/option&gt;
  &lt;option value="IBESKP~MU"&gt;Mauritius &lt;/option&gt;
  &lt;option value="IBESLM~MX"&gt;Mexico &lt;/option&gt;
  &lt;option value="IBESKM~MA"&gt;Morocco &lt;/option&gt;
  &lt;option value="IBESEN~NL"&gt;Netherlands &lt;/option&gt;
  &lt;option value="IBESAN~NZ"&gt;New Zealand &lt;/option&gt;
  &lt;option value="IBESSN~NO"&gt;Norway &lt;/option&gt;
  &lt;option value="IBESFQ~PK"&gt;Pakistan &lt;/option&gt;
  &lt;option value="IBESLP~PE"&gt;Peru &lt;/option&gt;
  &lt;option value="IBESFP~PH"&gt;Philippines &lt;/option&gt;
  &lt;option value="IBESEG~PL"&gt;Poland &lt;/option&gt;
  &lt;option value="IBESEP~PT"&gt;Portugal &lt;/option&gt;
  &lt;option value="IBESEK~RO"&gt;Romania &lt;/option&gt;
  &lt;option value="IBESER~RU"&gt;Russia &lt;/option&gt;
  &lt;option value="IBESFS~SG"&gt;Singapore &lt;/option&gt;
  &lt;option value="IBESDR~SK"&gt;Slovakia &lt;/option&gt;
  &lt;option value="IBESDV~SI"&gt;Slovenia &lt;/option&gt;
  &lt;option value="IBESKS~ZA"&gt;South Africa &lt;/option&gt;
  &lt;option value="IBESFK~KR"&gt;South Korea &lt;/option&gt;
  &lt;option value="IBESEE~ES"&gt;Spain &lt;/option&gt;
  &lt;option value="IBESBL~LK"&gt;Sri Lanka &lt;/option&gt;
  &lt;option value="IBESSS~SE"&gt;Sweden &lt;/option&gt;
  &lt;option value="IBESES~CH"&gt;Switzerland &lt;/option&gt;
  &lt;option value="IBESFA~TW"&gt;Taiwan &lt;/option&gt;
  &lt;option value="IBESFT~TH"&gt;Thailand &lt;/option&gt;
  &lt;option value="IBESET~TR"&gt;Turkey &lt;/option&gt;
  &lt;option value="IBESEX~GB"&gt;United Kingdom &lt;/option&gt;
  &lt;option value="IBESNA~US"&gt;United States &lt;/option&gt;
  &lt;/select&gt;
  &lt;/td&gt;
  &lt;td valign="middle"&gt;
  &lt;img width="5px" src="images/spacer.gif"&gt;
  &lt;/td&gt;
  &lt;td valign="middle"&gt;
  &lt;a href="javascript:setChildFrameWidth();valid()"&gt;
  &lt;/td&gt;
  &lt;td valign="middle"&gt;
  &lt;img width="10px" src="images/spacer.gif"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>And here is my code:</p>
  
  <pre><code>from __future__ import division
  from __future__ import unicode_literals
  from __future__ import print_function
  import re
  import spynner
  from BeautifulSoup import BeautifulSoup
  import time
  br = spynner.Browser()
  br.create_webview()
  br.show()
  br.set_html_parser(BeautifulSoup)
  br.load("https://www.thomsononeim.com/s-log_in.asp")
  br.fill("input[name=txtLoginID]", "USERNAME")
  br.fill("input[name=txtPWD]", "PASSWORD")
  br.click("input[name=Submit]", wait_load=True)
  br.click("input[name=Market]", wait_load=True)
  br.select("IBESNA~US")
  br.browse()
  br.close()
  </code></pre>
  
  <p>What am I doing wrong with the select? It gives me the error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Python27\Sample Programs\Spynner Basic.py", line 17, in &lt;module&gt;
      br.select("IBESNA~US")
    File "C:\Python27\lib\site-packages\spynner\browser.py", line 862, in select
      self._runjs_on_jquery("select", jscode)
     File "C:\Python27\lib\site-packages\spynner\browser.py", line 394, in _runjs_on_jquery
       raise SpynnerJavascriptError("error on %s: %s" % (name, code))
  SpynnerJavascriptError: error on select: jq('IBESNA~US').attr('selected', 'selected')
  </code></pre>