UI test automatically by using Selenium-WebDriver for Acceptance Testing

Environment


Case of using Ruby

1. Install gem

Refer from this


2. Install Driver

chromedriver


3. execute test case

% rspec ./test.rb

Where is gems

webdriver, capybara, cucumber store under /Library/Ruby/Gems/2.0.0/gems/.


What is capybara?

Capybara suggest a vocabulary for testing frameworks and can simulate multi web access.

Case of default, driver is rack_test. Case of including JavaScript, driver is Selenium and can access remote server.

This is made by Ruby.

Capybara is not testing framework so you write test case by Turnip, Cucumber, RSpec and so on.


What is cucumber?

Cucumber is BDD (Behavior Driven Development). BDD is much the same as product spec. After make spec, start making test case.

Cucumber can write test case by Japanese(and other language) so familiar for Acceptance Testing.

This use gherkin format so you can write almost natural language. This is made by Ruby.

Japanese is "きゅうり".


What is Turnip?

Turnip is derived from cucumber and more write easy.

This is executed by rspec command.

This do not use regular expression and compare to cucumber, do not difficult.

Japanese is "かぶ".



Case of Turnip

1.



Case of using Python (on the way)

1. Install Python

Install Python from this site.

f:id:hrt0kmt:20150620234710p:plain


f:id:hrt0kmt:20150620234933p:plain


2. Throw path to Python `C:\Python27;`

Control panel > system & security > system > detail system > environment variable

f:id:hrt0kmt:20150621005524p:plain


Confirm path with below command.

>python --version
Python 2.7.10


3. Install Python client

f:id:hrt0kmt:20150621011734p:plain


You can install Python client of selenium from this site.


Please decompress this selenium-2.46.0.tar.gz file from Lhaplus etc.. and you move selenium-2.56.0 > py > selenium to C:¥Python27 > Lib.


f:id:hrt0kmt:20150621013024p:plain


Then you can execute test case.

>python test.py
-
------------------------------------------------------
Ran 2 test in 18.888s

OK



Case of using pip

pip is package management tools.

You can manage python easy by using pip. Example you can simply install or upgrade the Python bindings.

By administrator install pip & selenium.

// install pip for mac
% sudo curl -kL https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
or
% sudo easy_install pip

// install pip for windows
http://www.pip-installer.org/en/latest/installing.html
or
% sudo easy_install pip


!attention

pip make install all source so windows do not work well. Then you can use easy_install.


// install selenium
% sudo pip install -U selenium
!attention

You can not execute selenium or webdriver, maybe your path is wrong so please see this site



Case of Java

1. Install [Node.jp](http://hrt0kmt.hatenablog.com/entry/2015/05/31/183648) and install Selenium Webdriver from npm.

>npm -g install selenium-webdriver

>npm -g install mocha


2. Throw path to Node

  • PATH: C:\Program Files\nodejs\
  • NODE_PATH: C:\Users(ユーザ名)\AppData\Roaming\npm\node_modules


3. Build Selenium-Server

C:\Users\developer\Documents\selenium>java -jar selenium-server-standalone-2.
45.0.jar -Dwebdriver.chrome.driver="C:\Users\INTEREST-MKT\Documents\selenium\chr
omedriver.exe"


4. Execute test case

% node testcase.js

If you have error, please see this.

This book of O'REILLY is maybe useful.



Refer from..

https://www.npmjs.com/package/selenium-webdriver

http://qiita.com/takatama/items/ddaf9e85c71f7f0e922a

http://creator.mynavi-agent.jp/sougou/feature/toolbox/0011.html

http://www.storklab.com/seleniumhq.org/docs/03_webdriver.html

http://futurismo.biz/archives/2431

https://github.com/willnet/capybara-readme-ja

http://stackoverflow.com/questions/9485962/does-python-have-anything-like-capybara-cucumber

http://qiita.com/moriyaman/items/af2a0264adbaaa0d2029

http://magazine.rubyist.net/?0042-FromCucumberToTurnip