firewatir's execute_script executes in the context of the very top level
exposed by jssh, which is different than the top level that's available to
the web page. in jssh you can control the browser itself to a much greater
extent than is possible through a page (which is how firewatir works).
a top-level variable on the page is defined on the content window object of
the browser. I don't know about in firewatir, but in vapir-firefox (my fork
of firewatir, which I highly recommend over firewatir), your script should
work because execute_script is defined in the context of the content window,
not the top level of the jssh environment.

or you can write your javascript in ruby, something like:
firefox.content_window_object.tinyMCE.get('editor_id').setContent('some
content')

see http://vapir.org/

If you want to stick with firewatir, you'll have to figure out a reference
to the content window object and evaluate your script in that context. I'm
not sure what that would be.


On Sat, Jun 12, 2010 at 23:53, Matt Wiseley <[email protected]> wrote:

> Writing a test that sets content in a TinyMCE instance using a firefox
> browser object. My first attempt was this:
>
> firefox.execute_script("tinyMCE.get('editor_id').setContent('some
> content')")
>
> This raises "JsshSocket::JSReferenceError:  tinyMCE is not defined"
> even though the exact same code works if entered into Firebug.
>
> There's another post here about doing this with IE, getting the
> editor's element by ID, setting focus, and typing stuff into it - that
> doesn't work with the Firefox browser object.
>
> So here's what I've got working:
>
> firefox.goto("javascript:tinyMCE.get('editor_id').setContent('some
> content')")
> firefox.back
> firefox.wait
> # now I can submit the form and the value gets passed from TinyMCE
>
> Anyone know why execute_script doesn't see the tinyMCE JavaScript
> object? Is it running in some other context? Anyone have a more
> elegant way of doing this?
>
> If not, this works for the next guy trying to do it.
>
> MW
>
> --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> You received this message because you are subscribed to
> http://groups.google.com/group/watir-general
> To post: [email protected]
> To unsubscribe: 
> [email protected]<watir-general%[email protected]>
>

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: [email protected]
To unsubscribe: [email protected]

Reply via email to