Skip to content

Facebook Login and post share automation using Watir-Webdriver

May 20, 2013

Watir (pronounced as ‘water’) is an open source group of Ruby libraries that allows you to automate browser-based tests of web applications. It is an amazing browser driver, very light weight and simple to use. Any web applications written in any language can be automated with Watir and it simulates browser interactions the same way an end user would.

Unlike most of the other testing tools, it is very easy to setup in your machine, you don’t have to run a server or configure much of anything. You need to run gem install water-webdriver in command prompt and there you have it! Obviously you first need the Ruby installed in your system and then set up the watir-webdriver, but I am not going to detail that here.  Check out for the instructions of installation.

Write your first test script using Watir-Webdribver 

As Watir is built on Ruby scripting language, it’s easier to get into it if you have some knowledge in Ruby. But if you don’t, then too relax! you will love Ruby for its simplicity. Below is an example of  Facebook login and post share automation using Watir-Webdriver and Ruby that followed a very few steps. You will fall in love with Watir when you will see how straight forward it is.

Basically, here is what we are going to do:

Step 1: Open the browser and Navigate to

Step 2: Enter username, password and Login

Step 3: Evaluate Login

Step 4: Share a post

Step 6: Logout

 require "watir-webdriver"

  email: "", # The email you use to sign in to Facebook
  password: "" # The password you use to sign in to Facebook

 browser.goto test_site

 browser.text_field(:id, "email").set signIn[:email]
 browser.text_field(:id, "pass").set signIn[:password]

 if browser.text.include? "" #name of the logged in person goes inside the quotation
  puts "***Login successfull"
  puts "***Error in Login"
 end, "navLink").click
 browser.textarea(:class, "DOMControl_placeholder uiTextareaAutogrow input mentionsTextarea textInput").set("Testing using Watir, its amazing!")
 browser.button(:class, "_42ft _4jy0 _11b _4jy3 _4jy1 selected").click, "navAccountLink").click
 browser.button(:value,"Log out").click

From → Watir

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: