mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
reset history when resetting session
This commit is contained in:
parent
5eacd085da
commit
eaec9792b3
3 changed files with 15 additions and 0 deletions
|
@ -211,6 +211,11 @@ describe Capybara::Driver::Webkit do
|
||||||
subject.find("//*[contains(., 'hello')]").should be_empty
|
subject.find("//*[contains(., 'hello')]").should be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "has a location of 'about:blank' after reseting" do
|
||||||
|
subject.reset!
|
||||||
|
subject.current_url.should == "about:blank"
|
||||||
|
end
|
||||||
|
|
||||||
it "raises an error for an invalid xpath query" do
|
it "raises an error for an invalid xpath query" do
|
||||||
expect { subject.find("totally invalid salad") }.
|
expect { subject.find("totally invalid salad") }.
|
||||||
to raise_error(Capybara::Driver::Webkit::WebkitInvalidResponseError, /xpath/i)
|
to raise_error(Capybara::Driver::Webkit::WebkitInvalidResponseError, /xpath/i)
|
||||||
|
|
|
@ -16,6 +16,13 @@ void Reset::start(QStringList &arguments) {
|
||||||
page()->setUserAgent(NULL);
|
page()->setUserAgent(NULL);
|
||||||
page()->resetResponseHeaders();
|
page()->resetResponseHeaders();
|
||||||
page()->resetConsoleMessages();
|
page()->resetConsoleMessages();
|
||||||
|
resetHistory();
|
||||||
emit finished(new Response(true));
|
emit finished(new Response(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Reset::resetHistory() {
|
||||||
|
// Clearing the history preserves the current history item, so set it to blank first.
|
||||||
|
page()->currentFrame()->setUrl(QUrl("about:blank"));
|
||||||
|
page()->history()->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,5 +8,8 @@ class Reset : public Command {
|
||||||
public:
|
public:
|
||||||
Reset(WebPage *page, QObject *parent = 0);
|
Reset(WebPage *page, QObject *parent = 0);
|
||||||
virtual void start(QStringList &arguments);
|
virtual void start(QStringList &arguments);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void resetHistory();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue