Archive for December, 2008

Virtualized Storage Strategies

photoCitrix Meetups > Silicon Valley Citrix Professionals Group

We’re looking forward to starting off the year looking to get the most out of our existing storage investments with some candid conversations and best practices discussions. We’ll have a number of experts in this area including vendors and Citrix provessionals…AND YOU! So bring your thoughts on what’s work, and what hasn’t, in your enviroment regarding storage solutions and virtualization. Of course our presentations and panel discussions will be followed by general networking and gloves off sharing between MeetUp members. Looking forward to seeing you all there and meeting some new folks as well so, spread the word. See you in February!cool

Milpitas, CA 95035 – USA

Thursday, February 19 at 3:30 PM

Attending: 14

Details: http://citrix.meetup.com/18/calendar/9403857/

]]>

Post to Twitter Tweet This Post

Document Object Model(DOM) and QTP – A complete guide.

What is Document object Model?

Wikipedia defines Document Object Model(DOM) as:

A platform- and language-independent standard object model for representing HTML or XML and related formats.

For QTP’s sake, I would redefine it to make it simpler. DOM is a method for QTP engineers to access the source (IE –> View –> Source) of any webpage direct through VB Scripting.

When can we use DOM?

One of the very important places you can use it is when a QTP web table checkpoint doesn’t show you the desired content in a cell. I mean the content in the cell is in a format that is not supported by the web table checkpoint. Another use can be when you want to access all the HTML tags used in a webpage. You can get the names, the innertext, innerHTML property of all these tags. The possibilities are endless.

How can we use DOM to access the source page?

We can access the source page of any webpage using .object notation.

Any practical example of using DOM?

I have created a demo web page to show you document object model in action. Say you want to find the font color used for writing Happy Holidays Everyone in cells of the webtable given on this page. The algorithm would be:

  1. Access the DOM of webtable using .object notation.
  2. Access the tagname corresponding to the property you wish to find out. In our case tagname is “font” and property to be explored is “color”. Document Object Model QTP
  3. Find the count of total number of tags and loop it find out the font-color.

The corresponding VB script would be:

Using DOM to find the font color

 
Now it’s quiz time. On the same page find out the src of all the images used in the table. Let me know your script through the comments below.

[Also note that src won’t show up in the webtable checkpoint (for obvious reasons!)]

So, what does src say to you?

I wish you Happy Holidays 2009! :)

Post from: Learn QTP

Document Object Model(DOM) and QTP – A complete guide.

Related posts:

  1. Understanding object repositories in QTP 9.x series
  2. Video: How to create a table checkpoint?
  3. Quiz: Find the difference between these VBScript codes?

Post to Twitter Tweet This Post

For Beginners in Software Testing

uTest

I come across a lot of questions where freshers to software testing want a hands-on project to work with. Most of them are in a kind of catch-22 situation. Without experience no one gives them a software testing job (project) and without job they can’t get experience.

Enter uTest. It is a marketplace that provides companies with on-demand testing services, sourcing software testers from around the world. These testers do not physically work from utest offices rather they work from their home — online. So, even if you are from a remote village you can join. You just need a decent internet connection, a computer and analytical brain to find bugs in software. uTest allow people with no prior software testing experience also.

Working with them will provide a dual advantage. Not only you will  get a hang of real time test cases, bug reporting, testing experience but also you would get paid for it — if you find a valid bug. What more do you want? It’s kind of a classroom where you are being paid to get trained.

Start out by filling this joining form. It’s a 5 step registration process where they ask you information ranging from personal data, your experience in testing using different platforms, experience in number of years etc. Once registered successfully, you will receive a uTest branded debit card through which you would be paid according to performance.

All the best!

More Reviews:

Post from: Learn QTP

For Beginners in Software Testing

Related posts:

  1. How to auto generate test data for software testing needs?

Post to Twitter Tweet This Post

Web Spider Creation with scRUBYt! – Part II

Continuing on from the previous post, Web Spidering and Data Extraction with scRUBYt!, this article will help you delve a little deeper with the scRUBYt! scraping framework both in terms of your understanding of how to use it… and actually delving deeper in your crawl to more pages.

A quick recap on the last web spider

So as far as we got last week was to go off to Google, put in a search for the word “ruby”, and then list the link text for each of the results. Here’s the code we ended up with to get that far:

@extractor = Skimr::Extractor.new(:agent => :standard) do
  fetch "http://www.google.com/ncr"
  fill_textfield "q", "ruby"
  submit
  page_title "//h3[@class='r']"
end

How to scrape deeper pages

