Insert javascript in the IE-URL (non-QUERTY-Layout)

Asked by Thorsten

Hi there,

first: Sikuli is great! Thank you for support and developement!

My problem:
I am testing web sites with a lot of fields and need some shortcuts for navigating. I don't want to take a Screenshot of every field. To make things easier I wanted to use JavaScript to navigating to certain fields. So I tried this script:

keyDown(Key.CTRL)
type("l")
keyUp(Key.CTRL)
type('javascript:alert($("#someid").focus());')

This leads to an exception because of the colon in my non-QUERTY-Keyboard-Layout. So I used the workaround with "paste":
paste('javascript:alert($("#someid").focus());')

This would work if the Internet Explorer would not cut of the part "javascript:" when pasting in the URL :( the result of pasting this line is only "alert($("#someid").focus());".

If there was a Key.POS1 this would work:
keyDown(Key.CTRL)
type("l")
keyUp(Key.CTRL)
paste(':')
paste('alert("123")')
keyDown(Key.CTRL)
type(Key.POS1)
keyUp(Key.CTRL)
type('javascript')

Unfortunatly there is no Key.POS1 and I can not "type" a colon.

Any suggestions?

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
Thorsten (thorsten-m) said :
#1

I found a workaround myself:

def ie_execJS_URL(js):
# js = "alert($('#somefield').focus());"
    keyDown(Key.CTRL)
    type("l")
    keyUp(Key.CTRL)
    wait(0.2)
    paste(':')
    paste(js)
    for x in js:
        type(Key.LEFT)
    type(Key.LEFT)
    type('javascript')
    type(Key.ENTER)
    wait(0.2)
    type(Key.ESC)

It's a bit slow and sloppy but works...

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

I guess what you are looking for is Key.HOME

What about tabbing through the fields?

Revision history for this message
Thorsten (thorsten-m) said :
#3

Thanks RaiMan, that solved my question.

Revision history for this message
Thorsten (thorsten-m) said :
#4

Tabbing would be an option. But I don't want to change my test cases every time the tab order changes in the application. The tab order will change quite often.