python - 如何修复TypeError:getText()缺少1个必需的位置参数:python中的'self'?
问题描述
**我在这个类中调用类重用方法**'''
from behave import *
from Functions_Orange.reuse import Reuse
from Resources import Locator
class Orange:
@given('Navigate to organeHRM')
def Navigate_loginPage(context):
print("Testing======Test \n")
print(Locator.Locator_UserName)
Reuse.sendText(Locator=Locator.Locator_UserName,Text=Locator.UserName)
Reuse.sendText(Locator=Locator.Locator_passWord,Text=Locator.Password)
'''
这是我创建方法的重用类
from Resources.Driver import *
class Reuse(Driver):
y = Driver()
y.intialise()
def markElement(self,Locator):
self.intialise().find_element_by_xpath(Locator)
def click(self,Locator):
self.intialise().find_element_by_xpath(Locator).click()
def getText(self,Locator):
self.intialise().find_element_by_xpath(Locator)
return self.y.__getattribute__("text")
def sendText(self,Locator,Text):
self.intialise().find_element_by_xpath(Locator).send_keys(Text)
解决方案
您需要实例化 Reuse 并调用该对象的方法。
类似的东西:
@given('Navigate to organeHRM')
def Navigate_loginPage(context):
print("Testing======Test \n")
print(Locator.Locator_UserName)
r = Reuse()
r.sendText(Locator=Locator.Locator_UserName,Text=Locator.UserName)
r.sendText(Locator=Locator.Locator_passWord,Text=Locator.Password)
推荐阅读
- reactjs - Axios 和 Redux 返回未定义,而不是解析
- windows - 在运行和运行选择之间使用 PowerShell 在 Visual Studio Code 的集成终端中出现错误的变音字母
- ios - Firebase auth ui 或 google 在 macOS 和 iOS 上登录
- javascript - 图像在 A 帧中的本地服务器上不起作用
- points - 如何确定四面体三角形面的法线?
- html - 如何在 html 和 css 中更改表格列的背景颜色?
- python - 从项目根目录导入模块
- google-chrome - 浏览器不做任何动画
- python - 打印具有多个分隔值的字典
- sql-server - 日期转换与角度材料日期选择器和 SQL Server 数据库的混淆