Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97826

No errors in uploading images with selenium java but does not execute

$
0
0

Highlighted area is the Element target

I have tried the following:

    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    StringSelection str = new StringSelection(System.getProperty("usr.dir") + "\\src\\main\\resources\\assets\\images\\[image]");
    clipboard.setContents(str, null);

    WebElement element = webDriver.findElement(By.id("coral-id-4"));
    element.click();

    Robot robot = new Robot();
    robot.keyPress(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_V);
    webDriver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    robot.keyRelease(KeyEvent.VK_CONTROL);
    robot.keyRelease(KeyEvent.VK_V);
    webDriver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    robot.keyPress(KeyEvent.VK_ENTER);
    robot.keyRelease(KeyEvent.VK_ENTER);

As well as:

    String filePath = System.getProperty("usr.dir") + "\\src\\main\\resources\\assets\\images\\[image]";
    JavascriptExecutor jsx = (JavascriptExecutor) webDriver;
    jsx.executeScript("document.getElementById('coral-id-4').value='" + filePath + "';");

And:

    String fileName = System.getProperty("usr.dir") + "\\src\\main\\resources\\assets\\images\\[image]";
    File file = new File(fileName);
    String path = file.getAbsolutePath();
    webDriver.findElement(By.id("#coral-id-4")).sendKeys(path);

The location of my image is either the one above or "I:[folder]\Pictures[picture]", I don't get any errors, but my picture doesn't upload.

The element in which I am sendkeys to is from a drop down button 'Create' as you can see from the image.

I appreciate any help.


Viewing all articles
Browse latest Browse all 97826

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>