Giter Site home page Giter Site logo

laurentj / slimerjs Goto Github PK

View Code? Open in Web Editor NEW
3.0K 101.0 258.0 3.84 MB

A scriptable browser like PhantomJS, based on Firefox

Home Page: http://slimerjs.org

License: Other

Shell 0.57% JavaScript 89.50% CSS 1.01% Java 2.30% Python 0.52% CoffeeScript 0.01% HTML 5.54% Batchfile 0.51% Dockerfile 0.05%
slimerjs casperjs firefox javascript phantomjs

slimerjs's Introduction

SlimerJS

http://slimerjs.org/

SlimerJS is a scriptable browser. It allows you to manipulate a web page with an external Javascript script: opening a webpage, clicking on links, modifying the content... It is useful to do functional tests, page automation, network monitoring, screen capture etc.

It is a tool like PhantomJs, except that it runs Gecko instead of Webkit, and it is headless when using Firefox 56+. It can be used with Firefox 59.

Higher version of Firefox is not supported and probably will not be supported in the future, as the development is suspended for now.

SlimerJS provides the same API of PhantomJS. The current version of SlimerJS is highly compatible with PhantomJS 2.1. See current release notes in docs/release-notes-*.rst, and read the compatibility table to know the implementation level.

The main goal of SlimerJS is to allow to execute all scripts developed for PhantomJS. So you could use tools like CasperJS. In fact, CasperJs 1.1 and higher can be executed with SlimerJS!

SlimerJS is not only a PhantomJS clone, it contains also additional features.

Technically, SlimerJS is a XUL/JS application that is launched with Firefox.

Community

Follow us on twitter: @slimerjs

Ask your questions on the dedicated mailing list.

Install SlimerJS, executing a script...

See documentation into the docs/ directory into the source code, or read it on the web site

FAQ and contribution

Read the faq into the website/faq.html file or on the website.

slimerjs's People

Contributors

abozhilov avatar auroranockert avatar bernardeli avatar billiegoose avatar darrencook avatar graingert avatar hywan avatar jelu avatar justinklemm avatar kevingrandon avatar laurentj avatar madarche avatar malixsys avatar marco-c avatar markr42 avatar matthewkastor avatar matthewlmcclure avatar mncharity avatar nagyv avatar niek avatar patricklucas avatar paulchaplin avatar paxa avatar pgeraghty avatar samdutton avatar stoykostanchev avatar swatinem avatar twitwi avatar vmeurisse avatar wskorodecki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slimerjs's Issues

Use temporary profiles or do not store preferences

Many command line options change preferences. By default preferences are stored automatically so if we launch two instances of SlimerJS, they will share same preferences values even if we don't set same command line options.

Two solutions:

  • find a way to not store permanently preferences
  • or create a new profile at each startup (but it could be slow...)

Supports settings on phantom and webpage objects

see webpage.settings and phantom.defaultPageSettings.

  • javascriptEnabled
  • loadImages
  • localToRemoteUrlAccessEnabled
  • XSSAuditingEnabled
  • webSecurityEnabled
  • javascriptCanOpenWindows (see preferences dom.disable_open_during_load and dom.popup_allowed_events)
  • javascriptCanCloseWindows (see preference dom.allow_scripts_to_close_windows)
  • userAgent
  • userName
  • password
  • maxAuthAttempts
  • resourceTimeout

callback of open() is not called on a redirect

when calling a web page with redirect the callback of open is never called

for example with this script

var webpage = require("webpage").create();

//page with redirect
var url ="http://fr.wikipedia.org/";
webpage.open(url, function(success){
            console.log(success);
            console.log("loaded "+url);        
        });

// page without redirect
var url ="http://fr.wikipedia.org/wiki/Wikipédia:Accueil_principal";
webpage.open(url, function(success){
            console.log(success);
            console.log("loaded "+url);
        });

the result is

 success
 loaded http://fr.wikipedia.org/wiki/Wikipédia:Accueil_principal

the expected result should be

 success
 loaded http://fr.wikipedia.org/wiki/Wikipédia:Accueil_principal
 success
 loaded http://fr.wikipedia.org/

Tests on module fail with windows

