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")

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

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
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

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().


if type() does not work at all, try

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.