Headless Selenium From Your VM
This morning I asked about installing Firefox/Chrome on CentOS server, so I could run Selenium from my VM; quite honestly, I've never interacted with Selenium before today. I was admittedly ignorant about what Selenium actually did, and even after today know that I still have a lot to learn. After an encouraging nudge from @leedavis81, I decided to try to tackle it.
Priming the Pump
My VM setup is pretty straight-forward, I run Vagrant and created a base box using CentOS 5.8 and installed all the goodies that I needed. Pretty common, so to get started; I ran the following commands.
sudo yum install java sudo yum install Xvfb sudo yum install firefox
Getting Xvfb Configured
So @leedavis81 sent me a link to Stackoverflow, which had a question/answer with a link to a blog post; so I started there (and I'll post the links at the end). The problem with a lot of blog posts like that are the implicit assumptions that are made. Most people get frustrated if their setup isn't the same and they don't get the same results right off the bat. The blog post, I found was a great starting point, but it didn't quite get me to the finish line. So here's how the fine folks at alittlemadness.com got me started...(just now noticed the post was from 2008)
Xvfb :99 -ac export DISPLAY=:99 firefox &
I installed Xorg as the post described
sudo yum install Xorg
You have the selenium server running, PHPUnit and PHPUnit_Selenium installed and configured, Xvfb running on the number of your choice and firefox running in the background; quite a bit going on no? What's next, well now you start running your Selenium tests and you get your feedback! After investing a bit of time in this today, I came to the realization that's really not advantageous to run it headless; but it was a geeky thing to do; and no one that I had talked to told me they had done it before.
Conclusion
I'm sure there is a use case for running Selenium this way that isn't totally crazy; but from what I've seen you're only going to get Firefox out of this equation. There are a lot of things you can verify in one browser, so again not to totally discount it. I'll probably stick to using Selenium on the Mac, but I found this to be an interesting trek into the world of Selenium. If you have a use case that fits the bill here, hopefully this is a help to you. I've linked to the blog posts I used throughout the article, so I've decided not to link them down here. corpocrat.com and alittlemadness.com were the sites though. Let me know what you think though, was this cool? a total waste of time? somewhere between?




Comments
There are no comments