How to set up selenium grid to test Internet Explorer from a Mac or Linux computer

This blog post explains how to set up Selenium Grid to run your selenium-powered tests on another computer or virtual machine. In this example, you currently run an rspec test suite on a Mac using the selenium-webdriver gem, but you’d like your application to work in Internet Explorer. The example application can be found here. I made it for this blog post, and styled the code to be as simple as possible for learning purposes.

Since Internet Explorer doesn’t run on Macs you could install a VM with Windows on it, and test out the site by hand. But by using the instructions in this blog post, you can simply run your existing test suite directly on IE. The instructions can easily be adapted to other operating systems and web browsers.

First, install VirtualBox on your Mac. VirtualBox is free and open source software that runs on Windows, Linux, Mac and other host systems. Go here to download VirtualBox.

Either install a legitimate copy of Windows in a VirtualBox VM, or download one from modern.ie. I don’t recommend pirating Windows, not least because most pirated copies online are full of exploits and viruses and such things. Go here to download a free, legitimate Windows VirtualBox image from Microsoft. If you already have Windows installed using other VM software, that will work fine too. In fact, these instructions will work even if Windows is on a different computer, e.g. if you have a Windows laptop laying around you can use for this.

Launch your Windows VM. Make sure the Windows VM and your Mac can ping each other over the network. If you have trouble with this when using VirtualBox, shut down your Windows VM, then go into the settings for your Windows VM. Choose Network, and for Adapter 1 “Attached to” choose Bridged Adapter. This will place the VM on the same network subnet as your main computer. When you start the Windows VM back up, launch a command prompt by clicking the Start menu and running “cmd”. Then run “ipconfig” to find your IP address. Once your Windows VM and Mac can ping each other, move on to the next step.

Install Java on both your host computer and the Windows VM. Go here to download Java.

Download the Selenium Grid binary jar file to both your Mac and your Windows VM. Go to the following link and click the folder with the highest version number. In that folder, download the file named selenium-server-standalone-????.jar with the ???? replaced by the version number. Go here to download Selenium Grid.

Download the Internet Explorer Driver to your Windows VM only. It is in the same folder as the Selenium Grid binary. The filename for the 32-bit version is IEDriverServer_Win32_????.zip, again with ???? replaced with the latest version number.

On the Windows VM, unzip the IEDriverServer file you downloaded. Then place the .exe file that comes out in a directory in the Windows PATH. One such directory is C:\Windows\.

Now we need one selenium grid hub, and one node. The Mac will be the hub, and Windows will be the node. On the Mac go to the directory with the selenium-server-standalone file you downloaded earlier. Then run (replacing the selenium-server stuff with the actual filename):

java -jar selenium-server-standalone-????.jar -role hub

You will see some console output about “Launching a selenium grid server”. Now go to the url http://localhost:4444/grid/console. You should see that your hub is up and running, but not offering any browsers yet.

Before you begin this step, make a note of your Mac’s IP address. Let’s say it is 192.168.0.3. Now go to your Windows VM and open a command prompt. Navigate to the selenium-server-standalone-????.jar file directory, and execute the following command, replacing the ???? with the proper filename, and 192.168.0.3 with your actual Mac’s IP address:

java -jar selenium-server-standalone-????.jar -role node -hub http://192.168.0.3:4444/grid/register

You should see some terminal output about “Launching a selenium grid node”. Now go back to your grid console webpage and refresh it. The one at http://localhost:4444/grid/console. You should see some web browsers on offer! You now have a selenium grid running.

Now it is time to run a test over the grid. Go to my sample project on github here.

Follow the sample project’s instructions and get the server and tests running locally. Once you have done that, use git to checkout the selenium_grid branch. Then open the spec/index_page_spec.rb file in a text editor. You will see the following code in a before block

@firefox = Selenium::WebDriver.for(:remote, desired_capabilities: :internet_explorer)

