If you are working on shell most of the time Aliases are very help full and time saving. For testing purposes you can use Alias for getting ready your test suites. In this post, I want to explain both running Selenium and Capybara on console and creating aliases for each. This post is for Windows machines, if you are using Unix-like see this post.
Creating Scripts for Selenium and Capybara
First of all, it is assumed that you have installed Selenium and Capybara correctly and they work on your machines. If you haven't installed, you can see my previous posts. I am using Capybara with Ruby. You can use several different language for Selenium but Capybara works only with Ruby. Create scripts in a directory called scripts (better to use this all user so the path should look like c:/scripts) for your automation tool as following, save them as capybara.rb and sel.py respectively:
Creating Aliases For Windows
Creating Profile File
For windows we can use PowerShell, we can add for only current user or for all user. My aim is configure this in Jenkins machines so that it will be used for automation engineer to debug failures easily so I set it as for all users:
For current user, create Microsoft.PowerShell_profile.ps1 file by the following command under C:\Users\user.name\Documents\WindowsPowerShell:
For all user, create profile.ps1 file by the following command under $PsHome folder, so first you need to get run $PsHome, but you should use PowerShell (x86)New-Item -path $profile -type file -force
new-item -path $env:windir\SysWOW64\WindowsPowerShell\v1.0\profile.ps1 -itemtype file -force
Writing Alias Description to Profile File
For current user, you should edit the following file:
For all user, you should edit the following file:C:\Users\user.name\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\profile.ps1
Add the following aliases to Profile File:function cp-selenium { irb c:\scripts\capybara.rb selenium }
Set-Alias capybara-firefox cp-selenium
function cp-chrome { irb c:\scripts\capybara.rb chrome }
Set-Alias capybara-chrome cp-chrome