@Bryce, Selenium is great, but I don't think it will ever replace unit or functional tests. It works very well for testing the flow between multiple pages, javascript, and making sure the full stack of your app works. I would not use it for testing complicated business logic or numerous edge cases.
AFAIK, out of the box this doesn't work with autotest, but I'm sure it's possible to hack that functionality together somehow. I haven't tried.
I personally wouldn't find autotest support very useful. To me acceptance tests are something that don't have to be run as often as unit or functional tests. However I'm still trying to figure out how best to fit Selenium into my workflow.
I can't install git on my laptop. It's an old Lombard with Panther 10.3. I downloaded the selenium-on-rails package from the github website, but I'm not sure how to install it. It includes one very long filename. Can anyone show me how to install it?
It is indeed useful to test the flow, from functionality perspective. But most of the time we have problem with different browsers that the visual presentation of web pages differ a lot. Say it looks most of the time OK in FF, but just bad in IE. And the javascript is not surely to work on different browsers either. Can Selenium help on those issues?
@Quincy you likely downloaded the ".tar" file. You'll need to uncompress this. Once you do you'll end up with a folder with the plugin inside. Rename the folder to 'selenium-on-rails' and move it into your vendor/plugins directory and you should be good to go.
@Yuchen testing the visual look of the page would be hard to do programatically with any tool. You may want to try scripting Selenium to take a screenshot when going to certain pages. Then you can quickly review all of these. I haven't looked into this so I'm not sure how difficult/possible it is.
As for testing Javascript, Selenium can certainly do this (as I show in the episode) and I find it to be one of the big reasons to use it.
Great screencast. I've been using Selinium for about a year now, good product and getting better all the time. About 2 weeks ago I posted a small description of how I'm testing www.graphsy.com with selenium. If anyone is interested you can check it out at:
http://www.blog.graphsy.com/?p=18
In that post I try to show how mouse events can be simulated and tested for in selenium.
Thanks for a great screencast, more people need to know about selenium.
I would be interested if anyone has any thoughts of how and when to integrate Selenium alongside a BDD workflow, especially when using Rspec and Rails.
I've been preparing to write some Rspec user stories for my app, but my first impressions of Selenium are making me think again. Selenium seems to be much quicker, more intuitive and more comprehensive by including the browser into the equation.
The only thing that's holding me back from jumping headfirst into Selenium right this minute is the fact that its geared up for testing rather than specing and I'm rather keen on the BDD conventions.
James, I think you can kind of do BDD testing with selenium, as long as you first prototype what your front end looks like. If you make the views you want to use, or at least stay consistent with you ID values of ways of referencing fields you can write selenium cases for them before actually implementing anything. Though, then you will need to write everything by hand and the Selenium IDE will not be as useful. My development process tends to be just that, first prototype the front end, then make selenium cases for it, and then hook it up to the back end. Hope that helps.
I found I always get false on assertTextPresent (assert_text_present) and verifyTextPresent (verify_text_present) with selenium_on_rails while the same test passes with Selenium-IDE.
Do you have any ideas ?
I'm trying on both the original selenium_on_rails with rails-2.0.2 and your git version with rails-2.1. But the results are same...
Anyway, this episode is great.
Thank you very much.
/rorApp/application/vendor/rails/activesupport/lib/active_support/dependencies.rb:115:in `qualified_const_defined?': "Plugins::Selenium-on-rails::Lib" is not a valid constant name! (NameError)
Any ideas? Rails 2.1 with ryanb modified selenium plugin.
Since my comment, above, I have found quite a few people who are working with both Rspec and Selenium. I did try to post a comment with links to relevant pages, but Akismet thought it was spam. If anyone is interested in working with both these tools and integrating Selenium into a BDD workflow, then just google "Rspec and Selenium" and some interesting projects come up.
Have you tried Watir? I've been using that for a while now. The API is much better than Selenium. I know that Brett P. is working hard on getting Firefox(Firewatir) compatible with IE Watir Scripts.
I always got a `draw_without_selenium_routes': stack level too deep (SystemStackError)
in test_environment and then it stops? Any ideas how to fix this?
-- Frisee
Off topic, but after installing Selenium 1.0b2 from the link you provided into Firefox 3.04, I am now getting endless "spam popups". Even with Firefox's "block popups" turned on.
I'll ask around in the Firefox / Selenium/ google, but if anyone else has encountered this, or has any info I'd greatly appreciate finding out how to kill this malware.
While running "rake test:acceptance" on console I am getting this error
***************
rake aborted!
uninitialized constant SeleniumOnRailsConfig::ERB
*******************
Could you please show me links for Selenium in Rails as Am using the beta for Rails 2.2
In vendor/plugins/selenium_on_rails/lib/selenium_on_rails_config.rb (note the name of the plugin - if it's selenium-on-rails, you will have other errors!)
I got a question, I've already written my .rsel file and I would like to pass it a parameter to specify wich product to test. Does someone have an idea?
As a follow up -- Sauce Labs has cloud-hosted Selenium, and provides a drop-in Selenium RC replacement that can be called from Ruby scripts. You can learn more at http://saucelabs.com/ .
Someone please help urgently,
I added a patch for the plugin selenium_on_rails for rails 2.2.2 from Selenium test runner and simple test cases working fine.
But method include_partial is not working in my rselenese test case
include_partial 'login', :name => 'user1', :password => 'password'
error
NoMethodError in Selenium#test_file
Showing test/selenium/login/invalid_login_test.rsel where line #1 raised:
private method `split' called for #<Hash:0x7ea9708>
Anton, on this
`parent_name': can't modify frozen object
error - I just had the same with Rails 2.2, and managed to fix it with class caching setting:
config.cache_classes = true
Just AMAZING!
if you know java and junit inside eclipse or other testing environments from other languages you really know how useful such and IDE can be.
Selenium is really really cool.
THX Ryan for that screencast.
FINALLY! I've been waiting for ages to have a good screencast on Selenium. Can't wait to see this.
Cheers, Ryan!
Nice! Running from a rake task it's very usefull!
Must try this!
Thanks a lot Ryan for this intro to Selenium! What a great tool to compliment the current test suite and enhance UI testing.
Do you think this will eventually replace the built in rails test suite? Will it work with autotest?
Thanks again for the great screencasts
Bryce
Hopefully we will see your forked changes incorporated back in to the plugin. Thanks for your work on this.
@Bryce, Selenium is great, but I don't think it will ever replace unit or functional tests. It works very well for testing the flow between multiple pages, javascript, and making sure the full stack of your app works. I would not use it for testing complicated business logic or numerous edge cases.
AFAIK, out of the box this doesn't work with autotest, but I'm sure it's possible to hack that functionality together somehow. I haven't tried.
I personally wouldn't find autotest support very useful. To me acceptance tests are something that don't have to be run as often as unit or functional tests. However I'm still trying to figure out how best to fit Selenium into my workflow.
I can't install git on my laptop. It's an old Lombard with Panther 10.3. I downloaded the selenium-on-rails package from the github website, but I'm not sure how to install it. It includes one very long filename. Can anyone show me how to install it?
It is indeed useful to test the flow, from functionality perspective. But most of the time we have problem with different browsers that the visual presentation of web pages differ a lot. Say it looks most of the time OK in FF, but just bad in IE. And the javascript is not surely to work on different browsers either. Can Selenium help on those issues?
@Quincy you likely downloaded the ".tar" file. You'll need to uncompress this. Once you do you'll end up with a folder with the plugin inside. Rename the folder to 'selenium-on-rails' and move it into your vendor/plugins directory and you should be good to go.
@Yuchen testing the visual look of the page would be hard to do programatically with any tool. You may want to try scripting Selenium to take a screenshot when going to certain pages. Then you can quickly review all of these. I haven't looked into this so I'm not sure how difficult/possible it is.
As for testing Javascript, Selenium can certainly do this (as I show in the episode) and I find it to be one of the big reasons to use it.
Very Cool.
Nice changes to the 2.1 git version.
I've watched almost all of your casts and look forward to them every week.
Thank you very much
Ben
PS i love the new intro sound, ;-)
Great screencast. I've been using Selinium for about a year now, good product and getting better all the time. About 2 weeks ago I posted a small description of how I'm testing www.graphsy.com with selenium. If anyone is interested you can check it out at:
http://www.blog.graphsy.com/?p=18
In that post I try to show how mouse events can be simulated and tested for in selenium.
Thanks for a great screencast, more people need to know about selenium.
Another great screen cast. Keep up the nice work!
test
Thank you Ryan!
I would be interested if anyone has any thoughts of how and when to integrate Selenium alongside a BDD workflow, especially when using Rspec and Rails.
I've been preparing to write some Rspec user stories for my app, but my first impressions of Selenium are making me think again. Selenium seems to be much quicker, more intuitive and more comprehensive by including the browser into the equation.
The only thing that's holding me back from jumping headfirst into Selenium right this minute is the fact that its geared up for testing rather than specing and I'm rather keen on the BDD conventions.
James, I think you can kind of do BDD testing with selenium, as long as you first prototype what your front end looks like. If you make the views you want to use, or at least stay consistent with you ID values of ways of referencing fields you can write selenium cases for them before actually implementing anything. Though, then you will need to write everything by hand and the Selenium IDE will not be as useful. My development process tends to be just that, first prototype the front end, then make selenium cases for it, and then hook it up to the back end. Hope that helps.
Hi
I found I always get false on assertTextPresent (assert_text_present) and verifyTextPresent (verify_text_present) with selenium_on_rails while the same test passes with Selenium-IDE.
Do you have any ideas ?
I'm trying on both the original selenium_on_rails with rails-2.0.2 and your git version with rails-2.1. But the results are same...
Anyway, this episode is great.
Thank you very much.
Hey
/rorApp/application/vendor/rails/activesupport/lib/active_support/dependencies.rb:115:in `qualified_const_defined?': "Plugins::Selenium-on-rails::Lib" is not a valid constant name! (NameError)
Any ideas? Rails 2.1 with ryanb modified selenium plugin.
Renamed /plugins/selenium-on-rails to selenium_on_rails and all ok :).
Maxim, Thanks for your thoughts.
Since my comment, above, I have found quite a few people who are working with both Rspec and Selenium. I did try to post a comment with links to relevant pages, but Akismet thought it was spam. If anyone is interested in working with both these tools and integrating Selenium into a BDD workflow, then just google "Rspec and Selenium" and some interesting projects come up.
Have you tried Watir? I've been using that for a while now. The API is much better than Selenium. I know that Brett P. is working hard on getting Firefox(Firewatir) compatible with IE Watir Scripts.
Hey thanks for the video Ryan. Awesome little tutorial. I had previously installed Selenium inside my Rails projects by following the writeup here:
http://siannopollo.blogspot.com/2007/02/selenium-and-ruby-they-actually-work.html
Works very well, but not quite as flexible and versatile as this method. Thanks
Hi!
Thanks for great screencast!
Any ideas how to use it to test app which serves different subdomains eg using account_location plugin?
--Yury
This is a really nice screencast. Testing should be pushed more and more. To many projects fail due to poor testing. Many thanks!
I always got a `draw_without_selenium_routes': stack level too deep (SystemStackError)
in test_environment and then it stops? Any ideas how to fix this?
-- Frisee
It seems that this doesn't work for Rails 2.2+ yet. Eric hasn't gotten around to fixing it, either. Any ideas, Ryan?
http://clearspace.seleniumhq.org/thread/15609
Off topic, but after installing Selenium 1.0b2 from the link you provided into Firefox 3.04, I am now getting endless "spam popups". Even with Firefox's "block popups" turned on.
I'll ask around in the Firefox / Selenium/ google, but if anyone else has encountered this, or has any info I'd greatly appreciate finding out how to kill this malware.
thx
Mike
I can't use ActiveRecord in rsel files...
Without any ActRec's like
product = Product.first
everything works fine, if I insert anything (like "Product.new()" or "Product.find(1)" or whatever (doesn't matter what class I use) I always get a
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/module/introspection.rb:9:in `parent_name': can't modify frozen object
vendor/plugins/selenium-on-rails/lib/selenium_on_rails/rselenese.rb:29:in `render'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/module/introspection.rb:31:in `parent'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:88:in `const_missing'
(eval):9:in `render'
...
I found that XPather is an excellent add-on for writing locators, especially when trying to write and debug tests.
https://addons.mozilla.org/en-US/firefox/addon/1192
Hey All,
Someone, please help me on this urgently.
While running "rake test:acceptance" on console I am getting this error
***************
rake aborted!
uninitialized constant SeleniumOnRailsConfig::ERB
*******************
Could you please show me links for Selenium in Rails as Am using the beta for Rails 2.2
Am new to this.....
Please....
@Binod
Here's how I fixed that error:
In vendor/plugins/selenium_on_rails/lib/selenium_on_rails_config.rb (note the name of the plugin - if it's selenium-on-rails, you will have other errors!)
Underneath "include 'yaml'", put "include 'erb'"
voila with extra sauce!
I got a question, I've already written my .rsel file and I would like to pass it a parameter to specify wich product to test. Does someone have an idea?
Thanks
As a follow up -- Sauce Labs has cloud-hosted Selenium, and provides a drop-in Selenium RC replacement that can be called from Ruby scripts. You can learn more at http://saucelabs.com/ .
Someone please help urgently,
I added a patch for the plugin selenium_on_rails for rails 2.2.2 from Selenium test runner and simple test cases working fine.
But method include_partial is not working in my rselenese test case
include_partial 'login', :name => 'user1', :password => 'password'
error
NoMethodError in Selenium#test_file
Showing test/selenium/login/invalid_login_test.rsel where line #1 raised:
private method `split' called for #<Hash:0x7ea9708>
Anton, on this
`parent_name': can't modify frozen object
error - I just had the same with Rails 2.2, and managed to fix it with class caching setting:
config.cache_classes = true
it's a good application. Thanks.I am hoping the same best work from you in the future as well.
The selenium tests on the demo app of this episode doesn't work [rails 2.3.8, ruby 1.8.7].
Trace: http://pastebin.com/RSWDeZp6
Screenshot: http://is.gd/iPbXd
Thanks
There should be a revised episode for this, or are there better options to use nowadays?
I second the comment above, this episode should be revised, please!