But this is a fairly contrived example, and it’s not exactly going to save you a huge amount of time over a quick manual copy-and-paste job from the results page. But what if you didn’t want to just have a list of the links, you wanted some kind of summary or additional detail on each of the links? Lets actually go to each website, and see what kind of content they’ve got and grab something useful from it:

@extractor = Skimr::Extractor.new(:agent => :standard) do
  fetch "http://www.google.com/ncr"
  fill_textfield "q", "ruby"
  submit
  page_detail "//h3[@class='r']/a" do
    page_body "//body"
  end
end

If you offer up the XPath to a link element with a result name ending in _detail, and then pass in a block, scRUBYt! will follow the link before trying to process the block. That means we can use this technique for following each of the results Google gives us, and at each we return all of the text contain on the page between the <body> tags.

Now you could take the hash returned, and do some post processing on it to get something meaningful from the text extracted. But for the sake of example, I’ll make some big assumptions and assume that every page is going to have at least a <title> tag, and a <p> tag with more than just a few words in it.

@extractor = Skimr::Extractor.new(:agent => :standard) do
  fetch "http://www.google.com/ncr"
  fill_textfield "q", "ruby"
  submit
  page_detail "//h3[@class='r']/a" do
    title "//title"
    summary "//p", :script => Proc.new{|result| result if result.match(%r{(\w+\W+){25}})}
  end
end

As you may have noticed, you can pass a proc in as a parameter to your result definition. The output of the XPath match will be passed in to the proc, and the result ultimately returned as the final result for that definition? Make sense? If not, what I’ve done above is look for all <p> tags on the page and pass them in to my proc definition. The proc then runs a regexp against it to check that at least 25 words exist within the <p>, if there is then all the <p> content is returned otherwise nil is returned.

What if the results are paginated?

You could potentially create a highly recursive extractor to handle this, but it’s such a common case that we’ve included a method to do it for you:

@extractor = Skimr::Extractor.new(:agent => :standard) do
  fetch "http://www.google.com/ncr"
  fill_textfield "q", "ruby"
  submit
  page_detail "//h3[@class='r']/a" do
    title "//title"
    summary "//p", :script => Proc.new{|result| result if result.match(%r{(\w+\W+){25}})}
  end
  next_page "//a[text()*='Next']", :limit => 2
end

I’ve used the XPath text() function here to highlight its usefulness. I use it quite a lot as a shortcut to get things working and test, and it’s been a lifesaver in many scenarios where the markup is inconsistent or you want to keep the scraper definition generic. And thankfully, it works for this scenario. However, be wary of using it as is in production as it may have some unexpected side effects. If one of the results that came back had the word “Next” in the title, then scRUBYt! would diligently follow that link and you’d end up on the wrong page.

What’s next?

In the next installment I’ll briefly cover how to handle logging of the scrape to help you diagnose any problems, and how to handle more complex form completion.

Post to Twitter Tweet This Post

Web Spidering and Data Extraction with scRUBYt!

Some of you may be aware that I work on (time permitting) the scRUBYt! project with Peter Szinek. Hopefully some of you have actually found an excuse to use the tool, I know there are quite a few hundred other satisfied users out there. Well Peter has been furiously working away on polishing up the lastest release, we’ve also gone back and refactored a lot of the internals and improved the test coverage of library. Given the gnarly levels of recursion in it, at times it was proving difficult to add in the new features we wanted.

The skimr branch is our first attempt at refactoring, but to do it we’ve sacrificed quite a lot. A lot of functionality is currently missing, and the syntax has changed slightly. I wouldn’t yet consider this to be a release candidate, but it has been getting used successfully for a few months now in production so I think it’s worth a look.

Whats new?

Well apart from being a lot less code, it’s significantly faster and requires much less RAM on larger web scrapes. This is in part due to the fact that you can now stream your results out to a file, rather than trying to hold your entire dataset in memory before dumping them. If you don’t stream your results out to a file, the default is to return them as a Hash making it much easier to develop custom output handlers, or integrate the results into your existing ruby code.

Creating your own web crawler

To begin with, we will start with the tried and true google/ruby example that has served so well with previous scRUBYt! releases. So we start by defining a new Skimr extractor:

@extractor = Skimr::Extractor.new(:agent => :standard) do
end

You’ll notice here we pass in an agent type. It’s an optional parameter, and if you leave it out it will default to :standard which means a combination of mechanize/hpricot to parse your results. Others will become available in future releases to allow you to scrape AJAX heavy sites again. Next, to tell it what page we want to start at:

@extractor = Skimr::Extractor.new(:agent => :standard) do
  fetch "http://www.google.com/ncr"
end

Now we run over to Google (the ncr bit tells Google not to redirect me to a country specific site), because we’re about to start a search:

