51Testing软件测试论坛
标题:
请教下大佬们,谢谢!
[打印本页]
作者:
测试积点老人
时间:
2021-7-7 15:42
标题:
请教下大佬们,谢谢!
请教下大佬们,使用@pytest.mark.parametrize数据驱动时,提示“TypeError: message_complete() missing 1 required positional argument: ‘bathroom_name’”
def test_data():
# 打开Excel文件
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
openExcelFile = open_workbook(path + "/config/data.xlsx")
# 获取工作表
getSheet = openExcelFile.sheet_by_name("Sheet1")
# 获取行数
rowNumber = getSheet.nrows
# 数据List
dataList = []
# 从第二行开始遍历每一行
for i in range(1, rowNumber):
# 把每个单元格的数值存放到dataLis
dataList.append(getSheet.row_values(i))
return dataList
"""浴室管理"""
class Bathroom_Func(BasePage):
def add_bathroom(self):
lp = BasePage(self._driver)
"""
点击右上角“新增”按钮进入新增浴室界面
:return:
"""
try:
self._driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.qekj.merchant:id/iv_add")').click()
except Exception as e:
self._driver.get_screenshot_as_file(lp.screenshot_filepath())
return self
@pytest.mark.parametrize("bathroom_name", test_data())
def message_complete(self, bathroom_name):
lp = BasePage(self._driver)
"""
完善新增浴室信息
"""
sleep(1)
try:
self._driver.find_element_by_android_uiautomator(
'new UiSelector().resourceId("com.qekj.merchant:id/et_device_name")').send_keys(bathroom_name)
self._driver.find_element_by_android_uiautomator(
'new UiSelector().resourceId("com.qekj.merchant:id/tv_store_name")').click()
sleep(1)
self._driver.find_element_by_android_uiautomator(
'new UiSelector().text("确定")').click()
sleep(1)
self._driver.find_element_by_android_uiautomator(
'new UiSelector().resourceId("com.qekj.merchant:id/tv_sex")').click()
self._driver.find_element_by_android_uiautomator(
'new UiSelector().text("确定")').click()
self._driver.find_element_by_android_uiautomator(
'new UiSelector().text("提交")').click()
except Exception as e:
self._driver.get_screenshot_as_file(lp.screenshot_filepath())
return self
@pytest.mark.parametrize("bathroom_name",test_data())
def delete_bathroom(self,bathroom_name):
"""删除新增浴室"""
action1 = 'new UiSelector().text{bathroom_name}'.format(bathroom_name=bathroom_name)
action2 = 'new UiSelector().text("删除")'
self._driver.find_element_by_android_uiautomator(action1).click()
self._driver.find_element_by_android_uiautomator(action2).click()
return self
复制代码
[attach]133016[/attach]
作者:
海海豚
时间:
2021-7-8 09:16
对bathroom_name这个实例化一下
作者:
bellas
时间:
2021-7-8 10:16
找下这个bathroom_name赋值了没
作者:
qqq911
时间:
2021-7-8 10:34
看下是不是要加self
作者:
郭小贱
时间:
2021-7-8 16:51
@pytest.mark.parametrize需要在pytest框架下执行的。
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2