From 6e5d7939877041cd54b28def70322fd9c8e62899 Mon Sep 17 00:00:00 2001 From: Joe Ferris Date: Fri, 26 Jun 2015 12:01:26 -0400 Subject: [PATCH] Remove auto-screenshot behavior We can't distinguish between ClickFailed errors which will be retried, and those which have actually failed for good. This means we end up writing hundreds of screenshot files during a failure, and we sometimes write several screenshot files even when the click ends up working. This isn't feasible to work around in a driver, so this commit removes the behavior from capybara-webkit. Something like this may make more sense in Capybara proper. Resolves #626. --- spec/integration/session_spec.rb | 4 ---- src/JavascriptInvocation.cpp | 11 ----------- src/JavascriptInvocation.h | 1 - src/capybara.js | 1 - 4 files changed, 17 deletions(-) diff --git a/spec/integration/session_spec.rb b/spec/integration/session_spec.rb index 106edfeb..050ee201 100644 --- a/spec/integration/session_spec.rb +++ b/spec/integration/session_spec.rb @@ -419,10 +419,6 @@ module TestSessions subject.find(:css, '#one').click }.to raise_error(Capybara::Webkit::ClickFailed) { |exception| exception.message.should =~ %r{Failed.*\[@id='one'\].*overlapping.*\[@id='two'\].*at position} - screenshot_pattern = %r{A screenshot of the page at the time of the failure has been written to (.*)} - exception.message.should =~ screenshot_pattern - file = exception.message.match(screenshot_pattern)[1] - File.exist?(file).should be_true } end diff --git a/src/JavascriptInvocation.cpp b/src/JavascriptInvocation.cpp index bd340782..8fb66f0f 100644 --- a/src/JavascriptInvocation.cpp +++ b/src/JavascriptInvocation.cpp @@ -135,14 +135,3 @@ void JavascriptInvocation::keypress(QChar key) { event = QKeyEvent(QKeyEvent::KeyRelease, keyCode, Qt::NoModifier, key); QApplication::sendEvent(m_page, &event); } - -const QString JavascriptInvocation::render(void) { - QString pathTemplate = - QDir::temp().absoluteFilePath("./click_failed_XXXXXX.png"); - QTemporaryFile file(pathTemplate); - file.open(); - file.setAutoRemove(false); - QString path = file.fileName(); - m_page->render(path, QSize(1024, 768)); - return path; -} diff --git a/src/JavascriptInvocation.h b/src/JavascriptInvocation.h index 4d18a666..da118c09 100644 --- a/src/JavascriptInvocation.h +++ b/src/JavascriptInvocation.h @@ -26,7 +26,6 @@ class JavascriptInvocation : public QObject { Q_INVOKABLE QVariantMap clickPosition(QWebElement element, int left, int top, int width, int height); Q_INVOKABLE void hover(int absoluteX, int absoluteY); Q_INVOKABLE void keypress(QChar); - Q_INVOKABLE const QString render(void); QVariant getError(); void setError(QVariant error); InvocationResult invoke(QWebFrame *); diff --git a/src/capybara.js b/src/capybara.js index ac2f8f9f..59470d9f 100644 --- a/src/capybara.js +++ b/src/capybara.js @@ -421,7 +421,6 @@ Capybara.ClickFailed = function(expectedPath, actualPath, position) { this.message += ' at position ' + position["absoluteX"] + ', ' + position["absoluteY"]; else this.message += ' at unknown position'; - this.message += "; \nA screenshot of the page at the time of the failure has been written to " + CapybaraInvocation.render(); }; Capybara.ClickFailed.prototype = new Error(); Capybara.ClickFailed.prototype.constructor = Capybara.ClickFailed;