@extractor = Skimr::Extractor.new(:agent => :standard) do
  fetch "http://www.google.com/ncr"
  fill_textfield "q", "ruby"
  submit
end

Hopefully the above is fairly obvious, we’ve entered the term “ruby” into the field named “q”, and hit submit. Play along in your browser so you can see what we are playing with.

Extracting data from the website

Okay, so we’ve got the navigation part covered. Now we want to pull out a list of all the results, it’s quite simple:

@extractor = Skimr::Extractor.new(:agent => :standard) do
  fetch "http://www.google.com/ncr"
  fill_textfield "q", "ruby"
  submit
  page_title "//h3[@class='r']"
end

Just provide an XPath to the element on the page that you want, and scRUBYt! will extract all elements that fit that definition. As the results are now available as a Hash object we could simply do the following:

>> @extractor.results.first
=> {:page_title=>"Ruby Programming Language"}
>> @extractor.results.last
=> {:page_title=>"Welcome! [Ruby-Doc.org: Documenting the Ruby  Language]"}

I’ll follow this up in a couple of days with some examples of scraping deeper pages, merging multiple result sets, some of the new features we’ve included, and talk about some of the future enhancements that are coming soon.

Post to Twitter Tweet This Post

Custom Starting Templates for Rails Apps

Okay, so I’ve been a little slow on the uptake on this one. But for anybody else that missed it, you can now define your own standard setup for a rails app. (And kudos to Peter Szinek, who I work with on the leading ruby web spider/data scraping library, for the heads up on this last week)

Reducing the time taken to start coding

That’s essentially what this change does. Most of us probably have out preferred setup, especially if we’ve deployed a few sites. Typically I create the rails directory structure, then pull in HAML, rspec, rspec on rails, my form helper, restful auth, etc. It’s not terribly difficult, but it is laborious. Well someone else I once worked with, Jeremy McAnally (woo!, look at me name drop ;) , created a great little tool called rg which would allow you to define your own templates for when you create a new application. Now just like engines has been pulled into the latest edge core to give rails the same ability as merb-slices, so too has rg now been pulled in to match the functionality offered by creating your own custom merb-stack.

How to create a custom rails template

So if like me you have your usual grab bag you want to setup when you start a new app, you can define your own template.rb file like this:

run "rm public/index.html"
git :init

plugin "rspec", :git => "git://github.com/dchelimsky/rspec.git", :submodule => true
plugin "rspec-rails", :git => "git://github.com/dchelimsky/rspec-rails.git", :submodule => true
plugin "exception-notifier", :git => "git://github.com/rails/exception_notification.git", :submodule => true
plugin "restful-authentication", :git => "git://github.com/technoweenie/restful-authentication.git", :submodule => true
plugin "semantic-form-builder", :git => "git://github.com/rubypond/semantic_form_builder.git", :submodule => true
plugin "paperclipped", :git => "git://github.com/kbingman/paperclipped.git", :submodule => tru

gem "will-paginate", :git => "git://github.com/mislav/will_paginage.git"
gem "haml", :git => "git://github.com/nex3/haml.git"
rake "gems:install", :sudo => true
run "haml --rails ."

route "map.login '/login', :controller => 'sessions', :action => 'new'"

rakefile("cruise_controle.rake") do
  <<-TASK
    desc "Run all the tests, including API and acceptance tests"
    task :cruise do
      Rake::Task['db:migrate'].invoke
      Rake::Task['spec'].invoke
      Rake::Task['spec:stories'].invoke
      Rake::Task['metrics:all'].invoke
      Rake::Task['flogger:record'].invoke
    end
  TASK
end

initializer 'form_builder.rb', <<-CODE
  ActionView::Base.default_form_builder = SemanticFormBuilder
CODE

generate("authenticated", "user session")
generate("rspec")

rake("db:migrate")

git :add => "."
git :commit => "-a -m 'Initial commit'"

There is quite a lot going on there, I’ll quickly run through what I’ve done. Firstly, I’ve deleted index.html as I never use it. Next we initialise a local git repository and pull in all the plug-ins I want (as git submodules). Next we have a couple of gems I need, so we define them and install (using sudo) if they’re not already on the system. I setup a route to the login page, create a rake task to run cruise, an initializer to change the default form builder to be my own. And then finally I create the user/session models for restful-authentication, migrate the database, and commit all the changes.

Running your custom template

Now to create a new rails app using this template do the following:

rails my_new_app -m ~/template.rb

Or alternatively if you work across various machines you can post the template up to a server (git, your own box, etc) and specify a full HTTP to the remote file:

rails my_new_app -m http://gist.github.com/33443.txt

Post to Twitter Tweet This Post