class Bjcl_ck(unittest.TestCase): """我的工作台-报警车辆-查看""" def setUp(self): self.driver = webdriver.Chrome() self.driver_l = LoginPage(self.driver) self.driver_g = GongzuotaiPage(self.driver) self.driver_g.open() """登录""" self.driver_l.input_username("admin") self.driver_l.input_password("super_0711") self.driver_l.click_login() title = self.driver_l.get_title() self.assertEqual(title, u"后台管理") """进入工作台""" self.driver_g.click_gongzuotai() def test_bjcl_ck(self): """工作台-报警车辆-查看""" self.driver_g.click_baojing_chakan() xinzengbaojing_loc = ("class name", "el-button--info") result = self.driver_g.is_text_in_element(xinzengbaojing_loc, u"新增报警") self.assertEqual(result, True) def tearDown(self): self.driver.quit()
class Hmd_ck(unittest.TestCase): """我的工作台-黑名单车辆-查看""" def setUp(self): self.driver = webdriver.Chrome() self.driver_b = BasePage(self.driver) self.driver_l = LoginPage(self.driver) self.driver_g = GongzuotaiPage(self.driver) #self.driver_c=ClbjPage(self.driver) self.driver_l.open() """登录""" self.driver_l.input_username("admin") self.driver_l.input_password("super_0711") self.driver_l.click_login() title = self.driver_l.get_title() self.assertEqual(title, u"后台管理") """进入工作台""" self.driver_g.click_gongzuotai() def test_heimingdan(self): self.driver_g.click_heimingdan_chakan() heimingdan_loc = ( "xpath", ".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[2]/div" ) #显示的第一条数据的名字是张峰 result = self.driver_b.is_text_in_element(heimingdan_loc, u"张峰") self.assertEqual(result, True) def tearDown(self): self.driver.quit()
class Guji(unittest.TestCase): """定位""" def setUp(self): self.driver=webdriver.Chrome() self.driver_g=GongzuotaiPage(self.driver) self.driver_l=LoginPage(self.driver) self.driver_l.open() self.driver_l.input_username() self.driver_l.input_password() self.driver_l.click_login() title=self.driver_l.get_title() self.assertEqual(title,u"后台管理") """进入工作台""" self.driver_g.click_gongzuotai() self.driver_g.click_dingwei() def test_dingwei_chepaihao(self): """定位-芯片编号""" self.driver_g.input_dingwei_neirong(u"511539") self.driver_g.click_dingwei_queding() text=("xpath","html/body/div[2]/form/div[3]/div/div/div[1]/span[4]") result=self.driver_g.is_text_in_element(text,"王连珍") self.assertEqual(result,True) def tearDown(self): self.driver.quit()
class Guji(unittest.TestCase): """轨迹""" def setUp(self): self.driver = webdriver.Chrome() self.driver_g = GongzuotaiPage(self.driver) self.driver_l = LoginPage(self.driver) self.driver_l.open() self.driver_l.input_username() self.driver_l.input_password() self.driver_l.click_login() title = self.driver_l.get_title() self.assertEqual(title, u"后台管理") """进入工作台""" self.driver_g.click_gongzuotai() self.driver_g.click_guiji() def test_chaxunguiji_xinpian(self): """输入芯片编号查询轨迹""" self.driver_g.input_guiji_neirong("524451") self.driver_g.click_guiji_jinriguiji() self.driver_g.input_guiji_begintime("2017-11-02 13:39:32") self.driver_g.click_guiji_neirong() self.driver_g.input_guiji_endtime("2017-11-22 13:39:32") self.driver_g.click_guiji_neirong() self.driver_g.click_guiji_chaxun() jizhan_loc = ( "xpath", ".//*[@id='container']/div[1]/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[1]/div" ) result = self.driver_g.is_text_in_element(jizhan_loc, "7255") self.assertEqual(result, True) def test_chaxunguiji_chepaihao(self): """输入车牌号查询轨迹""" self.driver_g.click_guiji_id() self.driver_g.click_guiji_neirong_chepaihao() self.driver_g.input_guiji_neirong(u"武汉AA2796") self.driver_g.click_guiji_jinriguiji() self.driver_g.input_guiji_begintime("2017-11-02 13:39:32") self.driver_g.click_guiji_neirong() self.driver_g.input_guiji_endtime("2017-11-22 13:39:32") self.driver_g.click_guiji_neirong() self.driver_g.click_guiji_chaxun() jizhan_loc = ( "xpath", ".//*[@id='container']/div[1]/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[1]/div" ) result = self.driver_g.is_text_in_element(jizhan_loc, "7255") self.assertEqual(result, True) def tearDown(self): self.driver.quit()
class Login_test(unittest.TestCase): """登录""" def setUp(self): self.driver=webdriver.Chrome() self.driver_n=LoginPage(self.driver) self.driver_n.open() def test_login(self): self.driver_n.input_username("admin") self.driver_n.input_password("super_0711") self.driver_n.click_login() title=self.driver_n.get_title() self.assertEqual(title,u"后台管理") def tearDown(self): self.driver.quit()
class Fb_qy(unittest.TestCase): """车辆分布,区域""" def setUp(self): self.driver = webdriver.Chrome() self.driver_g = GongzuotaiPage(self.driver) self.driver_l = LoginPage(self.driver) self.driver_l.open() self.driver_l.input_username() self.driver_l.input_password() self.driver_l.click_login() title = self.driver_l.get_title() self.assertEqual(title, u"后台管理") """进入工作台""" self.driver_g.click_gongzuotai() def test_fenbu(self): """验证车辆分布是否显示""" cheliangfenbu_loc = ("xpath", ".//*[@id='container']/div[2]/div[1]" ) #车辆分布 result = self.driver_g.is_text_in_element(cheliangfenbu_loc, u"车辆分布") self.assertEqual(result, True) # def test_quyu(self): #暂未查出原因,无法用xpath方法定位到元素,无法判断元素 # """验证区域是否能点击""" # time.sleep(2) # self.driver_g.click_quyu() # xuanzequyu_loc=("xpath","html/body/div[5]/div[1]") # # time.sleep(2) # result=self.driver_g.is_visibility(xuanzequyu_loc) # print result #result=self.driver_g.is_text_in_element(xuanzequyu_loc,u"选择区域") #self.assertEqual(result,True) def tearDown(self): self.driver.quit()
class hmdbj(unittest.TestCase): """黑名单车辆报警""" def setUp(self): self.driver = webdriver.Chrome() self.driver_l = LoginPage(self.driver) self.driver_g = GongzuotaiPage(self.driver) self.driver_g.open(login_url) """登录""" self.driver_l.input_username("admin") self.driver_l.input_password("super_0711") self.driver_l.click_login() title = self.driver_l.get_title() self.assertEqual(title, u"后台管理") """进入工作台""" self.driver_g.click_gongzuotai() def test_hmdbj(self): self.driver_g.click_baojing_heimingdan() jilu_loc = ("class name", "el-dialog__title") #异常车辆报警记录 result = self.driver_g.is_text_in_element(jilu_loc, u'异常车辆报警记录') self.assertEqual(result, True) def tearDown(self): self.driver.quit()
class Chaxuntiaojian(unittest.TestCase): """备案登记-查询条件""" def setUp(self): self.driver=webdriver.Chrome() self.driver_c=ClbadjPage(self.driver) self.driver_l=LoginPage(self.driver) self.driver_l.open() self.driver_l.input_username() self.driver_l.input_password() self.driver_l.click_login() title=self.driver_l.get_title() self.assertEqual(title,u"后台管理") """进入车辆管理--车辆备案登记页面"""#默认页面为车辆备案登记页面,不需要进去页面 #self.driver_c.click_cheliangguanli() #self.driver_c.click_cheliangbeiandengji() def test_xinming(self): """查询条件-姓名""" self.driver_c.click_chaxuntiaojian_xuanze() self.driver_c.click_chaxuntiaojian_xuanze_xingming() self.driver_c.input_chaxuntiaojian_neirong(u"肖银才") self.driver_c.click_chaxun() text=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr/td[2]/div") result=self.driver_c.is_text_in_element(text,"肖银才") self.assertEqual(result,True) def test_shoujihao(self): """查询条件-手机号""" self.driver_c.click_chaxuntiaojian_xuanze() time.sleep(2) self.driver_c.click_chaxuntiaojian_xuanze_shoujihao() self.driver_c.input_chaxuntiaojian_neirong("13308630215") self.driver_c.click_chaxun() text=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr/td[3]/div") result=self.driver_c.is_text_in_element(text,"13308630215") self.assertEqual(result,True) def test_shenfenzhenghao(self): """查询条件-身份证号""" self.driver_c.click_chaxuntiaojian_xuanze() time.sleep(2) self.driver_c.click_chaxuntiaojian_xuanze_shenfenzheng() self.driver_c.input_chaxuntiaojian_neirong("420106196908233566") self.driver_c.click_chaxun() text=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr/td[3]/div") result=self.driver_c.is_text_in_element(text,"13971331771") self.assertEqual(result,True) def test_chepaihao(self): """查询条件-车牌号""" self.driver_c.click_chaxuntiaojian_xuanze() time.sleep(2) self.driver_c.click_chaxuntiaojian_xuanze_chepaihao() self.driver_c.input_chaxuntiaojian_neirong(u"武汉Z25397") self.driver_c.click_chaxun() text=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr/td[5]/div") result=self.driver_c.is_text_in_element(text,"武汉Z25397") self.assertEqual(result,True) def test_chejiahao(self): """查询条件-车架号""" self.driver_c.click_chaxuntiaojian_xuanze() time.sleep(2) self.driver_c.click_chaxuntiaojian_xuanze_chejiahao() self.driver_c.input_chaxuntiaojian_neirong(u"373521512023153") self.driver_c.click_chaxun() text=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr/td[3]/div") result=self.driver_c.is_text_in_element(text,"13027191879") self.assertEqual(result,True) def test_xinpianbianhao(self): """查询条件-芯片编号""" self.driver_c.click_chaxuntiaojian_xuanze() time.sleep(2) self.driver_c.click_chaxuntiaojian_xuanze_fangdaoxinpian() self.driver_c.input_chaxuntiaojian_neirong(u"531175") self.driver_c.click_chaxun() text=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr/td[6]/div") result=self.driver_c.is_text_in_element(text,"531175") self.assertEqual(result,True) def test_shijianfangwei(self): """时间范围""" self.driver_c.input_shijianfanwei("2017-11-01 17:45:00 - 2017-11-02 00:00:00") self.driver_c.click_chaxun() text=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr/td[6]/div") result=self.driver_c.is_text_in_element(text,"531206") self.assertEqual(result,True) def test_zhuangtai_suoyou(self): """状态-所有""" self.driver_c.click_chaxuntiaojian_xuanze() self.driver_c.click_chaxuntiaojian_xuanze_shoujihao() self.driver_c.input_chaxuntiaojian_neirong("15972035798") self.driver_c.click_chaxuntiaojian_zhuangtai() self.driver_c.click_chaxuntiaojian_zhuangtai_suoyou() #time.sleep(2) self.driver_c.click_chaxun() t1=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[6]/div") t2=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr[2]/td[6]/div") text1=self.driver_c.get_text(t1) text2=self.driver_c.get_text(t2) self.assertEqual(text1,'792340') and self.assertEqual(text2,'586219') def test_zhuangtai_zhengchang(self): """状态-正常""" self.driver_c.click_chaxuntiaojian_xuanze() self.driver_c.click_chaxuntiaojian_xuanze_shoujihao() self.driver_c.input_chaxuntiaojian_neirong("15972035798") self.driver_c.click_chaxuntiaojian_zhuangtai() self.driver_c.click_chaxuntiaojian_zhuangtai_zhengchang() #time.sleep(2) self.driver_c.click_chaxun() t1=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[6]/div") t2=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr[2]/td[6]/div") text1=self.driver_c.get_text(t1) self.assertEqual(text1,'792340') and self.driver_c.is_invisibility(t2) def test_zhuangtai_heimingdan(self): """状态-黑名单""" self.driver_c.click_chaxuntiaojian_xuanze() self.driver_c.click_chaxuntiaojian_xuanze_shoujihao() self.driver_c.input_chaxuntiaojian_neirong("15972035798") self.driver_c.click_chaxuntiaojian_zhuangtai() self.driver_c.click_chaxuntiaojian_zhuangtai_heimingdan() #time.sleep(2) self.driver_c.click_chaxun() t1=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[6]/div") t2=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr[2]/td[6]/div") text1=self.driver_c.get_text(t1) self.assertEqual(text1,'586219') and self.driver_c.is_invisibility(t2) def test_tianjiaren(self): """添加人-秀派""" self.driver_c.click_chaxuntiaojian_tianjiaren() self.driver_c.click_chaxuntiaojian_tianjiaren_xiupai() #self.driver_c.click_chaxun() t1=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr[1]/td[6]/div") t2=("xpath",".//*[@id='app']/div[2]/div/div[2]/div/div[2]/div[1]/div[3]/table/tbody/tr[2]/td[6]/div") text1=self.driver_c.get_text(t1) text2=self.driver_c.get_text(t2) self.assertEqual(text1,"124385") and self.assertEqual(text2,"149456") def tearDown(self): self.driver.quit()