Search code examples
selenium-webdriverwebdriverselenide

Is there any way to handle security alert on chrome browser while uploading a file.?


I am automating test cases in which I have to upload a folder on Google drive. I am able to successfully click and upload folder by path but immediately when I click on upload button of browse windows the alert appears on top middle of the screen saying 'This will upload all files from "folderName". Only do this if you trust this site." (see attached image) There are two buttons 'Upload' and Cancel but there is no way I can identify those element. I tried all possible approaches.

Is there any other way to handle that security alert. I found following info about the alert.

How to remove warning message in Chrome when uploading a directory

  1. Disable alert in chrome web driver configuration
  2. Auto accept alert.
  3. AutoIT ( can not identify button )
  4. Robot Keys (works) but not stable. fails the test if you will execute two test in parallel.
    uploadFolder(folderToUpload, 5000);
    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_LEFT);
    robot.keyPress(KeyEvent.VK_ENTER);

Solution

  • I faced the same problem and to solve this I have used Sikuli. Sikuli will identify the pop-up as per the image. (you need to capture the screenshot of that pop-up).

    Try searching for Sikuli on google and you can find lot of stuff about implementation and all. Hope this will help.