# Testing Java Script in a View

**URL:** <https://discuss.rubyonrails.org/t/testing-java-script-in-a-view/49217>\
**Category:** rubyonrails-talk\
**Created:** [February 8, 2010, 9:01pm UTC](https://discuss.rubyonrails.org/t/testing-java-script-in-a-view/49217 "2010-02-08T21:01:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [February 8, 2010, 9:01pm UTC](https://discuss.rubyonrails.org/t/testing-java-script-in-a-view/49217/1 "2010-02-08T21: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:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [February 8, 2010, 9:17pm UTC](https://discuss.rubyonrails.org/t/testing-java-script-in-a-view/49217/2 "2010-02-08T21: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:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [February 9, 2010, 1:43pm UTC](https://discuss.rubyonrails.org/t/testing-java-script-in-a-view/49217/3 "2010-02-09T13: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!!!!!!
