Forum: JRuby How to export validations in javascript

Posted by Moises Siles (Guest)
on 2010-03-08 17:12
(Received via mailing list)
Hi all

I'm exporting my selenium scripts to jruby, but I have some functions in 
my
user-extensions.js file, here is one of them

        if
(selenium.browserbot.getCurrentWindow().document.getElementById(id).style.display=='none')
        {
            storedVars[value] = true;
        }
        else
        {
            storedVars[value] = false;
        }

how can I run that kind of validation in jruby, or how can I execute js 
code
in jruby?

Thanks
Posted by Maarten Mortier (maartenm)
on 2010-03-08 17:13
(Received via mailing list)
Why don't you use json to abstract the javascript information
(serializing and deserializing it)? It will be a bit than running
Nitro to run js server-side.

On Mon, Mar 8, 2010 at 5:11 PM, Moises Siles <moises.siles@gmail.com> 
wrote:
>         else
>         {
>             storedVars[value] = false;
>         }
>
> how can I run that kind of validation in jruby, or how can I execute js code
> in jruby?
>
> Thanks

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Joseph Athman (Guest)
on 2010-03-08 17:31
(Received via mailing list)
You can continue to use your user-extensions.js file with selenium RC 
and
JRuby.  See
http://seleniumhq.org/docs/08_user_extensions.html#using-user-extensions-with-selenium-rcfor
information about how to use it.  There's no need to port this code to
ruby if you already have it working in JS.

Joe

On Mon, Mar 8, 2010 at 10:13 AM, Maarten Mortier
Posted by Moises Siles (Guest)
on 2010-03-08 17:31
(Received via mailing list)
What I have to do is to verify if the element is displayed in the page 
or
not, to do that I was thinking in verify if the style.display = 'none' 
or
'block', but not sure if this is the best way to check it.

On Mon, Mar 8, 2010 at 10:13 AM, Maarten Mortier
Posted by Moises Siles (Guest)
on 2010-03-08 17:38
(Received via mailing list)
mmmmm, but I don't want to use Selenium RC, I'm using celerity.
:S
Posted by Charles Nutter (headius)
on 2010-03-08 17:45
(Received via mailing list)
On Mon, Mar 8, 2010 at 10:11 AM, Moises Siles <moises.siles@gmail.com> 
wrote:
> Hi all
>
> I'm exporting my selenium scripts to jruby, but I have some functions in my
> user-extensions.js file, here is one of them
...
> how can I run that kind of validation in jruby, or how can I execute js code
> in jruby?

I'm not quite sure what you need, but you could always pull in Rhino
(the OSS Java-based JavaScript implementation) to run JavaScrit. Since
it's "just another jar file" it works fine with JRuby.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Joseph Athman (Guest)
on 2010-03-08 18:02
(Received via mailing list)
I think if you are moving away from selenium to another product you will
need to look at all your user defined functions and port them one at a
time.  There isn't any general way of just moving all your JS code to 
work
with celerity when it was designed to run with selenium.

In the particular JS function you posted, it looks like you are checking
whether a given dom element is visible or not.  It looks like celerity 
has a
couple "visible?" methods that should probably work for you.  You would
check it's visible status and then run your assertion against the 
returned
value.

Joe

On Mon, Mar 8, 2010 at 10:44 AM, Charles Oliver Nutter
Posted by Moises Siles (Guest)
on 2010-03-08 18:31
(Received via mailing list)
thanks Joe "It looks like celerity has a couple "visible?" methods that
should probably work for you" this is what I'm trying to do, I will 
research
to see if I can found examples about the "visible?" methods you mention.

thanks
Posted by Joseph Athman (Guest)
on 2010-03-08 20:49
(Received via mailing list)
This is what I was looking at:

http://celerity.rubyforge.org/yard/Celerity/Element.html#visible%3F-instance_method
Posted by Moises Siles (Guest)
on 2010-03-08 21:32
(Received via mailing list)
yep thanks, that should work with "visibility", I have another question 
what
about if the element is with display = 'none' or block. :S
Posted by George Dinwiddie (Guest)
on 2010-03-09 01:16
(Received via mailing list)
If Celerity doesn't expose the functionality you need, you can delve
down into the underlying HtmlUnit to do almost anything.

  - George

Moises Siles wrote:
> 
> 
>             In the particular JS function you posted, it looks like you
> 
>                 how can I execute js code
>                 ---------------------------------------------------------------------
>                 To unsubscribe from this list, please visit:
> 
>                    http://xircles.codehaus.org/manage_email
> 
> 
> 
> 
> 
> 

--
  ----------------------------------------------------------------------
   * George Dinwiddie *                      http://blog.gdinwiddie.com
   Software Development                    http://www.idiacomputing.com
   Consultant and Coach                    http://www.agilemaryland.org
  ----------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.