Showing posts from September, 2014

Selenium Webdriver With Python

Basic Example

import unittest from selenium import webdriver classLogin(unittest.TestCase):def setUp(self): self.driver = webdriver.Firefox()def tearDown(self): self.driver.quit()def test_login(self): driver = self.driver driver.get('http://testurl') username = driver.find_element_by_name('user_id') username.send_keys('admin')Selecting element from drop down listel =driver.find_element_by_id('id_line') foroption inel.find_elements_by_tag_name('option'): ifoption.text =="line to select": break

Verifying Table Values

#Importing selenium webdriver library 
from selenium import webdriver
#Creating an driver instance of Firefox browser
driver = webdriver.Firefox()   #Accessing the Flipkart site url for the python book

driver.get("") #creating an array object n…

Test Automation with Cucumber & Capybara

We will introduce today Capybara an higher level ATDD testing framework
which support for multiple backends, supports Selenium and works in multiple browsers.

The advantage of using Capybara over selenium is being on higher level than selenium , it can be used for other types of automation beside browser automation without changing the user facing simple and intuitive DSL.
Let’s take for example a simple scenario of typing strings to an input textbox:

Selenium-webdriver snippet
require 'selenium-webdriver' element = driver.find_element :name=> "q" element.send_keys "Cucumber tests"
Capybara snippet

require 'capybara' fill_in "q", "Cucumber tests"
The difference is clear in terms of simplicity and user friendliness which sets apart capaybara from selenium webdriver.Below is complete example for the reference starting from setting up the folder structure.
I. Base Folder

Base Folder Structure where:
features – folder to host all your f…

Cucumber Basics Tutorial

In every cucumber project , first of all there should be root folder which will be a placeholder for all the cucumber files.

For every cucumber project there is a single directory at the root of the project named "features". This is where all of your cucumber features will reside. In this directory you will find additional directories, which is step_definition and support directories
What is "Feature File"? Feature File consist of following components -
Feature: A feature would describe the current test script which has to be executed.Scenario: Scenario describes the steps and expected outcome for a particular test case.Scenario Outline: Same scenario can be executed for multiple sets of data using scenario outline. The data is provided by a tabular structure separated by (I I).Given: It specifies the context of the text to be executed. By using datatables "Given", step can also be parameterized.When: "When" specifies the test action that has…