When launching initial-tests.js or main-tests.js on windows (with the slimerjs.bat), there is this error:

 Script Error: Module: Can not resolve "./a/b" module required by main located at
 file:///C:/Users/xxx/apps/slimerjs/test/main-tests.js
       Stack:
         -> file:///C:/Users/xxx/apps/slimerjs/test/test-require.js: 19

Support of API to manage child window

Windows opened by a web page (window.open), could be managed by some functions and properties on the webpage object: ownPages, pages, pagesWindowName, getPage()

Initial ressource id

Hi,

Although it is not a documented API of phantomJS, resource.id in onResourceRequested and onResourceReceived starts with 1. In slimerJS, it starts with 0.

Regards

Support of SSL options

We should support these parameters:

  • --ignore-ssl-errors
  • --ssl-protocol=[SSLv3|SSLv2|TLSv1|any](will not be supported)
  • --ssl-certificates-path=/path

To support --ssl-certificates-path=/path/to/dir see this code snipet

properties added to window are not available

CasperJS declares the patchRequire function on the window object of the initial script. In PhtanomJS, this function is accessible by other modules. This is not the case in SlimerJS.

Should we break sandboxing behavior of our module system implementation? :-/

Embed WebDriver / GhostDriver

Webdriver is a library to support the Selenium protocol. We should include it and support these cli options:

--webdriver or --wd or -w
--webdriver=ip:port
--webdriver-logfile=/path/to/logfile
--webdriver-loglevel=[ERROR|WARN|INFO|DEBUG]
--webdriver-selenium-grid-hub=url

Cannot run multiple instances in parallel

Hello,

When running two instances of SlimerJS in parallel, you get an error message:

SlimerJS is already running, but is not responding. To open a new window, you must first
close the existing SlimerJS process, or restart your system.

PhantomJS handle this correctly.

Regards

"javascript:" links should be executed synchronously

In gecko, "javascript:" links are executed asynchronously. The problem is that after clicking on this kind of link, if the script modify something that we want to test after the click, we don't see this modification.

We could patch gecko in nsDocShell to "load" javascript links in an synchronous manner.

Support of remote debugger

PhantomJS has these options

--remote-debugger-port=number
--remote-debugger-autorun=[yes|no]

They allow to debug a script with web developer tools of Google Chrome / Safari.

We should have similar features, working with developer tools of Firefox.

Support of local storage options

PhantomJS has these options

--local-storage-path=/path/to/file
--local-storage-quota=number

However, SlimerJS support natively local storage: it is stored in the app profile under a specific name, and I'm not sure we can indicate the file name (is it in a pref?)

For quota, probably it is a preference.

We should at least document how to manage profiles

There is also the API webpage.offlineStoragePath webpage.offlineStorageQuota

Support of Navigation locking

webpage.navigationLocked, webpage.onNavigationRequested, webpage.navigationRequested(url, navigationType, navigationLocked, isMainFrame)

Slimerjs freeze on JS errors

Hi,

When I load the following script,

var page = require('webpage').create();
page.open("http://www.slimerjs.org", function (status) {
    console.log('a');
    page.evaluate(function() {
        var I;
        I.will.throw.an.error();
     }); 
    console.log('b');
});

it just freezes on the page.evaluate line and no error message is displayed. This makes debugging scripts quite complicated.

Regards

Support of the cookies API and cli options

SlimerJS should support

  • phantom.cookies, phantom.cookiesEnabled, phantom.addCookie(), phantom.clearCookies(), phantom.deleteCookie()
  • webpage.cookies , webpage.addCookie() , webpage.clearCookies() , webpage.deletCookie()

This API should rely on the cookie manager already provided by XulRunner.

  • --cookies-file should be ignored, for two reasons: 1) the format of the cookie file of PhantomJS is binary and very specific (QT IO output); 2) cookies are already stored automatically by the cookie manger in an sqlite file in the app profile

In SlimerJS, Cookies are activated by default and are persistant.
We should provide an option:

  • --clear-cookies to erase cookies at startup?
    • or cookies are erased at each startup, and we provide --keep-cookies to not erase them ?

Note: to deactivate cookies: preference network.cookie.cookieBehavior. 2=disabled, 0=enabled
-

Exit code should not be 0 on incorrect Firefox version

Hello,

I recently updated my Firefox version to 23 which is unsupported yet by slimerjs. As expected, slimerjs is showing an error. Unfortunately, the return code is 0 which confuse the calling script:

