Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Webdriver - PhantomJS hangs upon send_keys() to file input element

I am performing some file uploading tests. I found that my test code hangs at element.send_keys(file) if I am using PhantomJS, however the same code does not hang if I am using Firefox.

element = self.browser.find_element_by_xpath("//input[@type='file']")
element.send_keys(file)

Is there any workarounds to make PhantomJS upload files properly? Currently I am using Windows 7, Python 3.4.1, selenium 2.42.1, PhantomJS 1.9.7.

like image 392
Saren Arterius Avatar asked Jul 12 '14 12:07

Saren Arterius


1 Answers

browser = webdriver.PhantomJS()
browser.set_window_size(1200,800)

Without setting the window size, the browser remains in mobile size causing errors. Try a implicit wait too.

like image 104
M.A.K. Simanto Avatar answered Sep 17 '22 17:09

M.A.K. Simanto