Chrome update disabled the file upload feature? {"code":-32000,"message":"Not allowed"}

selenium-ide
file-upload

#1

This is since the Chrome 72.0.3626.81 update. It seems to me all web automation tools are affected. When I search for the error, I find similar error reports in the Selenium IDE ticket system, the Katalon forum and the iMacros forum :roll_eyes:

type on id=imagepp with value c:\testdata\passport1.png Failed:

{"code":-32000,"message":"Not allowed"}

Macro stops at file selection window on chrome(windows 7)
Uploading photos from Google Drive
File uploads with variable filename from csv
#2

Update May 11, 2019: Native file upload continues to be disabled in Chrome V74 ("-32000" error message). To upload files please use the XClick solution described here: :arrow_down:

Yeah, we see the same issue since a few days. Now Chrome is at 72.0.3626.96 and the problem is still there. Normally Kantu (just like all other tools you mentioned) would use Chrome’s debugging API to perform file uploads. But since the latest Chrome updates Kantu stops at the “Kantu… is debugging this browser” message.

cdbaby

But the solution is easy: Until the Chrome team allows automated file uploads again via its extension API you can use xtype to automate file uploads:

  • click| id=imageFile (open upload file picker)
  • xtype | f:\\testcases\\data\\up1.png
  • xtype | ${KEY_ENTER}

The xtype solution has the great advantage that it works for file uploads in Firefox, too :smiley:

Screencast of the file upload in action:

Demo macro for Chrome:

 {
  "Name": "1upload",
  "CreationDate": "2019-5-2",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://cgi-lib.berkeley.edu/ex/fup.html",
      "Value": ""
    },
    {
      "Command": "XClick",
      "Target": "name=upfile",
      "Value": ""
    },
    {
      "Command": "XType",
      "Target": "C:\\1tmp\\1test.txt",
      "Value": ""
    },
    {
      "Command": "XType",
      "Target": "${KEY_ENTER}",
      "Value": ""
    },
    {
      "Command": "clickAndWait",
      "Target": "xpath=/html/body/form/input[3]",
      "Value": ""
    }
  ]
}

:fire::fox_face: Test macro for Firefox

Here, XType | ${KEY_ENTER} does not work (we are not sure yet why). But the workaround is easy: You can replace the ENTER keystroke with an XClick on the “Open” button using desktop automation and XDesktopAutomation | true before the XClick command. The XClick image used is:

1test_dpi_96

{
  "Name": "1upload-firefox",
  "CreationDate": "2019-5-2",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://cgi-lib.berkeley.edu/ex/fup.html",
      "Value": ""
    },
    {
      "Command": "XClick",
      "Target": "name=upfile",
      "Value": ""
    },
    {
      "Command": "XType",
      "Target": "C:\\1tmp\\1test.txt",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "XType // ${KEY_ENTER}",
      "Value": ""
    },
    {
      "Command": "XDesktopAutomation",
      "Target": "true",
      "Value": ""
    },
    {
      "Command": "XClick",
      "Target": "1test_dpi_96.png@0.6",
      "Value": ""
    },
    {
      "Command": "clickAndWait",
      "Target": "xpath=/html/body/form/input[3]",
      "Value": ""
    }
  ]
}

Is firefox file upload through file input is not avaialble yet?
"kantu browser automation" is debugging this browser
#3

does this xtype solution work on mac as well? (Since there is no field for typing the location of the file really)


#4

@ronny911 - good point, on Mac the macro needs to be slightly modified:

Instead of sending the file path with XType , we need to select the file from the dialog. For this we can use the new desktop automation feature of Kantu. We switch the Kantu eyes to desktop mode with XDesktopAutomation | true and then use either XClick | image of file name or (recommended) XClick |ocr=file name. This does a text search for the file name on the screen, finds it and then clicks it.

The remaining part of the macro is the same. We use XType to send ENTER, and all is done.

I tested that this works and made a short screencast:


#5

Hi

For which version of Kantu and Firefox does it work? Because of version Kantu 4.0.1 and Firefix 66.0 follow code doesn’t upload files:

{
      "Command": "XType",
      "Target": "${KEY_ENTER}",
      "Value": ""
    }
```:fearful:

#6

hi, i have same problem with upload function… how long it take to fix this? xtype is not solution for me because it just limited for 25 command, meanwhile i have problem to upgrade this. And then sometimes this command in example :

{
“Command”: “click”,
“Target”: “id=imageFile”,
“Value”: “”
},

does’nt show openfile dialog box, so cant use xtype for give the name of file or enter. and it starting failure chain while macro running

please fix this upload function like before without xtype.


#7

Hi Team,

1st point:
as the 1st screenshot shows, i followed the code above, while still got the error,
it just stops after showing the openfile dialog box.
while the .png file with correct directory is there(as the 2nd screenshot shows).

2nd point:
while what i input in the code is “f:\testcases\data\up1.png”, the error log prompt as “f: estcases\data\up1.png”
apparently the “\t” is omitted, any insights on this issue?

Environment:
Windows 7 64 bit;
Chrome:
Version 73.0.3683.86 (Official Build) (64-bit);
Kantu Browser Automation Extension: 4.1.6

also, the XModules, i’d installed as the screenshot shows with the latest version.
can any one tell me what’s wrong here? Thanks!

file


#8

This is a bug in Chrome, not Kantu. The Chrome team told us this will be fixed with V74 in a few weeks.


#9

This a bug in Kantu. It thinks \t is an escape sequence. This will be fixed soon. The current workaround is to avoid path names that start with “t”.


#10

how about my 1st point?

thanks for your specific reply.


#11

For the first point, I think it is related to the “\t” issue. => If you use a path without"…\t…" in it, does it work then?


#12

hi, it works after the “\t” omitted, while there’s a new question here in this scenario:

(btw, i’ve updated into the latest version of Kantu: 4.1.12, others:
Environment:
Windows 7 64 bit;
Chrome:
Version 73.0.3683.103 (Official Build) (64-bit) (updated);

as attached, for testing purpose, the file is not existed in the hard drive, while is in the macro code, so the question is: how to ignore the “local File not found(via address link)” error message, basically simulating: click the “OK” button-> “Cancel” button as in the attached screenshot, then move on to the next steps?

thanks.


#13

Chrome 74 is out, unfortunately i’m not seeing the old method of file uploading without XType working. Can anyone else confirm what i’m seeing as well?


#14

Yes. The regular type | name=upfile | C:\\fakepath\\test.txt upload method is still not working. It is the same issue with the classic Selenium IDE and any other tool i tested. But the related Chromium ticket is closed: https://bugs.chromium.org/p/chromium/issues/detail?id=928255

So I am not sure what this means?


#15

You can simulate a click on the “Cancel” button in three different ways:

(1) In Chrome

  • Use XType | ${KEY_TABS} to move the selection to from “OK” to “Cancel”, then simulate Enter.

(2) In Chrome and Firefox

Use desktop automation and then find and click the “Cancel” button

  • XDesktopAutomation | true
  • XClick | (image of cancel button)

(3) In Chrome and Firefox

Use desktop automation and plus screen scraping (OCR). Then no input image is needed.

  • XDesktopAutomation | true
  • XClick | ocr=Cancel

And if you need to make decisions inside your macro, then use one of the flow control commands.