$slimerjs && echo success

(process:18232): GLib-CRITICAL **: g_slice_set_config: assertion `sys_page_size == 0' failed
Error: Platform version '23.0a2' is not compatible with
minVersion >= 17.0.0
maxVersion <= 22.*
success

Regards

Cygwin: bad path format for the application.ini

With cygwin, the bash script generate a unix path. However, xulrunner.exe/firefox.exe expect a windows path. We should generate a windows path for cygwin. By providing a specific bash script or by improving the current bash script if possible.

slimer.exit() should be able to set exit status

Currently (version 0.7) calling slimer.exit(1) makes the process exit with status 0. This makes Slimer unsuitable for use as a testing platform since CI servers cannot tell whether the tests failed without relying on a special output format like TAP or XML.

It should be possible to write test scripts with Slimer and use the exit status to indicate failure.

Support of proxy configuration

We should add support for these parameters:

  • --proxy=address:port
  • --proxy-auth=username:password
  • --proxy-type= http|socks5|none

I think values should be stored into preferences

Is it possible to capture flash url request?

Like page.onResourceReceived,but also support request that flash sent . I want to make webpage snapshoot also support music and videos,which usually are requested in flash.Is it possible to capture request that sent by flash?

Support of CoffeeScript

SlimerJS should be able to execute CoffeeScript.

The module loader should be modified to detect .coffee extension, and the CoffeeScript library should be embedded.

On Windows Vista, slimerjs.bat syntax error

I tried running slimerjs on Windows Vista 64, from the files in the Standalone Edition (slimerjs-0.8-win32.zip)

But it looks like there is something wrong with the slimerjs.bat file: I get the widows shell "Command syntax error" message (in my locale language):

I tried a bit of debugging and ditched @echo off and it bails about here

If I look into the .bat file I also see the 5 duplicated if clauses, like here so I wonder if things are as they should be.

I'll poke around a bit and see if I can find out more.

page.evaluate doesn't support string as parameter

Hi,

Although not documented in PhantomJS, page.evaluate accept an already stringified function. Here is a test file:

var page = require('webpage').create();

page.open('http://www.google.fr', function() {
    try {
        var res = page.evaluate('function(){return "ok";}');
    } catch(e) {
        console.log(e);
    }   
    console.log(res);
    phantom.exit();
});

Here are some usage in the wild.

Regards

Support of a --debug option

PhantomJS displays this informations:

  • configuration values
  • script and arguments
  • files that are readed (modules..)
  • webpage progression loading
  • sendEvent parameters
  • cookies

windows support?

ok, I had a look at bin/slimerjs and it appears to be an arg parser that supplies some text for the -help or -h option. The rest of it looks to be setup for the command line

"$SLIMERJSLAUNCHER" -app $SCRIPTDIR/../src/application.ini -purgecaches --envs "$LISTVAR" "$@"

If I've got it right $SLIMERJSLAUNCHER is the path to xulrunner, $SCRIPTDIR/../src/application.ini is the full path to slimerjs/src/application.ini, $LISTVAR is a comma separated list of environment variable names, and $@ is . . . I don't know exactly, maybe a pseudo variable that returns the arguments supplied to the script? At any rate, I supplied the javascript file name as the last argument. I also tried giving the full path to the script. Nothing I tried worked.

Anyway, on windows I created a batch file to create this command but couldn't get slimerjs to do anything except flash briefly on the screen. Then I changed the command and added the -console option so I could see any errors that might go to the console and commented out line 51 in slimerjs/src/chrome/slimerjs/content/slimerjs.js which reads Services.startup.quit(Components.interfaces.nsIAppStartup.eForceQuit); After doing this the window would stay on screen showing the fancy green ghost and my TrueConsole™ would stay on screen telling me that there was an error on line 34 of slimerjs/src/modules/phantom.jsm which led me to believe that somehow I had not supplied the script name and location correctly.

So, in order for me to figure this out I'll need to know what information slimer expects to be in $LISTVAR and what $@ does exactly. I'm figuring that after the program is started everything will be handled by the xulrunner and should work cross platform.

https://github.com/laurentj/slimerjs/blob/master/src/chrome/slimerjs/content/slimerjs.js#L51
https://github.com/laurentj/slimerjs/blob/master/src/modules/phantom.jsm#L34

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.