1

Using LeanFT's Java SDK, is it possible to perform click operation on "Save" button from Chrome's "Save As" dialog?

Adelin
  • 7,809
  • 5
  • 37
  • 65

2 Answers2

1

Have you tried to use the Object Identification Tool to identify the Save button?

In any case, I understand you are now working with Web technology, then you click on a Save button, which then prompts you to save the file in a location.

You have two options:

  1. Set Chrome to no longer ask where to save files;

  2. Describe the Save button that you want to Click using the STD technology.

Example of such description:

Desktop.describe(Window.class, new WindowDescription.Builder()
        .ownedWindow(false)
        .childWindow(false)
        .windowClassRegExp("Chrome_WidgetWin_1")
        .windowTitleRegExp(" Google Chrome").build())
    .describe(Dialog.class, new DialogDescription.Builder()
        .ownedWindow(true)
        .childWindow(false)
        .text("Save As")
        .nativeClass("#32770").build())
    .describe(Button.class, new ButtonDescription.Builder()
        .text("&Save")
        .nativeClass("Button").build());

Then you can call the .click method on this object (or cancel, or so on).

Adelin
  • 7,809
  • 5
  • 37
  • 65
-1
String home = System.getenv("USERPROFILE") + "\\Downloads\\";
String fileName = "xxxxxxxxx.xls";
File file = new File(home + fileName);
if (file.exists()) {
   file.delete();
   System.out.println("Deleted existing CurrentSortRules.xls file if it is already present");
    }
    Window popup = Desktop.describe(Window.class, new WindowDescription.Builder().ownedWindow(false).childWindow(false)
                                .windowClassRegExp("Chrome_WidgetWin_1").windowTitleRegExp(" Google Chrome").build())
                .describe(Dialog.class, new DialogDescription.Builder().ownedWindow(true).childWindow(false)
                        .text("Save As").nativeClass("#32770").build());