jenkins run pywinauto start not use

Viewed 83

i run my code on vscode ide or use cmd will be fine, but when i use jenkins run windows batch cmd will be fail (app start no use) , my jenkins also run on admin

    C:\ProgramData\Jenkins\.jenkins\workspace\Agent_Automation>python test_enf_ins_gui.py  
Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\pywinauto\timings.py", line 436, in wait_until_passes
    func_val = func(*args, **kwargs)
  File "C:\Program Files\Python37\lib\site-packages\pywinauto\findwindows.py", line 87, in find_element
    raise ElementNotFoundError(kwargs)
pywinauto.findwindows.ElementNotFoundError: {'class_name': 'MsiDialogCloseClass', 'backend': 'uia', 'visible_only': False}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test_enf_ins_gui.py", line 5, in <module>
    r'C:\Users\txone\Downloads\Install.exe').connect(class_name="MsiDialogCloseClass",timeout=20)
  File "C:\Program Files\Python37\lib\site-packages\pywinauto\application.py", line 994, in connect
    *(), **kwargs
  File "C:\Program Files\Python37\lib\site-packages\pywinauto\timings.py", line 458, in wait_until_passes
    raise err
pywinauto.timings.TimeoutError
1 Answers

If you run Jenkins agent as a service, Windows will not give you access to create/control any GUI. You have to start Jenkins agent under normal user, not as a service (maybe using Windows scheduler). Many hints are collected in the Remote Execution Guide. There are many things how to handle RDP or VNC desktop. Please read carefully.

P.S. Also PsExec may hang under Jenkins/Java (known issue, probably not your case), but you can use open-source analogue PAExec with similar options if you need it one day.

Related