Is it possible to upload a file from desktop to web using Selenide

0 votes
Is it possible to upload a file from desktop to web using Selenide?
Dec 16, 2020 in Java by NIKHIL
• 120 points
1,081 views

1 answer to this question.

0 votes

Hi, @Nikhil,

Yes it's possible to drop a file with Selenium via a script injection. The script needs to create an <input> web element to receive the file sent by SendKeys. Then simulate the dragenter, dragover and drop events on the targeted element with the file set in the dataTransfer object.

This example drops an image from the file system on a drop area:

ChromeDriver driver = new ChromeDriver();

driver.get("http://html5demos.com/file-api");

// locate the drop area
WebElement droparea = driver.findElement(By.cssSelector("#holder"));

// drop the file
DropFile(new File("C:\\Downloads\\image.png"), droparea, 0, 0);
answered Dec 16, 2020 by Gitika
• 65,770 points

Related Questions In Java

0 votes
1 answer

Is it possible to run a java program from command line on windows?How?

  Let's say your file is in C:\myprogram\ Run ...READ MORE

answered Apr 18, 2018 in Java by sophia
• 1,400 points
2,717 views
0 votes
3 answers

Is it possible to take char input from scanner?

// Use a BufferedReader to read characters ...READ MORE

answered Sep 7, 2018 in Java by Daisy
• 8,140 points
9,126 views
0 votes
1 answer

How to download and save a file from Internet using Java?

public void saveUrl(final String filename, final String ...READ MORE

answered May 25, 2018 in Java by Rishabh
• 3,620 points
924 views
0 votes
1 answer

Is it possible to create a memory leak with Java

Here's a good way to create a memory ...READ MORE

answered May 31, 2018 in Java by Parth
• 4,640 points
2,281 views
0 votes
2 answers

Why it is not possible to define a static method in a Java interface?

Interfaces are concerned with polymorphism which is ...READ MORE

answered Aug 27, 2019 in Java by Sirajul
• 59,230 points
2,091 views
0 votes
3 answers

Adding text to a file using Java

try { final Path ...READ MORE

answered Sep 6, 2018 in Java by Sushmita
• 6,920 points
1,436 views
0 votes
1 answer

What is the simplest way to read JSON from a URL in java

Read json from url use url.openStream() and read contents ...READ MORE

answered Jun 13, 2018 in Java by samarth295
• 2,220 points
5,197 views
+1 vote
2 answers

Is there a code to find 64-bit JVM or 32-bit JVM (from within a program)?

Do I need to understand the difference ...READ MORE

answered Jun 11, 2019 in Java by Jim
• 810 points
2,311 views
0 votes
1 answer

How do I save a String to a text file using Java?

If you're simply outputting text, rather than ...READ MORE

answered Dec 30, 2020 in Java by Gitika
• 65,770 points

edited Jul 6, 2023 by Khan Sarfaraz 2,104 views
+5 votes
11 answers

How to import a jar file in Eclipse?

Click on File > Import. The Import ...READ MORE

answered Aug 23, 2018 in Java by Daisy
• 8,140 points
360,201 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP