我开始在PyCharm上使用Pywinauto的项目。以下是我的项目结构:
mybeautifulproject
utils
Utils
pages
LoginPage
tests
MyTest
这是我的Utils
文件:
所以基本上这个文件将一直被使用(self.app
在测试期间是被测试的应用程序)。在
我的MyTest
文件:
from __future__ import print_function
from utils import Utils
from pages import LoginPage
test = Utils.Test()
class MyTest:
loginPage= LoginPage.LoginPage(test)
loginPage.connexion("login", "password")
最后一个,LoginPage
:
from __future__ import print_function
class LoginPage:
def __init__(self, test):
self.FENETRE_AUTHENTIFICATION = test.app.window(auto_id='UserAuthentication')
self.INPUT_NOM = self.FENETRE_AUTHENTIFICATION.child_window(auto_id="tbLogin")
self.INPUT_MOT_DE_PASSE = self.FENETRE_AUTHENTIFICATION.child_window(auto_id="tbPassword")
self.BTN_VALIDER = self.FENETRE_AUTHENTIFICATION.child_window(title="Mot de Passe", found_index=0)
def connexion(self, login, password):
self.INPUT_NOM.set_text(login)
self.INPUT_MOT_DE_PASSE.set_text(password)
self.BTN_VALIDER.click()
当我启动MyTest
时,应用程序打开,字段被正确填充,但随后我得到错误:
AttributeError: Neither GUI element (wrapper) nor wrapper method 'click' were found (typo?)
我不知道为什么按钮不能点击。我知道它被找到了,因为,当我输入错误的标识符时,会有一个错误明确地说找不到对象。在
我错过了什么?在
谢谢。在
如果按钮未被识别为}或{}。在
ButtonWrapper
,根据按钮类型,正确的方法是.invoke()
或{若要检查它是如何识别的,请使用
self.BTN_VALIDER.wrapper_object()
进行调试。另外,内置的Python函数dir()
可以帮助您列出返回的包装器对象的所有可用属性。示例:相关问题 更多 >
编程相关推荐