Beispiel #1
0
    def test_1_add_level1_dir_cancel(self):
        '''
        check add directory cancel funtion is available
        :return:
        '''
        #click add directory button
        add_dir_button = self.obj.getElementObject(self.driver, 'filePage',
                                                   'addDirButton')
        add_dir_button.click()

        #Type 'selenium' in the textbox and click cancel button
        add_dir_textbox = self.obj.getElementObject(self.driver, 'filePage',
                                                    'addDirTextBox')
        add_dir_textbox.send_keys('selenium')
        cancel_add_button = self.obj.getElementObject(self.driver, 'filePage',
                                                      'cancelAddButton')
        cancel_add_button.click()

        #positioning the name of first record
        models_list = self.driver.find_element_by_xpath(
            '//div[@class="ivu-checkbox-group"]')
        first_record_name = models_list.find_element_by_xpath('div[1]/span[2]')

        #check if the cancelled add directory is saved.
        try:
            self.assertEqual(first_record_name.text, 'selenium')
        except AssertionError:
            pass
        except Exception as e:
            print(traceback.print_exc())
        else:
            raise customError('放弃添加的文件夹竟然被保存了?')
Beispiel #2
0
    def test_2_add_level1_dir_confirm(self):
        '''
        check if the dirctory add funtion is available
        :return:
        '''
        # click add directory button
        add_dir_button = self.obj.getElementObject(self.driver, 'filePage',
                                                   'addDirButton')
        add_dir_button.click()

        # Type 'selenium' in the textbox and click confirm button
        add_dir_textbox = self.obj.getElementObject(self.driver, 'filePage',
                                                    'addDirTextBox')
        add_dir_textbox.send_keys('selenium')
        confirm_add_button = self.obj.getElementObject(self.driver, 'filePage',
                                                       'confirmAddButton')
        confirm_add_button.click()

        #Positioning the name of first record
        models_list = self.driver.find_element_by_xpath(
            '//div[@class="ivu-checkbox-group"]')
        first_record_name = models_list.find_element_by_xpath('div[1]/span[2]')

        # Check if the directory has been created .
        try:
            self.assertEqual(first_record_name.text, 'selenium')
        except AssertionError as e:
            print(traceback.print_exc())
        else:
            raise customError('添加的文件夹竟然没有被保存?')
Beispiel #3
0
    def test_9_rename_level2_dir_cancel(self):
        '''
        Check if rename of directory funtion is available
        :return:
        '''

        # 进入指定的一级目录下
        level1 = self.obj.getElementObject(self.driver, 'filePage', 'level1')
        level1.click()

        #Positioning the first record
        models_list = self.driver.find_element_by_xpath(
            '//div[@class="ivu-checkbox-group"]')
        first_record_name = models_list.find_element_by_xpath('div[1]')
        ActionChains(self.driver).move_to_element(first_record_name).perform(
        )  # move the mouse pointer on the record

        # Click Rename button
        rename_dir_button = self.obj.getElementObject(self.driver, 'filePage',
                                                      'renameButton')
        rename_dir_button.click()

        #Type string 'selenium' in textbox
        rename_dir_textbox = self.obj.getElementObject(self.driver, 'filePage',
                                                       'reNameTextBox')
        rename_dir_textbox.send_keys('rename')

        #Click cancel button to cancel the rename opera
        rename_dir_cancel = self.obj.getElementObject(self.driver, 'filePage',
                                                      'cancelReNameButton')
        rename_dir_cancel.click()

        # check if the cancelled rename directory is saved.
        try:
            self.assertEqual(first_record_name.text, 'rename')
        except AssertionError:
            pass
        except Exception as e:
            print(traceback.print_exc())
        else:
            raise customError('放弃重命名的文件夹竟然被保存了?')
Beispiel #4
0
    def test_12_delete_level2_dir_comfirm(self):
        '''
        Check if the delete funtion is available
        :return:
        '''

        # 进入指定的一级目录下
        level1 = self.obj.getElementObject(self.driver, 'filePage', 'level1')
        level1.click()

        # 连接 MongoDB 数据库
        client = MongoClient('114.215.220.91', 27017)
        db = client['Bim-FM']
        db.authenticate("fmDevelop", "abcd1234!")  # 输入数据库的用户密码
        collection = db.folder  # 表名

        # 查询列表数据
        data = collection.find({
            'shopId': '4',
            'parentId': ObjectId("ObjectId")
        })

        # 把数据库查询结果转换成字典形式
        cou = 0
        records = {}
        for i in data:
            sub = dict(i)
            new = {cou: sub}
            records.update(new)
            cou += 1

        # Positioning the first record
        models_list = self.driver.find_element_by_xpath(
            '//div[@class="ivu-checkbox-group"]')
        first_record = models_list.find_element_by_xpath('div[1]')
        ActionChains(self.driver).move_to_element(
            first_record).perform()  # move the mouse pointer on the record

        # Click delete button
        delete_button = self.obj.getElementObject(self.driver, 'filePage',
                                                  'deleteButton')
        delete_button.click()

        # Check if the content delete alert pop-up box is correct
        delete_alert = self.obj.getElementObject(self.driver, 'filePage',
                                                 'deleteAlert')
        delete_alert.is_displayed()  # 检查弹框是否显示

        # Click delete button
        confirm_delete_button = self.obj.getElementObject(
            self.driver, 'filePage', 'deleteConfirmButton')
        confirm_delete_button.click()
        # time.sleep(2)

        # 验证弹框是否消失,数据是否删除
        from selenium.common.exceptions import StaleElementReferenceException
        try:
            delete_alert.is_displayed()
        except StaleElementReferenceException:
            print('弹框消失')
        else:
            raise customError('弹框没有消失,测试失败')

        # 查询列表数据
        data2 = collection.find({
            'shopId': '4',
            'parentId': ObjectId("ObjectId")
        })

        # 把数据库查询结果转换成字典形式
        cou = 0
        records2 = {}
        for i in data2:
            sub = dict(i)
            new = {cou: sub}
            records2.update(new)
            cou += 1
        # Check if the folder is deleted
        if records2[len(records2) - 1]['name'] == records[len(records) -
                                                          1]['name']:
            raise customError('删除一级目录失败了....')
        elif records2[len(records2) - 1]['name'] == records[len(records) -
                                                            2]['name']:
            print('删除成功')
        else:
            raise customError('删除成功了,但是数据不太对,请检查')
Beispiel #5
0
    def test_11_delete_level2_dir_cancel(self):
        '''
        Check if the delete cancel funtion is available
        :return:
        '''

        # 进入指定的一级目录下
        level1 = self.obj.getElementObject(self.driver, 'filePage', 'level1')
        level1.click()

        # 连接 MongoDB 数据库
        client = MongoClient('000.000.000.000', 27017)
        db = client['xxxxx']
        db.authenticate("DB_User_Name", "DB_Password")  # 输入数据库的用户密码
        collection = db.folder  # 表名

        # 查询列表数据
        data = collection.find({
            'shopId': '4',
            'parentId': ObjectId("ObjectId")
        })

        # 把数据库查询结果转换成字典形式
        cou = 0
        records = {}
        for i in data:
            sub = dict(i)
            new = {cou: sub}
            records.update(new)
            cou += 1

        # Positioning the first record
        models_list = self.driver.find_element_by_xpath(
            '//div[@class="ivu-checkbox-group"]')
        first_record = models_list.find_element_by_xpath('div[1]')
        ActionChains(self.driver).move_to_element(
            first_record).perform()  # move the mouse pointer on the record

        # Click Rename button
        delete_button = self.obj.getElementObject(self.driver, 'filePage',
                                                  'deleteButton')
        delete_button.click()

        # Check if the content delete alert pop-up box is correct
        delete_alert = self.obj.getElementObject(self.driver, 'filePage',
                                                 'deleteAlert')
        delete_alert.is_displayed()  # 检查弹框是否显示

        delete_alert_title_range = self.obj.getElementObject(
            self.driver, 'filePage', 'deleteAlertTitle')
        delete_alert_title = delete_alert_title_range.find_element_by_xpath(
            's')
        self.assertEqual(delete_alert_title.text, '删除文件夹')  # 检查弹框标题是否正确

        # 检查弹出框的路径是否显示正确
        delete_alert_dir = self.obj.getElementObject(self.driver, 'filePage',
                                                     'deleteAlertDirectory')
        delete_alert_dir.is_displayed()  # 验证是否存在
        self.assertEqual(
            delete_alert_dir.find_element_by_xpath('span[1]').text,
            '全部>')  # 根目录验证
        self.assertEqual(
            delete_alert_dir.find_element_by_xpath('span[2]').text,
            'Auto Test>')  # 一级目录验证
        self.assertEqual(
            delete_alert_dir.find_element_by_xpath('span[3]').text,
            'rename')  # 二级目录验证

        delete_alert_text = self.obj.getElementObject(self.driver, 'filePage',
                                                      'deleteAlertText')
        self.assertEqual(delete_alert_text.text,
                         '删除此(些)文件夹后,将无法恢复,文件夹内的所有内容会被一起删除,您是否确定删除?')  # 弹框文本校验

        # 第一种取消方式 : 点击关闭按钮
        close_button = delete_alert_title_range.find_element_by_xpath('span')
        close_button.click()
        # time.sleep(2)

        # 验证弹框是否消失,数据是否删除
        from selenium.common.exceptions import StaleElementReferenceException
        try:
            delete_alert.is_displayed()
        except StaleElementReferenceException:
            print('弹框消失')
        else:
            raise customError('弹框没有消失,测试失败')

        # 查询列表数据
        data2 = collection.find({
            'shopId': '4',
            'parentId': ObjectId("ObjectId")
        })

        # 把数据库查询结果转换成字典形式
        cou = 0
        records2 = {}
        for i in data2:
            sub = dict(i)
            new = {cou: sub}
            records2.update(new)
            cou += 1
        # Check if the folder is deleted
        self.assertEqual(records[len(records) - 1]['name'],
                         records2[len(records2) - 1]['name'])

        #第二种方式
        first_record = models_list.find_element_by_xpath('div[1]')
        ActionChains(self.driver).move_to_element(first_record).perform()
        delete_button.click()
        cancel_button = self.obj.getElementObject(self.driver, 'filePage',
                                                  'deleteCancelButton')
        cancel_button.click()  # 点击取消按钮

        # 检查弹框是否显示
        try:
            delete_alert.is_displayed()
        except StaleElementReferenceException:
            print('弹框消失')
        else:
            raise customError('弹框没有消失,测试失败')

        # 查询列表数据
        data3 = collection.find({
            'shopId': '4',
            'parentId': ObjectId("ObjectId")
        })

        # 把数据库查询结果转换成字典形式
        cou = 0
        records3 = {}
        for i in data3:
            sub = dict(i)
            new = {cou: sub}
            records3.update(new)
            cou += 1
        # Check if the folder is deleted
        self.assertEqual(records[len(records) - 1]['name'],
                         records3[len(records3) - 1]['name'])
Beispiel #6
0
    def test_2_upload_cancel(self):
        '''
        check if the cancel upload funtion is available
        :return:
        '''
        enter_test_dir(self)

        # 文件路径
        path = '/Users/billylee/Documents/rvt'

        # 获取目录下文件的列表
        file_list = os.listdir(path)

        files = []

        # 获取目录下的文件列表
        for i in file_list:
            # os.path.splitext():分离文件名与扩展名
            if os.path.splitext(i)[1] == '.rvt':
                files.append(i)
                print(i)

        # 随机选取一个目录下的文件
        choose = random.randint(0, len(files) - 1)
        file = files[choose]
        print('文件名是:  ', file)

        # 上传上面选取的文件
        uploadButton = self.obj.getElementObject(self.driver, 'filePage',
                                                 'uploadButton')
        uploadButton.send_keys(path + '/' + file)  # 上传随机的一个文件

        # 显示等待模型上传中组件
        WebDriverWait(self.driver, 10).until(
            EC.visibility_of(
                self.obj.getElementObject(self.driver, 'filePage',
                                          'uploadingFile')))

        # 定位模型上传统计组件
        uploadingCount = self.obj.getElementObject(self.driver, 'filePage',
                                                   'uploadingCount')

        # 判断当前模型上传的状态是否正确,如果正确就点击取消上传按钮,否则报错
        if uploadingCount.text == '正在上传:1':

            #点击取消上传按钮
            cancel_upload = self.obj.getElementObject(self.driver, 'filePage',
                                                      'cancelUpload')
            cancel_upload.click()
            print('当前上传总数是:  ', uploadingCount.text)
            time.sleep(2)

            #检查是否取消成功
            self.assertTrue(uploadingCount.text, '正在上传:0')
            EC.invisibility_of_element_located(upload_file)

        elif uploadingCount.text == '正在上传:0':
            print('当前上传总数是:  ', uploadingCount.text)
            raise customError('上传的模型数据哪儿去了? ')
        else:
            print('当前模型上传的个数是: ', uploadingCount.text)
            raise customError('为什么不是一条数据? 哪儿来的数据?')
