appium中TypeError: Common() takes no arguments

qq_38993422 2019-05-31 04:23:50
这是代码:

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] * 0.9)
y1 = (l[0] * 0.5)
x2 = (l[0] * 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[line:32] 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



为什么会这样啊?折磨我好长时间
...全文
404 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_46186005 2020-10-21
  • 打赏
  • 举报
回复
我也有过类似的错误: from baseView.baseView import BaseView:里面脚本写错了认真查看修改即可

5,227

社区成员

发帖
与我相关
我的任务
社区描述
软件工程/管理 质量管理/软件测试
功能测试压力测试安全性测试 个人社区 湖南省·长沙市
社区管理员
  • 软件测试
  • 虫无涯
  • 小博测试成长之路
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

欢迎大家加入到软件测试的社区,在这里,希望大家勇于发表自己的看法,欢迎大家分享自己在软件测试工作过程中遇到的问题以及工作经验分享。

1.想转行的小伙伴,遇到问题没有及时回复的,可以私聊小博进行反馈

2.大家对社区有好的建议,都可以在社区发帖进行反馈

推荐大家学习的软件测试入门笔记:软件测试入门学习笔记

试试用AI创作助手写篇文章吧