amohanta / spynner

Automatically exported from code.google.com/p/spynner
GNU General Public License v3.0
0 stars 0 forks source link

JavaScript not working #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I installed everything on a Mac OX 10.6 with 32Bit cause of problems with PyQt. 
Now it seems to work but when I try the examples I always get an error when it 
comes to the JavaScript functions:

Page load finished (15303 bytes): http://www.wordreference.com/ (successful)
Javascript console (:12): TypeError: Type error
Traceback (most recent call last):
  File "wordreference.py", line 13, in <module>
    browser.fill("input[name=enit]", "hola")
  File "/Library/Python/2.6/site-packages/spynner/browser.py", line 459, in fill
    self._runjs_on_jquery("fill", jscode)
  File "/Library/Python/2.6/site-packages/spynner/browser.py", line 323, in _runjs_on_jquery
    raise SpynnerJavascriptError("error on %s: %s" % (name, code))
spynner.browser.SpynnerJavascriptError: error on fill: 
_jQuery('input[name=enit]').val('hola')

Original issue reported on code.google.com by btorbi...@gmail.com on 6 Jan 2011 at 3:33

GoogleCodeExporter commented 9 years ago
another example:

Traceback (most recent call last):
  File "google.py", line 10, in <module>
    browser.choose("input[name=lr=lang_es]")
  File "/Library/Python/2.6/site-packages/spynner/browser.py", line 474, in choose
    self._runjs_on_jquery("choose", jscode)
  File "/Library/Python/2.6/site-packages/spynner/browser.py", line 323, in _runjs_on_jquery
    raise SpynnerJavascriptError("error on %s: %s" % (name, code))
spynner.browser.SpynnerJavascriptError: error on choose: 
_jQuery('input[name=lr=lang_es]').simulate('click')

Original comment by btorbi...@gmail.com on 6 Jan 2011 at 3:34

GoogleCodeExporter commented 9 years ago
which version are you using? there was a commit regarding JS not long ago.

Original comment by tokland on 6 Jan 2011 at 10:48

GoogleCodeExporter commented 9 years ago
thanks for pushing me in the right direction I downloaded the newest version 
from github and it seems to work now. 

great projekt by the way!

Original comment by btorbi...@gmail.com on 6 Jan 2011 at 1:21

GoogleCodeExporter commented 9 years ago
ok!

Original comment by tokland on 6 Jan 2011 at 1:28

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I also have javascript not working. I am using spynner on an Ubuntu machine. I 
have just installed all the components today, they are all up to date. When I 
try to run a simple js command like:

br = spynner.Browser()
br.load("http://www.wordreference.com")
br.runjs("console.log('hello')")

I get this:
<PyQt4.QtCore.QVariant object at 0x1c10db8>

And when I try to click a button invoking some javascript calls like:

br.click("input[name=ctl00$plSearch$btnQuickSearch]")

I get this:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/spynner-1.10-py2.6.egg/spynner/browser.py", line 566, in click
    self._runjs_on_jquery("click", jscode)
  File "/usr/local/lib/python2.6/dist-packages/spynner-1.10-py2.6.egg/spynner/browser.py", line 400, in _runjs_on_jquery
    raise SpynnerJavascriptError("error on %s: %s" % (name, code))
spynner.browser.SpynnerJavascriptError: error on click: 
jq('input[name=ctl00$plSearch$btnQuickSearch]').simulate('click');

The html for the button is:
<input type="button" name="ctl00$plSearch$btnQuickSearch" value="Hızlı Ara" 
onclick="SayacSifirla();WebForm_DoPostBackWithOptions(new 
WebForm_PostBackOptions("ctl00$plSearch$btnQuickSearch", "", false, "", 
"Oteller.aspx", false, true))" id="ctl00_plSearch_btnQuickSearch" 
class="HizliAraButton" />

But I can click a simple button with no javascript involved.

How can I fix this situation? 

Original comment by akcali.ozgur on 13 Jul 2011 at 8:20