Context is the king! In this post I will explain how operating system environment variables can change the behavior of your selenium-webdriver test scripts.

If you are in network that requires http proxy to get to the internet, gem install or bundle install commands will not work from the command line.

You need to set HTTP_PROXY operating system environment variable. Problem is that selenium-webdriver also reads value of that variable in order to initiate the communication between selenium client and server. At that communication fails. Here is the example:

and the exception:

And to put some ‘testers eyes’ on this issue. Firefox browser will start, and after some time it will close. After that exception is thrown.

Value for proxy server is valid. It was taken from following link, and when you put that value in Firefox, you can browse the web through it.
Proper way to set proxy is to use browser profiles. Here is selenium-webdriver example.

So we need to override http_proxy value in ruby script, because you will still need http_proxy to be active form your command line. You need to set it to nil value:

ENV[‘http_proxy’] = nil

If you are using cucumber, the best place is in env.rb file, in before scenario hook.