Ask a Question

how to import image from system on my application

meghaphophalia
Occasional Contributor

how to import image from system on my application

On my application I want to upload image so for that what steps and code should I add . How to automate this steps.Please refer image.

How to define path in code to upload that image.

Writing code in java script and application is in delphi language.4.png

3 REPLIES 3
npaisley
Staff

Hey @meghaphophalia!

 

We have a built in method called 'OpenFile' you can use on objects to upload files, like the Open File dialog in windows. 

 

Below are 2 documents that cover working with Open and Save file dialogs and the OpenFile method itself that you can use to accomplish what you are looking for.

 

Working With Open File and Save File Dialogs;

https://support.smartbear.com/testcomplete/docs/app-objects/specific-tasks/openfile-savefile-dialogs...

 

OpenFile Method;

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/window-and-process/op...


Regards,
Nick

Solutions Engineer @ SmartBear
meghaphophalia
Occasional Contributor

I user this code-

After clicking on open button in application -

 

Aliases.FR4.FormImageMgr.SpeedButton1.Click() --Click on ... as shown in above attached picture 
let openWindow = process.Window('#32770','Open')
openWindow.OpenFile(Project.Path+"...\\Test_Data\\product.jpg")

 

but it throws error for Process keyword .Can you lemme what to configure about process .

 

meghaphophalia_0-1652421835455.png

 

npaisley
Staff

Hi @meghaphophalia!

 

Looks like how you are instantiating your openWindow variable is incorrect. 

 

What we need to do is create a variable that contains just the 'Sys.Process' for your application, then we run the OpenFile method on your object in the variable. 

 

Here is the example from the above documentation you can use to build this out.

function WorkWithFiles()
{
  var notepad = Sys.Process("notepad");
  var wndNotepad = notepad.Window("Notepad");
  
  // Open a file in Notepad
  wndNotepad.MainMenu.Click("File|Open...");
  notepad.Window("#32770", "Open").OpenFile("C:\\MyFile.txt");

  // Save the file to the desktop
  var strDesktop = WshShell.SpecialFolders.Item("Desktop");
  wndNotepad.MainMenu.Click("File|Save as...");
  notepad.Window("#32770", "Save As").SaveFile(strDesktop + "\\MyFile.txt");
}

Regards,
Nick

Solutions Engineer @ SmartBear
cancel
Showing results for 
Search instead for 
Did you mean: