getting sikuli to write html code

Asked by Daman Kirklin

What I want to do is get sikuli to type out a html code. Is this possible? I kept getting an error with type()

Question information

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

for these purposes you have to use paste() (see faq 933)

Revision history for this message
Daman Kirklin (shadowsparky87) said :
#2

paste() seems just as friendly about html code as type()

it seems like the problem is within the arrows <>.

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

Just be more specific:
where do you want to paste what? example?

Revision history for this message
Daman Kirklin (shadowsparky87) said :
#4
Revision history for this message
RaiMan (raimund-hocke) said :
#5

--- use raw string (nothing has to be escaped)
paste(r'<a href="http://www.gameusd.com/?agentid=17067 " target="_blank" rel="nofollow"><br>
<img src="http://i4.photobucket.com/albums/y109/Sk8Mythology/Cellphonetrackingsoftware.png"><br>
</a><br>')

--- or escape the apostrophes:
paste("<a href=\"http://www.gameusd.com/?agentid=17067 \" target=\"_blank\" rel=\"nofollow"\>"

Revision history for this message
Daman Kirklin (shadowsparky87) said :
#6

well that without the last line break but i'm sure you get the idea.

I'm trying to do is get it to type out a similar html code (general link to image) in a field on my web browser.

Revision history for this message
Daman Kirklin (shadowsparky87) said :
#7

ill give it a shot sec.

Revision history for this message
Daman Kirklin (shadowsparky87) said :
#8

is there something i'm missing? I pasted your code in here's an example

click(img of field)
paste(r'<a href="http://www.gameusd.com/?agentid=17067 " target="_blank" rel="nofollow"><br>
<img src="http://i4.photobucket.com/albums/y109/Sk8Mythology/Cellphonetrackingsoftware.png"><br>
</a><br>')

when I try to run it I get this.

[error] An error occurs at line 2 [error] Error message: SyntaxError: ("mismatched character '\\n' expecting '''", ('C:\\Users\\Daman\\AppData\\Local\\Temp\\sikuli-tmp815644451383041370.py', 2, 92, 'paste(r\' \n'))

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

sorry, the whole string has to be in one line.

If this is not possible or not wanted, you ca use the implicit concatenation feature for strings.

(if interested you find more about this stuff here: http://docs.python.org/reference/lexical_analysis.html#lexical-analysis)

your case:

paste(r'<a href="http://www.gameusd.com/?agentid=17067 " target="_blank" rel="nofollow"><br>'
        r'<img src="http://i4.photobucket.com/albums/y109/Sk8Mythology/Cellphonetrackingsoftware.png"><br>'
        r'</a><br>')

Revision history for this message
Daman Kirklin (shadowsparky87) said :
#10

works now thanks.