TA的每日心情 | 无聊 昨天 09:47 |
---|
签到天数: 528 天 连续签到: 1 天 [LV.9]测试副司令
|
1测试积点
请教下大佬们,使用@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
复制代码
|
|