Beispiel #7
0
    def test_6_delete_model_confirm(self):
        '''
        check if the delete funtion is available
        :return:
        '''

        # 连接 MongoDB 数据库
        client = MongoClient('000.000.000.000', 27017)
        db = client['XXXXX']
        db.authenticate("DB_User_Name", "DB_Password")  # 输入数据库的用户密码
        collection = db.FmFile  # 表名

        # 查询列表数据
        data = collection.find({
            'folderId': ObjectId("ObjectId"),
            'deleted': 0
        })

        # 把数据库查询结果转换成字典形式
        cou = 0
        records = {}
        for i in data:
            sub = dict(i)
            new = {cou: sub}
            records.update(new)
            cou += 1

        # 进入指定测试路径
        enter_test_dir(self)

        # 鼠标悬浮在第一条数据上
        models_list = self.driver.find_element_by_xpath(
            '//div[@class="ivu-checkbox-group"]')
        first_record = models_list.find_element_by_xpath('div[1]')
        ActionChains(self.driver).move_to_element(first_record).perform()

        # 检查删除按钮是否出现
        delete_button = self.obj.getElementObject(self.driver, 'filePage',
                                                  'deleteButton')
        delete_button.is_displayed()

        # 点击删除按钮
        delete_button.click()

        # 检查删除弹框内容是否显示正确
        delete_alert = self.obj.getElementObject(self.driver, 'filePage',
                                                 'deleteAlert')
        delete_alert.is_displayed()  # 检查弹框是否显示

        confirm_button = self.obj.getElementObject(self.driver, 'filePage',
                                                   'deleteConfirmButton')
        confirm_button.click()  # 点击取消按钮

        # 检查弹框是否显示
        from selenium.common.exceptions import StaleElementReferenceException
        try:
            delete_alert.is_displayed()
        except StaleElementReferenceException:
            print('弹框消失')
        else:
            raise customError('弹框没有消失,测试失败')

        time.sleep(5)  #等几秒,让数据库反映反映....

        # 验证数据是否发生变化
        data2 = collection.find({
            'folderId': ObjectId("ObjectId"),
            'deleted': 0
        })

        # 把数据库查询结果转换成字典形式
        cou = 0
        records2 = {}
        for i in data2:
            sub = dict(i)
            new = {cou: sub}
            records2.update(new)
            cou += 1

        #打印数据库两次的查询结果的遍历对比
        print('records : ' + str(len(records)),
              ' ======>records2 : ' + str(len(records2)))
        for i in range(len(records) - 1):
            print('Records %d : ' % (i), records[i])
            try:
                print('Records2 %d : ' % (i), records2[i])
            except Exception:
                print('Records2 已经没有更多的数据了')

        try:
            self.assertEqual(len(records2), len(records))  # 检查数据是否被删除
        except AssertionError:
            print('数据发生变化,验证通过')
        else:
            raise customError('数据没有发生变化,有问题需要检查')

        #由于每次删除的都是第一条(修改文件名后的文件都教 ReNamed),
        #一般情况只要 ReNamed文件名不存在数据库中就算是删除成功了
        if 'ReNamed' in records2.values():
            raise customError('rename 文件依然存在,请检查数据是否被删除')
        else:
            print('The rvt file has been deleted!')
Beispiel #8
0
    def test_5_delete_model_cancel(self):
        '''
        check if the cancel delete funtion is available
        :return:
        '''

        # 连接 MongoDB 数据库
        client = MongoClient('000.000.000.000', 27017)
        db = client['xxxxxx']
        db.authenticate("DB_User_Name", "DB_Password")  # 输入数据库的用户密码
        collection = db.FmFile  # 表名

        # 查询列表数据
        data = collection.find({
            'folderId': ObjectId("ObjectId"),
            'deleted': 0
        })

        # 把数据库查询结果转换成字典形式
        cou = 0
        records = {}
        for i in data:
            sub = dict(i)
            new = {cou: sub}
            records.update(new)
            cou += 1

        # 进入指定测试路径
        enter_test_dir(self)

        # 鼠标悬浮在第一条数据上
        models_list = self.driver.find_element_by_xpath(
            '//div[@class="ivu-checkbox-group"]')
        first_record = models_list.find_element_by_xpath('div[1]')
        ActionChains(self.driver).move_to_element(first_record).perform()

        # 检查删除按钮是否出现
        delete_button = self.obj.getElementObject(self.driver, 'filePage',
                                                  'deleteButton')
        delete_button.is_displayed()

        # 点击删除按钮
        delete_button.click()

        # 检查删除弹框内容是否显示正确
        delete_alert = self.obj.getElementObject(self.driver, 'filePage',
                                                 'deleteAlert')
        delete_alert.is_displayed()  #检查弹框是否显示

        delete_alert_title_range = self.obj.getElementObject(
            self.driver, 'filePage', 'deleteAlertTitle')
        delete_alert_title = delete_alert_title_range.find_element_by_xpath(
            's')
        self.assertEqual(delete_alert_title.text, '删除文件')  #检查弹框标题是否正确

        #检查弹出框的路径是否显示正确
        delete_alert_dir = self.obj.getElementObject(self.driver, 'filePage',
                                                     'deleteAlertDirectory')
        delete_alert_dir.is_displayed()  #验证是否存在
        self.assertEqual(
            delete_alert_dir.find_element_by_xpath('span[1]').text,
            '全部>')  #根目录验证
        self.assertEqual(
            delete_alert_dir.find_element_by_xpath('span[2]').text,
            'Auto Test>')  #一级目录验证
        self.assertEqual(
            delete_alert_dir.find_element_by_xpath('span[3]').text,
            'ReNam1>')  #二级目录验证
        self.assertEqual(
            delete_alert_dir.find_element_by_xpath('span[4]').text,
            'ReNamed.rvt')  #文件名验证

        delete_alert_text = self.obj.getElementObject(self.driver, 'filePage',
                                                      'deleteAlertText')
        self.assertEqual(delete_alert_text.text,
                         '删除此(些)文件后,将无法恢复,您是否确定删除?')  #弹框文本校验

        # 第一种取消方式 : 点击关闭按钮
        close_button = delete_alert_title_range.find_element_by_xpath('span')
        close_button.click()
        # time.sleep(2)

        # 验证弹框是否消失,数据是否删除
        from selenium.common.exceptions import StaleElementReferenceException
        try:
            delete_alert.is_displayed()
        except StaleElementReferenceException:
            print('弹框消失')
        else:
            raise customError('弹框没有消失,测试失败')

        data2 = collection.find({
            'folderId': ObjectId("ObjectId"),
            'deleted': 0
        })

        # 把数据库查询结果转换成字典形式
        cou = 0
        records2 = {}
        for i in data2:
            sub = dict(i)
            new = {cou: sub}
            records2.update(new)
            cou += 1
        self.assertEqual(len(records2), len(records))  #检查数据是否被删除

        #第二种取消方式

        # 点击删除按钮
        first_record = models_list.find_element_by_xpath('div[1]')
        ActionChains(self.driver).move_to_element(first_record).perform()
        delete_button.click()
        cancel_button = self.obj.getElementObject(self.driver, 'filePage',
                                                  'deleteCancelButton')
        cancel_button.click()  #点击取消按钮

        #检查弹框是否显示
        try:
            delete_alert.is_displayed()
        except StaleElementReferenceException:
            print('弹框消失')
        else:
            raise customError('弹框没有消失,测试失败')

        #验证数据是否发生变化
        data3 = collection.find({
            'folderId': ObjectId("ObjectId"),
            'deleted': 0
        })

        # 把数据库查询结果转换成字典形式
        cou = 0
        records3 = {}
        for i in data3:
            sub = dict(i)
            new = {cou: sub}
            records3.update(new)
            cou += 1
        self.assertEqual(len(records3), len(records))  #检查数据是否被删除