Redem
Redem

Reputation: 21

Pywinauto type_keys() omits "%" in string

When attempting to input a string 'customer asked for 30% discount' to a form by using type_keys() in Pywinauto 0.6.5, the output it sends is 'customer asked for 30 discount" omitting '%'.

Tried escape character:

  1. control.type_keys('customer asked for 30%% discount',with_spaces=True)
  2. control.type_keys('customer asked for 30\% discount',with_spaces=True)

But it still omits the '%'

When printing data in console string outputs correctly. So it is not a Python 3.7 issue.

Upvotes: 2

Views: 2230

Answers (2)

grantr
grantr

Reputation: 1060

here's a little utility I use to prep passwords when using pywinauto.handler.type_keys():

password = 'cJ/Dy}(4H%x!c{)6'
clean_pass = ''
for c in password:
    if c in ['(', ')', '{', '}', '%']:
        clean_pass += ('{' + c + '}')
    else:
        clean_pass += c
print(clean_pass)

Upvotes: 1

Vasily Ryabov
Vasily Ryabov

Reputation: 9991

As Redem already found, some special symbols must be escaped this way:

 control.type_keys('customer asked for 30{%} discount', with_spaces=True)

or method .set_edit_text() can be used for edit box control:

control.set_edit_text(r'customer asked for 30% discount')

Upvotes: 5

Related Questions