I want to move the file downloaded on first click to folder 1 and move the file downloaded on second click to folder 2 using java.

How it can be achieved using Java. Can somebody help me ?

enter image description here

for (WebElement element:list)
  String sourcePath = "C:\\Users\\sh370472\\Downloads";
  String destPath = "E:\\Query\\";
  String extension = ".csv";
     File[] files = moveFile.getTheFilesWithExtension(sourcePath, extension);
     for (File file : files)
    catch (IOException e) {

I want to check if it's a first or second download on the file(check image for ref). If it's a first click then the file should be moved first folder and If it's a second click then the file should be second folder


The answer might depend on whether you need to preserve the number from the last test run. If you don't you can just keep the static variable somewhere and increment it on each click.

If you do, you can go in two ways:

  1. check if the file has been downloaded already (if it exists in target folder). This approach will let you check if the file has been downloaded but it would not say how much times.

  2. Store the number in a file on your hard drive.

Anyway for going each of the ways you need to consider how you associate an entry in your web table with the file that is created on your hard drive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.