From 66a6145ee9c99d9f1a8a69878beeaab74d39d91d Mon Sep 17 00:00:00 2001 From: Chad Pytel Date: Thu, 2 Jun 2011 15:45:28 -0400 Subject: [PATCH] fix for https://github.com/thoughtbot/capybara-webkit/issues/52 --- spec/driver_spec.rb | 5 +++++ src/Visit.cpp | 8 ++++++-- src/Visit.h | 1 - 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/spec/driver_spec.rb b/spec/driver_spec.rb index de7b077..abf7384 100644 --- a/spec/driver_spec.rb +++ b/spec/driver_spec.rb @@ -167,6 +167,11 @@ describe Capybara::Driver::Webkit do subject.current_url.should =~ /hello%20there/ end + it "visits a page with an anchor" do + subject.visit("/hello#display_none") + subject.current_url.should =~ /hello#display_none/ + end + it "returns the source code for the page" do subject.source.should =~ %r{.*greeting.*}m end diff --git a/src/Visit.cpp b/src/Visit.cpp index e592e9e..7592a84 100644 --- a/src/Visit.cpp +++ b/src/Visit.cpp @@ -7,7 +7,12 @@ Visit::Visit(WebPage *page, QObject *parent) : Command(page, parent) { } void Visit::start(QStringList &arguments) { - page()->currentFrame()->setUrl(QUrl(arguments[0])); + QUrl requestedUrl = QUrl(arguments[0]); + page()->currentFrame()->setUrl(QUrl(requestedUrl)); + if(requestedUrl.hasFragment()) { + // workaround for https://bugs.webkit.org/show_bug.cgi?id=32723 + page()->currentFrame()->setUrl(QUrl(requestedUrl)); + } } void Visit::loadFinished(bool success) { @@ -17,4 +22,3 @@ void Visit::loadFinished(bool success) { emit finished(new Response(success, message)); } - diff --git a/src/Visit.h b/src/Visit.h index a4beb6a..5e6d148 100644 --- a/src/Visit.h +++ b/src/Visit.h @@ -13,4 +13,3 @@ class Visit : public Command { void loadFinished(bool success); }; -