from appium import webdriver
class Customer:
def __init__(self):
#logging.info("Test_appium.....setUp")
desire_caps = {}
desire_caps['platformName'] = 'Android'
desire_caps['platformVersion'] = '8.0'
desire_caps['deviceName'] = 'ae3fcc5d'
desire_caps['appPackage']='com.android.thememanager'
desire_caps['appActivity']='.business.startup.view.StartupActivity'
self.device = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desire_caps)
self.device.implicitly_wait(20) #全局默认等待最大时间
def Enter_Customer_List2(self,name):
self.device.find_element_by_android_uiautomator('text(\"'+name+'\")').click()
if __name__ == "__main__":
c = Customer()
c.Enter_Customer_List('铃声')
问题 1:
self.device = webdriver.Remote('http://127.0.0.1:4723/wd/hub,desire_caps')
在init函数中,没有 device 属性,但是 self 为什么可以调用 device 属性
如果在 定义改为 def init(self,device) 就报错误 TypeError: init() missing 1 required positional argument: 'device'
请问这是为什么。
问题 2:
调用 Enter_Customer_List2(self,name):
c.Enter_Customer_List('铃声')
TypeError: Enter_Customer_List() takes 1 positional argument but 2 were given
这个函数应该如何定义
请高手帮忙看一下,谢谢。