Open browser, type the url/IP address and hit enter

Asked by networkdownloader

Hi All,
          I am new to programming and I love the concept behind Sikuli. This concept makes programming simple even for non-programmers. I hate to ask people randomly without searching the web for content. Pardon me if I missed a link or typing some keywords incorrectly.

My task is to automate linksys router upgrades.

The basic task of launching chrome and typing the url and hitting enter fails.

This is the code that I am using:

switchApp("Desktop")
openApp("C:\Users\lightspeed\AppData\Local\Google\Chrome\Application\chrome.exe")
find("1343856403600.png") #This is the snapshot of the browser address bar in chrome including the home button
type(192.168.1.X)
type("Key.ENTER")

All I see is chrome gets launched but nothing is happening. Am I missing something, please let me know

Thank you
ND

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
Best RaiMan (raimund-hocke) said :
#1

Since you say it is running somehow, i guess there are some typos, when putting code here:

--- the backslashes must either be doubled or you use a raw string r"C:\...."

# switchApp("Desktop") # delete - not needed
openApp(r"C:\Users\lightspeed\AppData\Local\Google\Chrome\Application\chrome.exe")
click("1343856403600.png") # you must click to give focus to the entry field
type("192.168.1.X") # apo's missing
type("Key.ENTER")

An alternative that gives the Chrome window some time to get ready:
openApp(r"C:\Users\lightspeed\AppData\Local\Google\Chrome\Application\chrome.exe")
wait("1343856403600.png", 5) # waits max 5 seconds
type(getLastMatch(), "192.168.1.X") # first clicks on what was just found and then types
type("Key.ENTER")

An alternative using keyboard shortcut to focus address field:
openApp(r"C:\Users\lightspeed\AppData\Local\Google\Chrome\Application\chrome.exe")
wait( 5) # waits 5 seconds
type("l", KeyModifier.CTRL) # press lowercase L + CTRL
type("192.168.1.X")
type("Key.ENTER")

Revision history for this message
networkdownloader (networkdownloader) said :
#2

Thank you very much RaiMan for the prompt response. Beyond doubt you must be the best helping all the newbies. great job boss.

I modified the code slightly as Key.ENTER got pasted along with the 192.168.1.x line. I used "\n" instead (not sure if that is a bug). The following is my code

---------------------------------------------------------------------------------------------------------------
openApp(r"C:\Users\lightspeed\AppData\Local\Google\Chrome\Application\chrome.exe")
wait(7) # waits 5 seconds, I increased the wait to 7 seconds - just to be safe
type("l", KeyModifier.CTRL) # press lowercase L + CTRL
paste("192.168.1.x")
type("\n")
-----------------------------------------------------------------------------------------------------------------

Revision history for this message
networkdownloader (networkdownloader) said :
#3

Thanks RaiMan, that solved my question.

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

Uuups, sorry - my fault:

must be

type(Key.ENTER) # as the docs would have told you ;-)

Revision history for this message
Leochel (leochel519) said :
#5

There is a way to open Chrome without use the OpenApp(.... ???

Revision history for this message
Steph Werti (steffothefisher) said :
#6

@leochel519
you can simply click() and make a screenshot of the chrome-icon

@networkdownloader
you can also just add to the command line to open a webpage
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe http://www.google.com"