Gokul Kathirvel
Gokul Kathirvel

Reputation: 23

Pywinauto-How to get message contents from dialog box

I have done my form in VB. For instance, the alert box appears after submit button is clicked and i want to read the static content inside my alert box. Here is my code:

    import sys
    import json
    from pywinauto.application import Application
    print("test")
    app = Application(backend="uia").start("")
    data=json.loads(sys.argv[1])
    text=[]
    for rec in data:
        app.Form1.Edit6.type_keys(rec['name'])
        app.Form1.Edit5.type_keys(rec['age'])
        if rec['gender']=="male":
           app.Form1.Male.click()
        elif rec['gender']=="female":
           app.Form1.Female.click()

    app.Form1.Edit3.type_keys(rec['phnum'])

    app.Form1.Submit.click_input()

   app.Form1.Success.wait('visible', timeout=20)
   text=app.Form1.Success.Static.WindowText()

   app.Form1.Success.OKButton.click_input() 

  print("Records Submitted for ",rec['name'])
  print('\n')
  app.Form1.close()
  print text
 sys.stdout.flush()

Upvotes: 0

Views: 705

Answers (1)

Gokul Kathirvel
Gokul Kathirvel

Reputation: 23

used window_text() instead of WindowText()

Upvotes: 1

Related Questions