TA的每日心情 无聊 9 小时前
签到天数: 528 天
连续签到: 1 天
[LV.9]测试副司令
1 测试积点
这是代码:
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
复制代码 为什么会这样啊?折磨我好长时间
我来回答