include JS files from user-extensions.js

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

include JS files from user-extensions.js

GW-5
Hi,

my user-extensions grow bigger and bigger. Is there any JS command to inlude external files similar to import in Java?

JPT
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1904&messageID=5385#5385

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: include JS files from user-extensions.js

Dan Fabulich
JPT wrote:

> my user-extensions grow bigger and bigger. Is there any JS command to
> inlude external files similar to import in Java?

Yes and no, mostly no.  The Dojo toolkit has some tools that make this
possible, but I find the Dojo toolkit incomprehensible. :-)  Essentially
they just perform an XmlHttpRequest and then read the data out and then
eval() it.

Once things get complex enough, you may prefer to just write your tests in
Java (or in whatever programming language you're most familiar) using
Selenium Remote Control.

-Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: include JS files from user-extensions.js

GW-5
In reply to this post by GW-5
What I do is pretty simple but does the trick.  I broke the extensions up into several files (eg user-extensions-misc.js and user-extensions-foo.js), and then have user-extensions.js add the script includes to the page.

user-extensions.js contains:
function _addExtension(script)
{
    document.writeln("<script src=\"user-extensions-" + script + ".js\"></script>");
}
_addExtension("misc");
_addExtension("foo");

Obviously you can come up with any naming scheme you'd like.

I also have a batch file to cat them all together (type user-extensions-*.js > extensions.js) for the Selenium IDE to use since it doesn't like document.writes.  You could also do that for user-extensions.js as well, but it's a little tedious.

Raj Singh
SAS Institute, Inc.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1904&messageID=5518#5518

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]