Webrat verify content in iframe or frameset

I am using Cucumber + Webrat + Mechanize adapter and want to test contents of pages that are iframed or framed into the selected page.

In other words:

Scenario: View header on webpage
  Given I visit a page containing a frameset
  When there is a header frame
  Then I should see login details in frame header

The problem is of course the last step: I need to navigate to the frame header and investigate it's contents. I can verify the frame tag is here

response_body.should have_selector "frame[src][name=header]"

This leaves me with two questions:

  1. How to read the src attribute and navigate to that page
  2. How to navigate back to the original page

Answers


This would answer the first part of the question

Then /^I should see login details in frame header$/ do
  within 'frame[name=header]' do |frame|
    frame_src = frame.dom.attributes["src"].value
    visit frame_src
    response_body.should contain "Log in with digital certificate"
    response_body.should_not contain "Log out"
  end
end

you don't actually have to do it that way. Because your browser is already loading the frames automatically, you simply need to tell selenium(and thus webrat) which frame you want to look at.

When /^I select the "(.*)" frame$/ do |name|
  selenium.select_frame("name=#{name}")
end

try this in the step definition:

within_frame("headerid") do 
  assert page.has_content? "login details"
end

Need Your Help

Prevent application from closing

c# .net wpf multithreading

I created an empty project in Visual Studio and added the required assembly references, a class with a static Main function and a WPF Window.

ASP.NET MVC model defaults on post

asp.net-mvc

I have an ASP.NET MVC App, where I have interfaces for each viewmodel.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.