Create an Alias for Interactive Console Work: Selenium and Capybara


If you are working on shell most of the time Aliases are very helpfull 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 the Selenium with Python and the Capybara with Ruby. You can use several different language for Selenium but Capybara works only with Ruby. Create scripts in a directory called scripts (in your home folder, like as ~/scripts) for your automation tool as following, save them as capybara.rb, sel.py


Creating Aliases

Depends on your favourite shell, you need to add the alias to .bashrc bash shell, config_fish for fish shell and etc. You can see the example for fish and bash shell as following:

For fish: edit ~/.config/fish/config.fish 

alias capybara "irb ~/scripts/capybara.rb"
alias sel "python -i ~/scripts/sel.py" 

For Bash: edit ~/.bashrc 

alias capybara="irb ~/scripts/capybara.rb"
alias sel="python -i ~/scripts/sel.py"

To run it

Open your shell and type sel chrome for Selenium with Chrome and capybara poltergeist is for Capybara with Poltergeist browser. Keep in mind that the scripts are include minimum required library so if you want additional functionalities you can import/require them. 


Other options:
~ sel chrome
~ sel firefox
~ capybara selenium
~ capybara chrome
~ capybara poltergeist

Comments

  1. Testing now a days has become as importnant as developing of an application. With the help of testing, we can find out the potential bugs which would affect the application. Fixing this at a very early stage would help the application to run without any problem.
    Software testing training in Chennai | Software testing training institute in Chennai | Software testing courses in Chennai

    ReplyDelete
  2. Сумки из кожи никогда не стареют, актуальны всегда и при грамотном использовании сливаются практически со всей одеждой. Кожаная сумка выделяется долгим сроком использования и крутым видом. При хорошем уходе сумочка из естественного природного вещества проработает намного дольше, нежели из ситнетического и еще со временем сумочка становится прекраснее, раскрывая свою настоящую красоту. Отобрать кожаную сумку необходимо воспользовавшись каталогом пляжная сумка, ведь там в наличии достаточно вариантов сумочек. В магазине вы найдете отзывы покупателей, которые помогут вам сориентироваться и сделать хороший выбор сумочки.

    ReplyDelete

Post a Comment

Popular posts from this blog

Selenium Error "Element is not currently interactable and may not be manipulated"

Change Default Timeout and Wait Time of Capybara

Page-Object Pattern for Selenium Test Automation with Python

Performance Testing on CI: Locust is running on Jenkins

How to Set Shared Preferences in Espresso Test for Kotlin and Java