Skip to content

Instantly share code, notes, and snippets.

@jarib
Created April 19, 2011 18:19
Show Gist options
  • Select an option

  • Save jarib/929131 to your computer and use it in GitHub Desktop.

Select an option

Save jarib/929131 to your computer and use it in GitHub Desktop.
require 'celerity'
path = File.expand_path "test.html"
File.open(path, "w") { |file| file << DATA.read }
wc = ::HtmlUnit::WebClient.new(::HtmlUnit::BrowserVersion::FIREFOX_3)
front_page = wc.getPage("file://#{path}")
button = front_page.getElementById("loginButton")
new_page = button.click
puts("***************************************************************")
puts("Browser 1 Text")
puts(front_page.getDocumentElement.asText)
puts("***************************************************************")
puts("***************************************************************")
puts("Browser 2 Text")
puts(new_page.getDocumentElement.asText)
puts("***************************************************************")
__END__
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>CelerityTestFoo</title>
</head>
<body>
<h1>CelerityTestFoo</h1>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : '219977654685618',
status : true, // check login status
cookie : false, // enable cookies to allow the server to access thesession
xfbml : true // parse XFBML
});
function loginToFacebook()
{
FB.login(handleLoginResponse,{perms:'publish_stream,manage_pages,offline_access'});
}
function handleLoginResponse(response)
{
}
</script>
<script src="http://connect.facebook.net/en_US/all.js#appId=219977654685618&amp;xfbml=1"></script>
<button id="loginButton" onClick="loginToFacebook()">Login</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment