mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
support attaching file to HTML5 input with multiple attribute
This commit is contained in:
parent
a4490083b6
commit
0c8e347b61
2 changed files with 15 additions and 2 deletions
|
@ -137,7 +137,18 @@ QString WebPage::chooseFile(QWebFrame *parentFrame, const QString &suggestedFile
|
||||||
Q_UNUSED(parentFrame);
|
Q_UNUSED(parentFrame);
|
||||||
Q_UNUSED(suggestedFile);
|
Q_UNUSED(suggestedFile);
|
||||||
|
|
||||||
QString javascript = QString("Capybara.lastAttachedFile");
|
return getLastAttachedFileName();
|
||||||
return currentFrame()->evaluateJavaScript(javascript).toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WebPage::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) {
|
||||||
|
if (extension == ChooseMultipleFilesExtension) {
|
||||||
|
QStringList names = QStringList() << getLastAttachedFileName();
|
||||||
|
static_cast<ChooseMultipleFilesExtensionReturn*>(output)->fileNames = names;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WebPage::getLastAttachedFileName() {
|
||||||
|
return currentFrame()->evaluateJavaScript(QString("Capybara.lastAttachedFile")).toString();
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ class WebPage : public QWebPage {
|
||||||
QString userAgentForUrl(const QUrl &url ) const;
|
QString userAgentForUrl(const QUrl &url ) const;
|
||||||
void setUserAgent(QString userAgent);
|
void setUserAgent(QString userAgent);
|
||||||
bool render(const QString &fileName);
|
bool render(const QString &fileName);
|
||||||
|
virtual bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool shouldInterruptJavaScript();
|
bool shouldInterruptJavaScript();
|
||||||
|
@ -31,5 +32,6 @@ class WebPage : public QWebPage {
|
||||||
QString m_capybaraJavascript;
|
QString m_capybaraJavascript;
|
||||||
QString m_userAgent;
|
QString m_userAgent;
|
||||||
bool m_loading;
|
bool m_loading;
|
||||||
|
QString getLastAttachedFileName();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue