# What's the point of using Selenium?

**URL:** <https://www.ruby-forum.com/t/whats-the-point-of-using-selenium/131604>\
**Category:** Rails\
**Created:** [March 11, 2008, 8:46pm UTC](https://www.ruby-forum.com/t/whats-the-point-of-using-selenium/131604 "2008-03-11T20:46:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 11, 2008, 8:46pm UTC](https://www.ruby-forum.com/t/whats-the-point-of-using-selenium/131604/1 "2008-03-11T20:46:04Z")

</div>

Hello,

I’m wondering why I should use Selenium if I am already testing my  
application using functional and integration tests? Don’t Selenium  
tests merely test the same functionality?

Thanks,  
Ruben

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 11, 2008, 8:50pm UTC](https://www.ruby-forum.com/t/whats-the-point-of-using-selenium/131604/2 "2008-03-11T20:50:48Z")

</div>

Rails integration tests can’t test anything but the most basic HTML  
and full request cycles. They also cannot tell you if your site works  
on Firefox and not IE.

Use Selenium to test things like:

- Ajax calls
- Effects
- Workingness on multiple browsers
- Site usability

Jason

On Tue, Mar 11, 2008 at 3:44 PM, removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 11, 2008, 10:56pm UTC](https://www.ruby-forum.com/t/whats-the-point-of-using-selenium/131604/3 "2008-03-11T22:56:51Z")

</div>

On 11 Mar 2008, at 19:50, Jason R. wrote:

> Rails integration tests can’t test anything but the most basic HTML  
> and full request cycles. They also cannot tell you if your site works  
> on Firefox and not IE.

To elaborate on that, when you’re doing integration/functional tests  
there is no browser involved, therefore you cannot possibly test  
anything that happens in the browser. For example you can test that  
when you make a certain request some rjs is generated to update a  
certain div, but you can’t test that the div in question actually  
exist. You also cannot test any of your javascript.

Fred

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 12, 2008, 2:38am UTC](https://www.ruby-forum.com/t/whats-the-point-of-using-selenium/131604/4 "2008-03-12T02:38:47Z")

</div>

Jason R. wrote:

> Rails integration tests can’t test anything but the most basic HTML  
> and full request cycles. They also cannot tell you if your site works  
> on Firefox and not IE.
> 
> Use Selenium to test things like:
> 
> - Ajax calls
> - Effects
> - Workingness on multiple browsers
> - Site usability

Isn’t testing thru a server and browser to slow for TDD?

I would treat each failure as an opportunity to write a unit-level test

- one  
that efficiently mocks the browser and server. I want an incremental  
test run to  
work in less than a few seconds, and I want an integration to take less  
than a  
minute. The hard, slow tests can run on a build server.

–  
Phlip

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 12, 2008, 8:47am UTC](https://www.ruby-forum.com/t/whats-the-point-of-using-selenium/131604/5 "2008-03-12T08:47:48Z")

</div>

On 12 Mar 2008, at 01:37, Phlip wrote:

> > - Effects  
> > less than a  
> > minute. The hard, slow tests can run on a build server.

That’s all well and good, but the fact is that if you want to test  
what the browser does, you need a browser. For example those tests are  
never going to tell you that you’ve got a typo in your javascript.  
Those tests are a lot slower, so you’re probably not testing  
everything, just some common interactions.

Fred

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 12, 2008, 10:13am UTC](https://www.ruby-forum.com/t/whats-the-point-of-using-selenium/131604/6 "2008-03-12T10:13:46Z")

</div>

I can’t understand the confusion regarding selenium tests. Maybe the  
people are not running heavy ajax sites but if you have any significant  
ajax functionality, it becomes obvious why selenium tests are essential.  
“assert\_select\_rjs” just isn’t going to cut it when you need to  
integration test the entire (list =\> new =\> create =\> list) process and  
its all ajax.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 12, 2008, 2:57pm UTC](https://www.ruby-forum.com/t/whats-the-point-of-using-selenium/131604/7 "2008-03-12T14:57:27Z")

</div>

Frederick C. wrote:

> > I would treat each failure as an opportunity to write a unit-level  
> > test - one  
> > that efficiently mocks the browser and server. I want an incremental  
> > test run to  
> > work in less than a few seconds, and I want an integration to take  
> > less than a  
> > minute. The hard, slow tests can run on a build server.
> 
> That’s all well and good, but the fact is that if you want to test  
> what the browser does, you need a browser.

You need more than one!

> For example those tests are  
> never going to tell you that you’ve got a typo in your javascript.

assert\_javascript works out of unit tests, by parsing the JavaScript. It  
can  
catch simply typos - and of course it should not attempt to evaluate  
that JS, or  
simulate a browser. Its job (like assert\_rjs) is to detect that your  
production  
code has inserted the correct replacement values into the correct  
fields.  
assert\_js\_insert\_html matches rjs.insert\_html, assert\_js\_hide matches  
rjs.hide, etc.

–  
Phlip  
[http://assertxpath.rubyforge.org/](http://assertxpath.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 12, 2008, 4:15pm UTC](https://www.ruby-forum.com/t/whats-the-point-of-using-selenium/131604/8 "2008-03-12T16:15:49Z")

</div>

On 12 Mar 2008, at 13:56, Phlip wrote:

> > That’s all well and good, but the fact is that if you want to test  
> > what the browser does, you need a browser.
> 
> You need more than one!

Indeed. Things like selenium grid, jsunit will run your tests on  
multiple machines/browsers

> fields.  
> assert\_js\_insert\_html matches rjs.insert\_html, assert\_js\_hide  
> matches rjs.hide, etc.

Neato, hadn’t seen that before. It’s still not an end to end test  
though: it only tests a single interaction.
