0

I'm currently writing a test script for our web application that tests uploading a profile picture image using Microsoft Edge and EdgeDriver. When I initialize the click operation for the add photo button the script stops executing altogether. I think it's a parent/child window or javascript issue but have been stumped on this issue for some time now. I have it working in Chrome/Firefox/IE11. The code below should click the button to pop up the modal window, copy the path to the desired image, and then paste the path in the dialog box.

Here is the code snippet relevant to the issue:

    driverElement = driver.findElement(By.xpath("//span[text()='Add Photo']")); 
    actions.moveToElement(driverElement).click().build().perform(); //click button for modal window

    //find the image and upload it
    pathToImage = new StringSelection("C:\\path\\to\\image");
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(pathToImage, null);
    bot = new Robot();

    Thread.sleep(500);
    bot.keyPress(KeyEvent.VK_CONTROL);
    bot.keyPress(KeyEvent.VK_V);

    bot.keyRelease(KeyEvent.VK_CONTROL);
    bot.keyRelease(KeyEvent.VK_V);
    Thread.sleep(500);

    bot.keyPress(KeyEvent.VK_ENTER);
    bot.keyRelease(KeyEvent.VK_ENTER); 

After the click operation all execution stops, even in debug mode when I try to step over manually to the next line of execution.

Any help would be greatly appreciated.

potatocode
  • 13
  • 1
  • 6
  • This may work if you type path to image character one by one. We had same scenario to upload image and used robot class and typed individual character one by one and it worked. – Murthi Jun 02 '17 at 22:45

1 Answers1

0

After some extensive investigation and a ton of trying workarounds it appears that this is a plain showstopper. Microsoft has not developed the WebDriver enough to differentiate the root file explorer and the web file explorer. More details can be found here: Edge Upload File control using Selenium

potatocode
  • 13
  • 1
  • 6