AttributeError: 'str' object has no attribute '__exit__'

Asked by dinesh3434 on 2010-08-12

I have written a sikuli program for typing data into a portal textbox and press the enter key (as follows).

type( img, "500470")
type(Key.ENTER)

but i keep getting the following error after the 500470 is typed in the textbox

    type("1281615607923.png", "500470")
AttributeError: 'str' object has no attribute '__exit__'

i have tried type( img, "500470 \n") and everytime I get the above error. Even if i comment out this line, the same error is produced for the next type statement

Question information

Language:
English Edit question
Status:
Expired
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2010-08-12
Last reply:
2010-08-29
RaiMan (raimund-hocke) said : #1

It seems that type(img, "some text") is buggy.

Try to use
click(img) # to give focus to your entry field
type("some text"+Key.ENTER)
as a circumvention and post your situation as a bug.

dinesh3434 (dinesh-sun2003) said : #2

thank for the quick reply. I tried the suggestion, but i still get the following error

type("500470"+Key.ENTER)
AttributeError: 'str' object has no attribute '__exit__'

RaiMan (raimund-hocke) said : #3

Ok, the type as such seems to have a problem. Must be on Windows, since on my Mac it works fine.

then you should try to use paste() instead of type().

click("img-target-field")
paste("500470")
type(Key.ENTER)

if type() does not work at all, try
keyDown(Key.ENTER)
keyUp()

Later on I will check on my Win 7, wether it could be a bug.

Tip: I experienced, that using type()/paste() in web forms often requires to put intermediate short wait()'s (0.3 - 0.5 seconds), to give the app a chance to react. To advance from field to field it is easier to use the tab key.

Launchpad Janitor (janitor) said : #4

This question was expired because it remained in the 'Open' state without activity for the last 15 days.