**我正在此类中调用类重用的方法** '''
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)
答案 0 :(得分:0)
您需要实例化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)