Unable to perform a delete key function for a file rename

Asked by Mel Adajar

My mouse actions on a firefox browser is as follows. File -> Save As

The window for "Save As" box opens. I did a click(img) where image is the "File name:" box.
What I want to do next as the filename is already highlighted is to simply delete the file name and rename it to something else.

I am stuck at this part. Message is saying "type(Key.DELETE, KEY_DELETE + "MyNewFileName)" is not defined. I went through the docs
and I thought my syntax is correct, but apparently is not.

Here is my script thus far as it gets to the DELETE key part:
click (imgofSavePageAs)
wait (5.0)
type (Key.DELETE, KEY_DELETE + "MyNewFileName")

What is the best way to do this? Thanks for your help.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Landy (landy-zhu) said :
#1

What's the definition of "KEY_DELETE"?

type (Key.DELETE, KEY_DELETE + "MyNewFileName") // what actual action do you want to do by this line?

Thanks.

Revision history for this message
Best RaiMan (raimund-hocke) said :
#2

generally: if something is highlighted in an input field, you just start typing, and the highlighted text is overwritten.

so in your case you simply do this:

click (imgofSavePageAs)
wait (5.0) # 0.5 seconds should be sufficient
paste("MyNewFileName") #use paste instead of type for text
type(Key.ENTER)

BTW:
type (Key.DELETE, KEY_DELETE + "MyNewFileName")

is not correct:
- a KEY_DELETE is not defined
- the second parameter of type only accepts the modifier keys like KEY_CTRL ...

it should read:
type (Key.DELETE)
type ("MyNewFileName")

but I recommend th above mentioned solution

Revision history for this message
Mel Adajar (melsterdba) said :
#3

Thank you guys. Yes, the paste is a much better solution instead of trying to delete the highlighted file name.

Revision history for this message
Mel Adajar (melsterdba) said :
#4

Thanks RaiMan, that solved my question.