A
A
Andrew2017-09-26 17:55:40
Python
Andrew, 2017-09-26 17:55:40

How to send upload file in phantomjs python?

There is a piece of code that works fine in Chrome.

path2file = r'D:\test\file.apk'
files = browser.find_element_by_name('files') 
files.send_keys(path2file)

But doesn't work in phantomjs.
All other, not file, input are filled and send_keys leaves with a bang (in a phantom). But here the file does not want.
html code - Hangs on send_keys. Set time.sleep(5) - does not help. Changed files.send_keys(path2file) to files.send_keys("D:\test\file.apk") (or D:/test/file.apk, or D:\\test\\file.apk, or r"D :\test\file.apk") - the script works, but does not insert into the input (but does not freeze, but goes on) ... I found the code on the net, but how to adapt it?<input type="file" name="files" multiple="">
var webPage = require('webpage');
var page = webPage.create();

page.uploadFile('input[name=image]', '/path/to/some/photo.jpg');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2017-09-26
@sanya84

Brython

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question