у phantomjs
похоже есть свой _uploadFile
https://github.com/a...bpage.cpp#L1367
void WebPage::_uploadFile(const QString& selector, const QStringList& fileNames)
{
QWebElement el = m_currentFrame->findFirstElement(selector);
if (el.isNull()) {
return;
}
// Filter out "fileNames" that don't actually exist
m_customWebPage->m_uploadFiles.clear();
for (int i = 0, ilen = fileNames.length(); i < ilen; ++i) {
if (QFile::exists(fileNames[i])) {
m_customWebPage->m_uploadFiles.append(fileNames[i]);
}
}
el.evaluateJavaScript(JS_ELEMENT_CLICK);
}
у меня c phantomjs версия 2.1.1, windows64 сработало
https://seleniumhq.g...tePhantomJS.htm
String testFileName = "test.txt";
String testFilePath = new File(testFileName).getAbsolutePath();
driver.get("http://siptv.eu/converter/");
element = driver.findElement(
By.cssSelector("div#container form#file_form input#file"));
assertThat(element, notNullValue());
((PhantomJSDriver) driver).executePhantomJS(String.format(
"var page = this; page.uploadFile('input[id=file]', '%s' );",
testFilePath.replaceAll("\\\\", "/")));
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
assertThat(element.getAttribute("value"), containsString(testFileName));
нажимать на submit не пробовал.