appium中TypeError: Common() takes no arguments
这是代码:from baseView.baseView import BaseView
from common.desired_caps import appium_desired
from selenium.common.exceptions import NoSuchElementException
from appium import webdriver
import logging
from selenium.webdriver.common.by import By
import time, os
class Common(BaseView):
cancelBtn = (By.ID, 'com.android.packageinstaller:id/permission_allow_button')
skipBtn = (By.ID, 'com.tal.kaoyan:id/tv_skip')
def check_cancelBtn(self):
logging.info('----------check_cancelBtn ------------')
try:
cancelBtn = self.driver.find_element(*self.cancelBtn)
except NoSuchElementException:
logging.info('no cancelBtn')
else:
cancelBtn.click()
def check_skipBtn(self):
logging.info('----------check_skipBtn ------------')
try:
skipBtn = self.driver.find_element(*self.skipBtn)
except NoSuchElementException:
logging.info('no skipBtn')
else:
skipBtn.click()
def get_window_size(self):
x = self.driver.get_window_size()['width']
y = self.driver.get_window_size()['height']
return x, y
def swipeLeft(self):
logging.info('swipeleft')
l = self.get_size()
x1 = (l * 0.9)
y1 = (l * 0.5)
x2 = (l * 0.1)
self.swipe(x1, y1, x2, y1, 2000)
def getTime(self):
self.now = time.strftime('%Y-%m-%d %H-%M-%S')
return self.now
def getScreenShot(self, module):
time = self.getTime()
image_file = os.path.dirname(os.path.dirname(__file__)) + '/screenshots/%s_%s.png' % (module, time)
logging.info('get %s screenshot' % module)
self.driver.get_screenshot_as_file(image_file)
if __name__ == '__main__':
driver = appium_desired()
com = Common(driver)
com.check_cancelBtn()
com.check_skipBtn()
这是报错:
/usr/local/bin/python3.7 /Users/pei/PycharmProjects/kyb_testProject/common/common_fun.py
/Users/pei/PycharmProjects/kyb_testProject/common/desired_caps.py:15: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
2019-05-31 16:20:24,649 desired_caps.py INFO start app...
data = yaml.load(file)
Traceback (most recent call last):
File "/Users/pei/PycharmProjects/kyb_testProject/common/common_fun.py", line 61, in <module>
com = Common(driver)
TypeError: Common() takes no arguments
为什么会这样啊?折磨我好长时间
传入参数不对 from baseView.baseView import BaseView:里面脚本写错了认真查看修改即可 需要参数吧
页:
[1]