Focusing a field of a client application

Asked by Pritam Biswas on 2020-04-07

Hi,

I've a client application called Oracle Capture, in that application there is a field called "Batch_Num". I want sikuli to populate the field with the value i'm passing as argument (I'm using Sikulix server here). But i'm unable to focus the client application window itself and click on it seems not working. Any idea where i'm messing it up?

WS- http://localhost:50010/scripts/CMD_Test/run?args=456

cmdPath = os.getenv("comspec")
title = "My Command Line"
cmd = 'start "%s" %s'%(title, cmdPath)
os.popen(cmd);
wait(3)
#paste("Name")
BatchNum=sys.argv[1]
print(BatchNum)
#rightClick(App.focusedWindow())
App.focus("Oracle Webcenter Enterprise Capture")
wait(3)

click(Region(38,928,772,37)) //This is the location of the field
type(BatchNum)

VErsion- 2.0.3
JDK- 1.8

Regards,
Cris

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2020-04-07
Last reply:
2020-04-08
RaiMan (raimund-hocke) said : #1

possible problems:

--- App.focus() does not work
Try another shorter (one word) window title text and check wether the app comes to front

--- click after focus too fast
add a wait(3) before the click (if it now works reduce the wait time accordingly)
check wether the write cursor in the field is activated and the field id focused

type also might need a short wait before (give the GUI time to react)

You should think of using click(image), which in the standard waits 3 secs for the image to come up, instead of using coordinates (which might vary, if the window is placed somewhere else).

Pritam Biswas (pritam-b) said : #2

Hi Raiman,

Tried with the approach you've suggested. Program is able to focus on the client application screen. Got another problem, when i'm running the WS through a browser, it's pulling the client application in front and typing the argument in the desired field.
but when i'm calling the same URL through a js keystroke of the client application it's able to focus the screen but not able to type the argument value in desired field.

cmdPath = os.getenv("comspec")
title = "My Command Line"
cmd = 'start "%s" %s'%(title, cmdPath)
os.popen(cmd);
wait(3)
#paste("Name")
BatchNum=sys.argv[1]
#type(BatchNum)
print(BatchNum)
#rightClick(App.focusedWindow())
App.focus("Oracle WebCenter")
wait(4)
click(Pattern("1586330376130.png").similar(0.70))
wait(3)
type(BatchNum)

RaiMan (raimund-hocke) said : #3

I am sorry, but your workflow is too specific that I can help you.

You have to try different approaches and always check, wether the focus has worked, before the type().

In the IDE you can run selected lines only, to do some testing (right click on the line number column).

Can you help with this problem?

Provide an answer of your own, or ask Pritam Biswas for more information if necessary.

To post a message you must log in.