Raveendran

Nothing is impossible…

Hit Count

SEP Custom HTML report for 84,791 hits 5 2012 Ruby(Watir/) Base Automation framework RSS Links Requirement:

RSS - Posts Sample HTML report for any ruby based Automation Testing Framework RSS - Comments Installation/Changes :

1. Create code.rb file and paste the below code. Search … 2. Create folder named as Results in the same location.

Code: My Tags

def get_time_name Acts_as_attachment autoitx3.dll cheat sheet $time=Time.now cuRF error excel gem $time_name="#{$time.hour.to_s}-#{$time.min.to_s}-#{$time.sec.to_s}-#{$time.day.to_s}- height highline image save image scrap #{$time.mon.to_s}-#{$time.year.to_s}" $result_date = "#{$time.day.to_s}-#{$time.month.to_s}-#{$time.year.to_s}" Jazzez jazzezravi manual testing end pagination pagination in rails plugin in rails QA def create_report get_time_name rails rasta raveendran ror @result_file_name="Report"+"-"+$time_name @full_file_name="Results/#{@result_file_name}." rspec rspec watir Ruby ruby $report=File.open(@full_file_name,'w') end excercise ruby gem ruby def insert_head_title(title) gems Ruby solutions ruby watir- $report.puts " #{title} webdriver save_images selenium " selenium-webdriver selenium- end webdriver ruby selenium ide selenium def start_table ruby selenium webdriver code $report=File.open(@full_file_name,'a') $report.puts "

Spreadsheet Testing Updation in rails watir watir-webdriver web driver width bankbazaar " $report.close end BankBazaar def insert_reportname_date(name,date) $report.puts "

Personal Muthu Selvan

Political Lines

#{name}
Self Confidence

Srikanth Date: #{date}

" $report.close What I am doing ? end

def report_row(*details) Custom HTML report for $report=File.open(@full_file_name,'a') Ruby(Watir/Selenium) Base Automation name=details[0] framework wp.me/p5FW9-c6 1 day ago desc=details[1] How to zip the Folder using Ruby How to zip the Folder using Ruby browser=details[2] wp.me/p5FW9-c3 1 week ago result=details[3] reason=details[4] Ruby Gem xml-simple wp.me/p5FW9-bZ if result.downcase == "pass" 1 week ago $report.puts "

" else $report.puts "" end $report.close end def close_table $report=File.open(@full_file_name,'a') $report.puts "
Test Case NameTest Case DescriptionBrowser Name Result Remarks
#{name} #{desc} #{browser} #{result} #{reason}
#{name} #{desc} #{browser} #{result} #{reason}

" $report.close end def summary_report(overall,passed,failed) http://www.box.net/static/flash/widget_player.swf $report_overall=overall $report_pass=passed $report_fail=failed $report=File.open(@full_file_name,'a') Follow Blog via Email $report.puts "

Total Test cases : #{$report_overall}

Enter your email address to follow this blog

Passed : #{$report_pass}

and receive notifications of new posts by

Failed : #{$report_fail}

email. " Join 563 other followers $report.close end create_report Follow insert_head_title("Raveendran -- Sample HTML Report") insert_reportname_date("My Test Report",$result_date ) start_table report_row("Check Google Home Page","Check The Title in Google Home Page","IE","PASS","Title Present") report_row("Check Google Home Page","Check The Title in Google Home Page","FF","FAIL","Title Not Present") close_table summary_report(2,1,1)

Output HTML File: By raveendran • Posted in cheat sheet, QA, Ruby, Ruby 1.9, ruby excercise, selenium, selenium-webdriver, Selenium- webdriver, watir, watir-webdriver • Tagged automation html ruby, automation ruby, framework html, html report, reusable report, reuse html report, ruby framework, ruby html, ruby html report, sample html report, selenium html, watir html, watir html report, webdriver html

AUG How to zip the Folder using Ruby 30 2012 Step 1 – Install ruby-zip gem >gem install ruby-zip

Step 2 – Create the folder named as “Chrome” and puts 5 files within that folder

Step 3 – create code.rb file and put the below code with in the ruby file def zip_it(path) require '' require 'zip/zip' require 'zip/zipfilesystem' path.sub!(%r[/$],”) archive = File.join(path,File.basename(path))+’.zip’ FileUtils.rm archive, :force=>true

Zip::ZipFile.open(archive, ‘w’) do |zipfile| Dir["#{path}/**/**"].reject{|f|f==archive}.each do |file| zipfile.add(file.sub(path+’/',”),file) end end end zip_it(“chrome”)

Step 4 – Run the Ruby File

Output :

Chrome/Chrome.zip file created

By raveendran • Posted in zip • Tagged folder zip, ruby zip file, ruby-zip, zip folder

AUG Ruby Gem xml-simple 29 2012 Code:

1. Create test.xml file Ex. D:\xml\test.xml

2. Copy the XML content from http://msdn.microsoft.com/en- us/library/windows/desktop/ms762271(v=vs.85).aspx and paste in to test.xml file

3. Install xml-simple library CMD — >gem install xml-simple

4. Create new Ruby File code.rb Ex. D:\xml\code.rb require 'rubygems' require 'xmlsimple' config = XmlSimple.xml_in('test.xml', { 'KeyAttr' => 'name' }) i=0 while i < 12 puts config["book"][i]["id"] puts config["book"][i]["title"] puts config["book"][i]["author"] puts "------" i+=1 end

Output : bk101 XML Developer’s Guide Gambardella, Matthew ———————– bk102 Midnight Rain Ralls, Kim ———————– bk103 Maeve Ascendant Corets, Eva ———————– bk104 Oberon’s Legacy Corets, Eva ———————– bk105 The Sundered Grail Corets, Eva ———————– bk106 Lover Birds Randall, Cynthia ———————– bk107 Splish Splash Thurman, Paula ———————– bk108 Creepy Crawlies Knorr, Stefan ———————– bk109 Paradox Lost Kress, Peter ———————– bk110 Microsoft .NET: The Programming Bible O’Brien, Tim ———————– bk111 MSXML3: A Comprehensive Guide O’Brien, Tim ———————– bk112 Visual Studio 7: A Comprehensive Guide Galos, Mike ———————–

By raveendran • Posted in Blogroll, Ruby, xml • Tagged ruby xml, ruby xml-simple, software-development, xml ruby simple, xml-simple

AUG Drag and Drop using Watir-webdriver 27 2012 Requirement :

Drag and Drop an element to the particular location

Code: require 'rubygems' require ‘watir-webdriver’ browser=Watir::Browser.new :ie browser.goto("http://devfiles.myopera.com/articles/735/example.html") my_element=browser.li(:text,'Art Brut') target=browser.ul(:id,'Rej').li(:text,'None') my_element.fire_event("onmousedown") driver=browser.driver driver.action.click_and_hold(my_element.wd).perform sleep 2 driver.action.move_to(target.wd).perform sleep 2 target.fire_event("onmouseup")

By raveendran • Posted in Prawn, Proxy server -- Registry, ramaze, random names • Tagged drag, drag and drop, drop, selenium drag, selenium drag and drop, watir drag, watir drop, webdriver drag and drop, webdriver drag item

JUL Get the Version detail of opened 27 2012 Selenium/Watir Webdriver Browser Code for Selenium WebDriver IE Browser : require 'rubygems' require 'selenium-webdriver' br=Selenium::WebDriver.for :ie ie=br.execute_script("return navigator.userAgent;")

# Ex. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C)" puts ie.split("MSIE ")[1].split(";")[0]

OUTPUT –> 9.0

——————————————————————————————————————————————-

Code for Selenium WebDriver Browser : require 'selenium-webdriver' br=Selenium::WebDriver.for :ff ff=br.execute_script("return navigator.userAgent;")

# Ex. "Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0" puts ff.split("/")[-1]

OUTPUT –> 12.0

——————————————————————————————————————————————-

Code for Watir WebDriver IE Browser : require 'rubygems' require 'watir-webdriver' br=Watir::Browser.new :ie ie=br.execute_script("return navigator.userAgent;") puts ie.split("MSIE ")[1].split(";")[0]

OUTPUT –> 9.0

——————————————————————————————————————————————-

Code for Watir WebDriver Firefox Browser : require 'rubygems' require 'watir-webdriver' br=Watir::Browser.new :ff ff=br.execute_script("return navigator.userAgent;") puts ff.split("/")[-1]

OUTPUT –> 12.0

——————————————————————————————————————————————-

By raveendran • Posted in Ruby, selenium, Selenium-webdriver, watir • Tagged browser version, collect version detail, execute_script, ff version selenium-webdriver, ff version watir, ff version watir-webdriver, get browser version, ie version, ie version selenium-webdriver, ie version watir-webdriver, selenium, selenium-webdriver, watir, watir-webdriver JUL Verify the Element Height/Width in 1 26 2012 different browser dimensions using Selenium/Watir Webdriver Selenium WebDriver Code : require 'rubygems' require 'selenium-webdriver' browser=Selenium::WebDriver.for :ie browser.navigate.to(“google.com”) width1=browser.find_element(:id,’hplogo’).style(“width”) height1=browser.find_element(:id,’hplogo’).style(“height”) browser.manage.window.resize_to(200,600) width2=browser.find_element(:id,’hplogo’).style(“width”) height2=browser.find_element(:id,’hplogo’).style(“height”) if width1=width2 puts “Test Case Passed : Width is not changed” else puts “Test Case Failed : Width is changed” end if height1=height2 puts “Test Case Passed : Height is not changed” else puts “Test Case Failed : Height is changed” end browser.close

OUTPUT:

Test Case Passed : Width is not changed Test Case Passed : Height is not changed

Watir WebDriver Code : require 'rubygems' require 'watir-webdriver' browser=Watir::Browser.new :ie browser.goto(“google.com”) width1=browser.div(:id,’hplogo’).style(“width”) height1=browser.div(:id,’hplogo’).style(“height”) browser.window.resize_to(200, 200) width2=browser.div(:id,’hplogo’).style(“width”) height2=browser.div(:id,’hplogo’).style(“height”) if width1=width2 puts “Test Case Passed : Width is not changed” else puts “Test Case Failed : Width is changed” end if height1=height2 puts “Test Case Passed : Height is not changed” else puts “Test Case Failed : Height is changed” end browser.close

OUTPUT:

Test Case Passed : Width is not changed Test Case Passed : Height is not changed

By raveendran • Posted in Automation, cheat sheet, maximize, resize window, Ruby, selenium, selenium-webdriver, Selenium- webdriver, watir-webdriver • Tagged automation, element height, element width, height, resize window, selenium-webdriver, watir, watir-webdriver, width

JUN Automatically Sending Email(from Gmail) 22 2012 using tlsmail Ruby gem -

Installation:

1. Install Ruby 2. Install Ruby gem tlsmail CMD>gem install tlsmail

Code: def send_mail_to(to,contents) require 'rubygems' require 'tlsmail' require 'time' from = '[email protected]' p = 'GMAIL PASSWORD' content = <

#{contents}

Regards, Your Name EOF

Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) Net::SMTP.start(‘smtp.gmail.com’, 587, ‘gmail.com’, from, p, :login) do |smtp| smtp.send_message(content, from, to) end end send_mail_to(“Receiver Email Id”, “Hi, test Email”)

Output:

Check Your Sent Items list.

By raveendran • Posted in email, Ruby, Ruby 1.9, tlsmail • Tagged automatic email, automatic gmail using ruby, gem install tlsmail, gmail, gmail ruby mail send, Ruby, ruby gmail, ruby mail, send gmail ruby, send mail ruby, sending mail using ruby, tlsmail

JUN Watir-webdriver installtion issue with ffi 19 2012 in Windows - watir-webdriver Installtion issue with ffi in Windows:

1. Install ruby

2. Install the gem watir-webdriver from command prompt a. CMD>gem install watir-webdriver C:\Users\admin>gem install watir-webdriver Fetching: watir-webdriver-0.6.1.gem (100%) Fetching: ffi-1.0.11.gem (100%) ERROR: Error installing watir-webdriver: The 'ffi' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit from ‘http://rubyinstaller.org/downloads’ and follow the instructions at ‘http://github.com/oneclick/rubyinstaller/wiki/Development-Kit’

C:\Users\admin>

3. To Reolsve the issue, we need to install the ffi previous version gem.

4. CMD>gem install ffi -v1.0.9

5. Once ffi installed successfully, then install watir-webdriver again

a.CMD>gem install watir-webdriver

By raveendran • Posted in Ruby, watir-webdriver • Tagged Error installing watir-webdriver, ffi, ffi -v1.0.9, ffi 1.0.11, ffi error, ffi installation, Please update your PATH to include build tools, The 'ffi' native gem requires installed build tools, watir-webdriver installation

JUN Maximizing the Browser in Watir- 1 15 2012 WebDriver -

Maximize the Watir-WebDriver Web Page :

require 'rubygems'

requier ‘watir-webdriver’

browser= Watir::Browser.new :ie

width = browser.execute_script(“return screen.width;”) height = browser.execute_script(“return screen.height;”) browser.driver.manage.window.move_to(0,0) browser.driver.manage.window.resize_to(width,height)

By raveendran • Posted in maximize, Ruby, watir-webdriver • Tagged browser maximize, maximize, watir-webdriver maximize, watir-webdriver window maximize

JUN How to install/register AutoItX3.dll ? 1 15 2012 -

Steps to install/register AutoItx3.dll file in windows machine:

1. Download AutoItX3.dll file from the link http://www.2shared.com/file/6zR7bTlq/AutoItX3.html

2. After download completes, Copy & paste it in c:\autoit\PASTE HERE (c:\autoit\AutoItX3.dll)

3. Open Command Prompt as an ‘Adminstrator’

4. In Command Prompt>cd c:\windows\systems32 [Press Enter]

5. c:\windows\systems32>regsvr32 c:\autoit\AutoItX3.dll [Press Enter]

6. Prompt will appear with message “registration Succeeded”

By raveendran • Posted in Autoit, Ruby • Tagged autoit, autoitx3.dll, regsvr32, regsvr32 autoitx3.dll

Older posts

Blog at WordPress.com. | Theme: iTheme2 by Themify. Follow

Follow “Raveendran” Get every new post delivered to your Inbox.

Join 563 other followers

Enter your email address

Sign me up

Powered by WordPress.com