from pywinauto.application import Applicationimport timeclass start(): def __int__(self, com, url): self.com = com self.url = url self.app = Application(backend='uia').start(url) self.dlg = self.app.window(title_re=".*输入端口*") def start_ui(self): if self.com: self.ComboBox.select(self.com) time.sleep(2) self.dlg.确定.click() else: self.dlg['TitleBar'].关闭.click() time.sleep(1) self.dlg['关闭'].Button2.click() self.dlg['TitleBar'].关闭.click() time.sleep(1) self.dlg['关闭'].Button.click()com = 'COM4'url = 'C:\Program Files (x86)\EwayBot\ActuaticUI\ActuaticUI.exe'h=start(com, url)
错误提示:
C:\Users\fc\AppData\Local\Programs\Python\Python36\python.exe C:/Users/fc/Desktop/ActuaticUI-automation-Test/1.pyTraceback (most recent call last): File "C:/Users/fc/Desktop/ActuaticUI-automation-Test/1.py", line 28, in <module> h=start(com, url)TypeError: object() takes no parametersProcess finished with exit code 1
我那个init旁边是两个下划线没错,完全找不到bug,麻烦大家看看
解决方案
拼写错误导致继承了object类的__init__方法,该方法不接受除了self以外的实参