@firefox.navigate.to(“http://192.168.0.20:3000“)

Edit the IP address on the navigate.to argument to be your Mac’s IP address. Then in the project’s root directory run bundle exec rspec. In your Windows VM you should see Internet Explorer launch, visit the webpage, and close, followed by rspec reporting that the test passed.

Congratulations! You have set up a minimal selenium grid and run a test using rspec against a local web application. I hope this guide was useful for you, please leave any questions in the comments!

References

The Selenium Grid wiki

Hacker News discussion of this post

Using Selenium and Rspec to test any web application

Recently I set up selenium and rspec to test a single-page javascript application. While building that test suite and teaching the other developers on my team how to use it, I grew frustrated with the minimal documentation for selenium. So today I put together a simple web application and test suite you can use to learn how selenium works. It is fully functional and should allow you to quickly get up to speed.

I kept the web app and the test suite separate to show that one can use rspec and selenium-webdriver to test any kind of web app. Simply start the web app in one terminal and go run the test suite in another terminal. You can even run the test suite against your production system to make sure there were no problems with your last deploy.

Later I will write up how to use Selenium Grid combined with a VirtualBox VM to run your tests against a browser in a different operating system. [Edit: I have now written the post, here it is.] Let me know what you find confusing about selenium and maybe I’ll blog about the answer! Check out the sample app here.

How I used bitcoin to replace wire transfers and save money

I live in Berlin, and I need to send money to the US every month to make student loan payments. I am paid in euros, and my student loans must be paid in US dollars. Because of this I need some way to convert currencies and send money from Europe to the US.

The traditional way to do this is a wire transfer. That is very costly. My US bank, Chase, charges me $15 to receive a wire transfer. My bank in Berlin, Deutsche Bank, charges me 39€ ($48) to send one. Together that is $63 in fees.

Instead of wire transfers, I use bitcoin to send money. First, I use SEPA (the free system Europeans use to send each other money) to send euros to my bitstamp.net account. Once they arrive, I use all the money I sent to buy bitcoin. I then send the bitcoin to my Coinbase account. Once the bitcoin arrives, (which only takes a few minutes) I immediately sell the bitcoin and end up with US dollars in my Chase account.

Bitstamp charges a transaction fee of 0.5% to buy bitcoin. Coinbase charges 1% to sell. Together, that is 1.5% of the amount of money I’m sending. In my case, that is much less than the $63 it cost to send a wire transfer, and this method is saving me over $40 each month with no downsides.

If you were to send more than $4222, then paying $63 would be less than paying 1.5%. If you’re making regular wire transfers I strongly encourage you to use this method and save money.

Economics Study Idea

Open source software projects assume that “many eyes makes all bugs shallow.” However, the recent heartbleed vulnerability in OpenSSL revealed that showstopper bugs can exists for years.

Your paper would look at the biggest, most used open source software projects (like OpenSSL), and examine their development practices. For example, in OpenSSL, there is no proper intermediate code review step in between “random coder commits code” and “code goes out to the world.” In contrast, Chromium has a review step that the original author is completely excluded from, where multiple people read the code.

Once you have categorized review practices, you will examine the number of severe vulnerabilities that have made it past the review and been deployed to the world.

Sadly I can’t see a way to do randomized trials of software development. Coders are expensive and there are only a few projects that are as important and high-stakes as OpenSSL.

Hacker School banning “feigned surprise” is absolutely brilliant

[Since you might wonder while reading this piece what my relationship to Hacker School is: I have no relationship with Hacker School. It has been described to me, and I have devoured the blog. If I made a mistake, let me know.]

The biggest insight I’ve had as a programmer is just how often other programmers are portraying false confidence. My natural approach to problem-solving is Socratic, feeling out different ideas and taking small, well-supported steps. Compare and contrast that with making gigantic pronouncements full of bravado. Writing software is inherently an exercise in managing complexity, which is best done with caution.

The best developers I’ve worked with were willing to admit when they didn’t know something. Of course they could learn quickly. If you meet an arrogant developer who pretends to know everything, be careful. To them, their ego is more important than your software. An insecure person who mixes up their self-worth with their programming ability can be very unpleasant to work with. Sadly, some workplaces and development teams reward bombastic claims made with absolute certainty, even on complex topics.

If you have ability and a strong work ethic, people will notice. You will learn a lot from their reaction. If they react by treating with you with respect, they have strong character. If they react by taking every opportunity to belittle and undermine you, they perceive you as a threat to them. If you aren’t prone to petty jealousy and spiteful thinking, it will be difficult to empathize with people who are. Sadly, you must handle these threats. Declaring yourself “above it all” only makes you an easy target, especially once you gain more responsiblity and therefore power.

“Feigned surprise” (when someone gasps and says something like: “you don’t even know about monads?”) is a method of belittling someone and lording your superiority over them. Every organization says about itself, “we don’t have any rude, unpleasant people here. We’re different!” And during the interview process those people are hidden away. Usually you can only find out the truth by actually working there. But by banning feigned surprise, Hacker School strikes a real blow against unplesant, unproductive behavior, and drives away toxic people. That is a strong signal that Hacker School is the sort of place where someone can program and collaborate in a peaceful atmosphere, and therefore accomplish a great deal.

Edit: Join the Hacker news discussion here

“XOXO-style software”, or, What I learned from trying to build a niche site

A friend of mine is a great fan and supporter of the annual XOXO conference held in Portland, Oregon. According to their website, “XOXO is an experimental festival celebrating independently produced art and technology. We’re bringin’ the love back.” To me, XOXO is about using computers to have fun, and to entertain friends and likeminded people with whimsical software. Looking at the works presented there, I’m reminded of programming before it was my full-time job, when I spent all of my programming time tinkering and gratifying my curiosity, instead of implementing some boring widgit for the twelfth time. It’s a beautiful concept, and I coined the shorthand term “XOXO-style project” for software that would be appreciated by the folks who attend this conference.

A few months ago, I decided to try my hand at being an independent entrepreneur. I followed the directions I found online from successful people with profitable websites, which said to find an underserved market and create a website about it, whether or not you knew anything about the market. But as I was doing the research, I realized that even if I was successful making a niche site, I wouldn’t enjoy the process. I want to write software, and making a niche site requires very little programming or sysadmin ability these days. And writing trumped-up copy about products I don’t believe in isn’t how I want to spend my time, even if it means I don’t have a boss.

My vision of being an independent entrepreneur was hacking on interesting code, and doing XOXO-style projects. The reality was very different and disappointing, but I’m glad I put the time in, because I learned more about myself and what kind of work I prefer. I want to spend my time programming, preferably on my own XOXO-style projects, and given the choice between working for someone else, but writing code all day, and not having a boss but not coding, I’d rather code for someone else than run an independent business where I have to only do businessy stuff like write copy, sell, read emails from customers, etc.

Make scrollbars always visible in OS X

To make scrollbars always visible in OS X, first open System Preferences, and click on General.

general

Then under “Show scroll bars” click the bubble for “Always”

scrollbar2

Follow

Get every new post delivered to your Inbox.