如何修复TypeError:getText()缺少1个必需的位置参数:python中的“self”?

2024-09-28 01:33:37 发布

您现在位置:Python中文网/ 问答频道 /正文

**我在这个类中调用类重用的方法** ''

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)

Tags: textfromimportselfbydefdriverusername
1条回答
网友
1楼 · 发布于 2024-09-28 01:33:37

您需要实例化重用并调用该对象上的方法。你知道吗

一些类似的东西:

@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)

相关问题 更多 >

    热门问题