Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Is there anyway to run JavaScript in python?

Reply
Thread Tools

Is there anyway to run JavaScript in python?

 
 
crow
Guest
Posts: n/a
 
      12-30-2010
Hi, I'm writing a test tool to simulate Web browser. Is there anyway
to run JavaScript in python? Thanks in advance.
 
Reply With Quote
 
 
 
 
Roy Smith
Guest
Posts: n/a
 
      12-30-2010
In article
<(E-Mail Removed)>,
crow <(E-Mail Removed)> wrote:

> Hi, I'm writing a test tool to simulate Web browser. Is there anyway
> to run JavaScript in python? Thanks in advance.


The answer to the question you asked is, "Probably. You might want to
check out SpiderMonkey as a starting point".

The answer to the question you didn't ask is, "Before you invest a lot
of effort in this, check out Selenium".

http://en.wikipedia.org/wiki/SpiderM...aScript_engine)
http://en.wikipedia.org/wiki/Selenium_(software)

Another thing to think about is whether you really do need JS to test
your web app. Depending on how much your app depends on JS for its core
functionality, you may find that just using urllib to fetch pages,
parsing the HTML with lxml, and verifying that certain data exists in
the appropriate HTML elements might get you 80% of the testing value for
20% of the effort. But, I digress.
 
Reply With Quote
 
 
 
 
Dan Stromberg
Guest
Posts: n/a
 
      01-01-2011
On Thu, Dec 30, 2010 at 5:52 AM, crow <(E-Mail Removed)> wrote:
> Hi, I'm writing a test tool to simulate Web browser. Is there anyway
> to run JavaScript in python? Thanks in advance.
> --
> http://mail.python.org/mailman/listinfo/python-list
>


You might also consider Pyjamas, which translates Python (somewhere
between 2.5 and 2.6) to Javascript. Then your python code ends up
running on a javascript interpreter with interlanguage calling
available.
 
Reply With Quote
 
Diez B. Roggisch
Guest
Posts: n/a
 
      01-03-2011
crow <(E-Mail Removed)> writes:

> Hi, I'm writing a test tool to simulate Web browser. Is there anyway
> to run JavaScript in python? Thanks in advance.


Not really. Yes, you can invoke spidermonkey. But the crucial point
about running JS is not executing JS, it's about having the *DOM* of the
browser available. Which spidermonkey obviously hasn't.

So, I recommend using Selenium.

Diez
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyway to Run Code Not Associated with Loading a Page? Jonathan Wood ASP .Net 10 01-03-2009 11:24 PM
Is there anyway to run 16-bit apps on Vista 64 bit? Stuart Jackson Windows 64bit 7 10-05-2008 02:54 PM
Is there anyway with VB.net to force closing of a spreadsheet in E =?Utf-8?B?TmVpbA==?= ASP .Net 1 04-27-2005 03:14 PM
anyway to run anti-spyware without installing it? abc123 A+ Certification 3 03-10-2005 05:15 AM
is there anyway to stop active directory services in Win2k? Jason MCSE 16 04-20-2004 06:22 AM



Advertisments