Thursday, April 10, 2014

0 How to add Watir-Webdriver support in your scripts


First of all you need to install Watir-Webdriver gem on your machine. It’s pretty simple.

Installing watir-webdriver  gem
  • Open command prompt.
  • Type “gem install watir-webdriver”
  • You should see a confirmation message that it is installed. 
Note: If you don’t have selenium-webdriver gem already installed, let me tell you, water-webdriver has selenium-webdriver as a dependent gem.  All the dependent gems for water-webdriver gem would also get installed automatically when you install watir-webdriver.  Remember? In the tutorial Selenium History, we have seen that water-webdriver implements selenium-webdriver. This is the reason why watir-webdriver is dependent on selenium-webdriver.


 
Steps to include the support for watir-webdriver in you scripts
1. Open Aptana Studio.
2. Create a new project if you don’t have one already
a.      Right click on left hand pane of Aptana
b.      Move cursor over “New”
c.      Move cursor over “Ruby Project”
d.      Select “Default Project” from New Project window. Click Next button.
e.      Let the defaults stay for all the fields but enter a suitable project name in Name filed. Click Finish button.




  
3. Create a new ruby file
a.      Right click on left hand pane of Aptana
b.      Move cursor over “New From Template ”
c.      Move cursor over “Ruby”
d.      Move cursor over “Blank File”
e.      Enter a suitable name to your script. Make sure you have “.rb” as extension while adding the name to the script. Click finish.


4. Open script that you have just created from left hand pane.

5. Type the following line of code on top of your script
require “watir-webdriver”

Note: In ruby if we install a gem(library), we can add it to any of our scripts using “require” keyword followed by gem(library) name in quotes.




6.  Now to verify that watir-webdriver is added to your script, just click on run button on Aptana Studio tool panel.



If you see any errors in console, this would mean you did something wrong while configuring or installing watir-webdriver.

7. You don’t believe if technique mention in step 6 is working or not, do you ?
OK let’s clarify our doubt.
Type ‘require howdy’ and click on play button. You would see some errors in console. Now you can confidently believe that technique at step 6 is working and is a proof that watir-webdriver is successfully added to script.


That's all for this session. See you again in next session. 

Happy Testing :) :)
Shiva Krishna Imminni

To sponsor my work and help maintain this site please contact me.

0 comments:

Post a Comment

 

QuestionSelenium Copyright @Shiva Krishna