Testing Browser Pop-up: Basic Auth with Capybara

I’m working on a project. To protecting public access – we have pop-up port blocked. So, it’s simple to access with automation – without re-writing the same access again and again

#pop_up_auth.rb under steps_defintions

require_relative ‘../../lib/cucumber_helper’

When /^I grant popup access$/ do
visit “http://moteel:mxxxxx3@google.com/users/sign_in?lan=en

And in features block, I just call
Given I grant popup access

Cucumber: Upload file to system

I’m working on a project to practice test automation. So, I’ve choose WordPress.org framework and integrated cucumber + selenium web driver.

New Media Feature:

Feature Screenshot:

Screen Shot 2015-01-26 at 10.27.52 PM

Html Source Code:

<<span class="pl-ent">p</span> <span class="pl-e">id</span>=<span class="pl-s1"><span class="pl-pds">"</span>async-upload-wrap<span class="pl-pds">"</span></span>></div>
<div id="file-upload-html-LC2" class="line"><<span class="pl-ent">label</span> <span class="pl-e">for</span>=<span class="pl-s1"><span class="pl-pds">"</span>async-upload<span class="pl-pds">"</span></span> <span class="pl-e">class</span>=<span class="pl-s1"><span class="pl-pds">"</span>screen-reader-text<span class="pl-pds">"</span></span>>Upload</<span class="pl-ent">label</span>></div>
<div id="file-upload-html-LC3" class="line"><<span class="pl-ent">input</span> <span class="pl-e">type</span>=<span class="pl-s1"><span class="pl-pds">"</span>file<span class="pl-pds">"</span></span> <span class="pl-e">id</span>=<span class="pl-s1"><span class="pl-pds">"</span>async-upload<span class="pl-pds">"</span></span> <span class="pl-e">name</span>=<span class="pl-s1"><span class="pl-pds">"</span>async-upload<span class="pl-pds">"</span></span>></div>
<div id="file-upload-html-LC4" class="line"><<span class="pl-ent">input</span> <span class="pl-e">type</span>=<span class="pl-s1"><span class="pl-pds">"</span>submit<span class="pl-pds">"</span></span> <span class="pl-e">value</span>=<span class="pl-s1"><span class="pl-pds">"</span>Upload<span class="pl-pds">"</span></span> <span class="pl-e">class</span>=<span class="pl-s1"><span class="pl-pds">"</span>button<span class="pl-pds">"</span></span> <span class="pl-e">id</span>=<span class="pl-s1"><span class="pl-pds">"</span>html-upload<span class="pl-pds">"</span></span> <span class="pl-e">name</span>=<span class="pl-s1"><span class="pl-pds">"</span>html-upload<span class="pl-pds">"</span></span>></div>
<div id="file-upload-html-LC5" class="line"><<span class="pl-ent">a</span> <span class="pl-e">onclick</span>=<span class="pl-s1"><span class="pl-pds">"</span>try{top.tb_remove();}catch(e){}; return false;<span class="pl-pds">"</span></span> <span class="pl-e">href</span>=<span class="pl-s1"><span class="pl-pds">"</span>#<span class="pl-pds">"</span></span>>Cancel</<span class="pl-ent">a</span>></div>
<div id="file-upload-html-LC6" class="line"></<span class="pl-ent">p</span>></div>
<div class="line"></div>
<div id="file-upload-html-LC7" class="line">

Now, in step definitions I can write this – to directly show the local file (images, pdf, locations)


<div class="line">When "I upload a file" do</div>
<div id="file-upload_steps-LC2" class="line">attach_file('file','features/upload_files/theme-unit-test-data.xml')</div>
<div id="file-upload_steps-LC3" class="line">end</div>
<div class="line">
<div class="line">When I upload a file</div>
<div class="line">

It works as we have type=”file” and finds and system uploads file to system

Now if we go that way, sometimes it will not work. If we look that source code

Importing XML File:

Screen Shot 2015-01-26 at 10.35.32 PM

Source Code Html:

<label for="upload">Choose a file from your computer:</label> (Maximum size: 32 MB)
<input type="file" size="25" name="import" id="upload">
<input type="hidden" value="save" name="action">
<input type="hidden" value="33554432" name="max_file_size">

Now, in that case, I found it go confused and I needed generic solution to test.

Step definitions:

When /^I upload a "(.+)" file with "(.+)" and located at "(.+)"$/ do |file_name, name_selector, path|
attach_file(name_selector, "#{path}/#{file_name}")


And I upload a "theme-unit-test-data.xml" file with "file" and located at "/Users/sakib/Documents/projects/wp-automation/features/upload_files"


  • WordPress.org (Configured and execute on local server)
  • Cucumber
  • Capybara

Close range idea of Product Price – From Google Engine

As you know, people were looking for product price in several prices. Now google has algorithm which gets the product price (possibly close to) range and if you type “Sharp AQUOS Crystal price”, it will tell you the price of the product.

Screen Shot 2014-09-01 at 10.35.23 PM

With that feature, I’m sure they will kill some mid-level web services traffic so fast. Just like, now we are used to with 2+2 = 4 in google calculation. Similar way, we will not visit to gsmarena or verge to find the prices (maybe we will go for review to get product inside out) but I would prefer to get directly from google engine – even without browsing those official pages :)

Trello has flaws too

Trello is amazing tools and I do use it everyday and I found a bug :)

Let me explain the steps:

  1. Forget password page
  2. Input valid / registered email address
  3. Trello will let you know – “Help is on the way”
  4. Email – You will have email with reset password link
  5. Click to reset password link
  6. You will have seen two (2) fields to set “new password”
  7. Give ABCD and submit
  8. You will have success message
  9. Now use Back Button of browser and go back to the previous shown (2) field page.
  10. Give another password XYZ
  11. And submit – second (2nd) attempts to change the password
  12. You will have messages – you’ve already set the password (means, ABCD – the first one)
  13. Now, try login with username and password ABCD – system won’t allow you
  14. This time, try to login with surname and password XYZ – system will allow you to log into system.

See, if you forget to close the browser. And someone little bit naughty and tricky and the guy can replace your account with his own password :) Isn’t interesting!

Green Cucumber (Test Automation) is fun, errors are challenges

I was doing some work on a portal project, Moteel Portal. A client side solution. It works seamlessly in between several parties and make a sync data distribution for a online booking reservation.

  1. Moteel – Core platform, which stores all the branches, available, unavailable, occupied rooms
  2. Moteel Portal
    1. Corporate Users – Those are already signed with us, they will have special discount rate with us and rate will be shown to them, if they are logged into the portal
    2. Guest Users – They are just normal users/guest, those will who will take booking to our system. We will reserve room for them into the moteel core and branches will be informed, transaction will be made
    3. Registered Portal Users – Guest can be registered to our system with mobile verification and booking online rooms and moteel core will reserve the room and let to know other parties.

Testing the contact form with multiple scenarios