# Testing Java Script in a View

**URL:** <https://www.ruby-forum.com/t/testing-java-script-in-a-view/183137>\
**Category:** Rails\
**Created:** [February 8, 2010, 10:01pm UTC](https://www.ruby-forum.com/t/testing-java-script-in-a-view/183137 "2010-02-08T22:01:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![railslist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@railslist](https://www.ruby-forum.com/u/railslist)\
**Post date:** [February 8, 2010, 10:01pm UTC](https://www.ruby-forum.com/t/testing-java-script-in-a-view/183137/1 "2010-02-08T22:01:44Z")

</div>

Hello Everybody,

I am a newbie with rails, so please forgive me if I made a mistake.

I have a link in a view that uses java script to toggle a div.

Now, I need to test this. But I simply don’t know how to trigger  
the action of clicking on a link (to toggle the page element) in a test.

I have done an exhaustive search, but it was fruitless.

Any help is much appreciated.

Thanks a lot!!!

---

<div class="post-metadata">

**Author:** ![railslist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@railslist](https://www.ruby-forum.com/u/railslist)\
**Post date:** [February 8, 2010, 10:17pm UTC](https://www.ruby-forum.com/t/testing-java-script-in-a-view/183137/2 "2010-02-08T22:17:36Z")

</div>

Hey,

checkout Selenium ([http://seleniumhq.org/](http://seleniumhq.org/)). You can use that with webrat  
and/or cucumber to test javascript within your browser.

Robert

---

<div class="post-metadata">

**Author:** ![railslist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@railslist](https://www.ruby-forum.com/u/railslist)\
**Post date:** [February 9, 2010, 2:43pm UTC](https://www.ruby-forum.com/t/testing-java-script-in-a-view/183137/3 "2010-02-09T14:43:05Z")

</div>

Robert K. wrote:

> Hey,
> 
> checkout Selenium ([http://seleniumhq.org/](http://seleniumhq.org/)). You can use that with webrat  
> and/or cucumber to test javascript within your browser.
> 
> Robert

Hi Robert,

Thanks for your reply.  
I have heard of it and will definitely give it a shot.

Thanks a lot!!!
