lundi 12 septembre 2016

Unrecognized file type in selenium python

So I am testing a web client which communicates with an engine that does something to a text file that I upload. So basically, I choose a file to upload, once this file is uploaded i can press start and the engine does its thing and returns a result. I am trying to test the front end using selenium in python. This web client accepts zip or txt files. The developer of this web client made it such that when a file type other than a zip or text is uploaded it will give an error like so

File type "audio/wav" is not supported: Must be one of "text/plain", "application/zip", "application/zip-compressed", "application/x-zip-compressed".  

In this case, I tried to upload a wav audio file. When I try to manually upload a zip file, it works as expected. However, when I try this same process using the same file in selenium, it no longer recognize the file type and gives me this error

File type "" is not supported: Must be one of "text/plain", "application/zip", "application/zip-compressed", "application/x-zip-compressed". 

So the file type is unrecognized. Here is what I am using to upload the file:

choose = self.driver.find_element_by_id("chooseButton")
time.sleep(1)
#clicks to open upload window
choose.click()
time.sleep(1)
#ZIp file with other zips
pyautogui.typewrite("C:\\Transcriber\\Framework\\test\\audio\\Nested.zip")
time.sleep(1)
pyautogui.press('enter')

I am using pyautogui to manipulate the upload window that pops up when I click the upload button, so it's as though I am automating my keyboard. The time.sleep is just to ensure that enough time is provided between actions such that an action ends before the next one starts.

My zip is just an ordinary zip file. When I run it in selenium it gave me the above error. Does anyone know what the problem could be? Is this a python issue? Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire