def test6(self): '''范围''' SettingOptUtils.range(self.driver) BasicAction.preview(self.driver) self.assertEqual( self.driver.find_element_by_xpath( '//*[@id="fields"]/li').get_attribute('min'), '1', '最小值设置失败') self.assertEqual( self.driver.find_element_by_xpath( '//*[@id="fields"]/li').get_attribute('max'), '10', '最大值设置失败')
def test2(self): '''姓名格式''' js = '$("#nameformat").next().find(".dk-select-options li").eq(1).click()' self.driver.execute_script(js) BasicAction.preview(self.driver) self.assertIn( 'n', self.driver.find_element_by_xpath( '//*[@id="fields"]/li/div/span[1]/input').get_attribute( 'class'), '姓名格式设置失败')
def test2(self): '''商品列表''' self.driver.find_element_by_id("addNoImgGoods").click() self.driver.find_element_by_class_name('goods-name-view').click() SettingOptUtils.pgoods(self.driver) BasicAction.preview(self.driver) self.assertEqual('商品名称测试商品(剩余40)', self.driver.find_element_by_class_name('name').text, '商品名设置失败') self.assertIn('测试', self.driver.find_element_by_class_name('des').text, '商品描述设置失败') self.assertIn('2', self.driver.find_element_by_class_name('price').text, '商品价格设置失败') self.assertIn('2', self.driver.find_element_by_class_name('number').get_attribute('value'), '商品默认值数量设置失败')
def test2(self): '每个IP只允许提交一次' self.driver.find_element_by_css_selector('[for="onePerIp"]').click() BasicAction.view(self.driver, self.formid, url) self.driver.find_element_by_id('btnSubmit').click() self.driver.refresh() self.driver.find_element_by_id('btnSubmit').click() self.assertIn( '测试', self.driver.find_element_by_css_selector( '[class="error-content"]').text, '每个IP只允许提交一次修改失败')
def test5(self): '收集条数据量后关闭表单' self.driver.find_element_by_css_selector('[for="collect"]').click() self.driver.find_element_by_css_selector( '[id="entriesLimit"]').send_keys('1') BasicAction.view(self.driver, self.formid, url) self.driver.find_element_by_id('btnSubmit').click() self.assertIn( '测试', self.driver.find_element_by_css_selector( '[class="error-content"]').text, '收集条数据量后关闭表单修改失败')
def test99(self): '验证码' self.driver.find_element_by_xpath( '//*[@id="form1"]/fieldset[3]/div[2]/div').click() self.driver.find_element_by_xpath( '//*[@id="form1"]/fieldset[3]/div[2]/div/ul/li[2]').click() BasicAction.view(self.driver, self.formid, url) self.assertIn( ' ', self.driver.find_element_by_xpath( '//*[@id="liCaptcha"]/div/small').text, '验证码')
def test8(self): '''选择项''' SettingOptUtils.pitems_radio(self.driver) BasicAction.preview(self.driver) self.assertIn( '剩余', self.driver.find_element_by_css_selector( '[style="color:#ccc;"]').text, '提交限制设置失败') self.assertIn( '男', self.driver.find_element_by_css_selector( '[selected="selected"]').text, '批量设置失败')
def test6(self): '''选择项''' SettingOptUtils.pitems_radio(self.driver) BasicAction.preview(self.driver) self.assertIn( '男', self.driver.find_element_by_xpath('//*[@id="t2"]').get_attribute( 'value'), '批量设置失败') self.assertIn( '剩余', self.driver.find_element_by_css_selector( '[style="color:#ccc;"]').text, '增减选项设置失败')
def test6(self): '''范围''' SettingOptUtils.daterange(self.driver) BasicAction.preview(self.driver) self.assertEqual( self.driver.find_element_by_css_selector( '[typ="date"]').get_attribute("dtmin"), '2018-08-01', '最小值设置失败') self.assertEqual( self.driver.find_element_by_css_selector( '[typ="date"]').get_attribute("dtmax"), '2018-08-31', '最大值设置失败')
def test1(self): '支付参数' self.driver.find_element_by_css_selector('[menuindex="m41"]').click() self.driver.switch_to_frame('settingform') self.driver.find_element_by_css_selector('[for="sale"]').click() self.driver.find_element_by_id('salem').send_keys(4) self.driver.find_element_by_id('salej').send_keys(2) BasicAction.view(self.driver, self.formid, url) self.assertIn( '折', self.driver.find_element_by_css_selector( '.discount-container label').text, '支付参数失败')
def test4(self): '''上传设置''' SettingOptUtils.pmaxsize(self.driver) BasicAction.preview(self.driver) self.driver.find_element_by_css_selector("[type='file']").send_keys( "%s\\1.jpg" % os.getcwd()) self.driver.find_element_by_css_selector("[type='file']").send_keys( "%s\\2.jpg" % os.getcwd()) sleep(1) self.assertIn('1', self.driver.find_element_by_class_name('msg').text, '上传设置失败')
def test4(self): '''选择项''' SettingOptUtils.pitems_checkboxes(self.driver) BasicAction.preview(self.driver) self.assertIn( '男', self.driver.find_element_by_xpath('//*[@id="F1"]').get_attribute( 'value'), '批量设置失败') sleep(1) self.assertIn( '剩余', self.driver.find_element_by_css_selector( '[style="color:#ccc;"]').text, '提交限制设置失败')
def test5(self): '''表体设置-按钮''' self.driver.find_element_by_id('pbody').click() self.driver.find_element_by_id('buttonContainer').click() # self.driver.find_element_by_xpath('//*[@id="buttonText"]/input').clear() # self.driver.find_element_by_xpath('//*[@id="buttonText"]/input').send_keys('按钮') self.driver.find_element_by_id('buttoncolorSel').click() self.driver.find_element_by_xpath( '//*[@id="buttoncolorPre"]/div/div[2]/span/div/ul/li[1]').click() BasicAction.preview(self.driver) js = "return $('.btn-submit').css('color')" color = self.driver.execute_script(js) self.assertEqual(color, 'rgb(250, 221, 209)', '表体设置-按钮修改失败')
def test2(self): '''表头设置''' self.driver.find_element_by_id('phead').click() self.driver.find_element_by_xpath( '//*[@id="pheadContainer"]/div[1]/div/div').click() self.driver.find_element_by_xpath( '//*[@id="pheadContainer"]/div[1]/div/ul/li[1]').click() self.driver.find_element_by_xpath( "//*[@id='fileCustomLogo']").send_keys('%s\\2.jpg' % os.getcwd()) sleep(1) BasicAction.preview(self.driver) js = "return $('.logo a').css('background-image')" url = self.driver.execute_script(js) self.assertIn('url', url, '表头设置修改失败')
def test6(self): '每天每台电脑/手机限填' self.driver.find_element_by_css_selector('[id="entriesLimit"]').clear() self.driver.find_element_by_css_selector('[for="dailytime"]').click() self.driver.find_element_by_css_selector( '[id="dailytimelimit"]').send_keys('1') BasicAction.view(self.driver, self.formid, url) self.driver.find_element_by_id('btnSubmit').click() self.driver.refresh() self.driver.find_element_by_id('btnSubmit').click() self.assertIn( '测试', self.driver.find_element_by_css_selector('[class="msg"]').text, '每天每台电脑/手机限填修改失败')
def test7(self): '启用IP黑名单' self.driver.find_element_by_css_selector( '[id="dailytimelimit"]').clear() self.driver.find_element_by_css_selector( '[for="chkIPcontrol"]').click() self.driver.find_element_by_css_selector( '[name="IPBLACKLIST"]').send_keys( DataUtils.verify_data(url, self.formid)['IP']) BasicAction.view(self.driver, self.formid, url) self.driver.find_element_by_id('btnSubmit').click() self.assertIn( '禁止', self.driver.find_element_by_css_selector( '[class="error-content"]').text, '启用IP黑名单修改失败')
def test3(self): '''表体设置-背景色''' self.driver.find_element_by_id('pbody').click() self.driver.find_element_by_id('bgContainer').click() self.driver.find_element_by_xpath( '//*[@id="backgroudgraphy"]/div/div').click() self.driver.find_element_by_xpath( '//*[@id="backgroudgraphy"]/div/ul/li[2]').click() self.driver.find_element_by_id('bgcolorSel').click() self.driver.find_element_by_xpath( '//*[@id="bgcolorPre"]/div/div[2]/span/div/ul/li[1]').click() BasicAction.preview(self.driver) js = "return $('.input').css('background-color')" color = self.driver.execute_script(js) self.assertEqual(color, 'rgb(250, 221, 209)', '表体设置-背景色修改失败')
def test4(self): '''表体设置-文字''' self.driver.find_element_by_id('pbody').click() self.driver.find_element_by_id('fontContainer').click() self.driver.find_element_by_xpath( '//*[@id="typography"]/div/div').click() self.driver.find_element_by_xpath( '//*[@id="typography"]/div/ul/li[3]').click() self.driver.find_element_by_id('colorSel').click() self.driver.find_element_by_xpath( '//*[@id="colorPre"]/div/div[2]/span/div/ul/li[1]').click() BasicAction.preview(self.driver) js = "return $('.desc').css('color')" color = self.driver.execute_script(js) self.assertEqual(color, 'rgb(250, 221, 209)', '表体设置-文字修改失败')
def test1(self): '凭密码才能访问' self.driver.find_element_by_css_selector( '#divPublic > table > tbody > tr > td:nth-child(1) > div > div' ).click() self.driver.find_element_by_css_selector( '#divPublic > table > tbody > tr > td:nth-child(1) > div > ul > li:nth-child(2)' ).click() self.driver.find_element_by_css_selector('[name="PWD"]').clear() self.driver.find_element_by_css_selector('[name="PWD"]').send_keys( '123') BasicAction.view(self.driver, self.formid, url) self.assertIsNotNone( self.driver.find_element_by_xpath('//*[@id="form1"]/label[2]'), '凭密码才能访问修改失败')
def test1(self): '''修改名称''' self.driver.find_element_by_id('reportName').clear() self.driver.find_element_by_id('reportName').send_keys('报表名称') BasicAction.SaveReport(self.driver) self.assertEqual( self.driver.find_element_by_id('rptTitle').text, '报表名称', '报表改名失败')
def test13(self): '''提交数据''' self.formid = BasicAction.preview(self.driver) self.driver.find_element_by_xpath('//*[@id="fields"]/li/div/input').send_keys('1122') self.driver.find_element_by_id('btnSubmit').click() sleep(1) self.assertEqual('1122',DataUtils.verify_data(url, self.formid)['F1'],'提交数据失败')
def test3(self): '''允许用户导出''' self.driver.find_element_by_css_selector('[for="showExport"]').click() BasicAction.SaveReport(self.driver) self.assertEqual( self.driver.find_element_by_id('exportButton').text, '导出', '允许用户导出失败')
def test2(self): '''修改描述''' self.driver.find_element_by_id('reportDescription').clear() self.driver.find_element_by_id('reportDescription').send_keys('报表描述') BasicAction.SaveReport(self.driver) self.assertEqual( self.driver.find_element_by_id('rptDesc').text, '报表描述', '报表描述修改失败')
def test6(self): '''布局方式''' self.driver.find_element_by_css_selector('[for="layout2"]').click() BasicAction.SaveReport(self.driver) self.assertEqual( self.driver.find_element_by_id('stage').get_attribute('class'), 'layout2', '布局方式修改失败')
def test1(self): '''标题''' self.driver.find_element_by_id('chartName').clear() self.driver.find_element_by_id('chartName').send_keys('统计') BasicAction.SaveReport(self.driver) self.assertEqual( self.driver.find_element_by_xpath( '//*[@id="z1"]/div/table/caption/h4').text, '统计', '统计改名失败')
def test2(self): '''描述''' self.driver.find_element_by_id('numberDescription').clear() self.driver.find_element_by_id('numberDescription').send_keys('描述') BasicAction.SaveReport(self.driver) self.assertEqual( self.driver.find_element_by_xpath('//*[@id="w0_0"]/em').text, '描述', '描述修改失败')
def test1(self): '''标题''' self.driver.find_element_by_id('numberName').clear() self.driver.find_element_by_id('numberName').send_keys('数字') BasicAction.SaveReport(self.driver) self.assertEqual( self.driver.find_element_by_xpath('//*[@id="w0_0"]/strong').text, '数字', '数字改名失败')
def setUpClass(cls): cls.Login = Login() cls.Login.login() cls.driver = cls.Login.driver cls.driver.get(url[0] + 'app/formmain/add?groupid=') sleep(1) cls.driver.find_element_by_id('drag_text').click() cls.driver.find_element_by_id('nb').click() BasicAction.preview(cls.driver) for i in range(3): cls.driver.find_element_by_name("F2_number").send_keys( random.randint(1, 10)) cls.driver.find_element_by_id("tmpid").send_keys( random.randint(1, 10)) cls.driver.find_element_by_id('btnSubmit').click() cls.driver.refresh() cls.driver.close()
def test1(self): '''标题''' self.driver.find_element_by_id('textDescription').clear() self.driver.find_element_by_id('textDescription').send_keys('文本') BasicAction.SaveReport(self.driver) self.assertEqual( self.driver.find_element_by_xpath('//*[@id="z1"]/div/div').text, '文本', '文本修改失败')
def setUpClass(cls): cls.Login = Login() cls.Login.login() cls.driver = cls.Login.driver cls.driver.get(url[0] + 'app/formmain/add?groupid=') sleep(1) cls.driver.find_element_by_id('sl').click() cls.formid = BasicAction.preview(cls.driver)