def test_subject_login(self): driver = self.driver now_handle = driver.current_window_handle #获取当前窗口句柄 ElementOperate = ElementOperation(driver) print(u"开始验证轮播图跳转******************************") ElementOperate.Mouse('next', 1) for i in range(10): time.sleep(0.5) ElementOperate.Mouse('next', 1) ElementOperate.Ergodic('.car-news-wrap img', None) assertList = ['评论', '车型库', '经销商'] ElementOperate.switch_to_window(now_handle, assertList) print(u"结束验证轮播图跳转******************************") print(u"开始验证列表详情********************************") ElementOperate.CSSList('.info-info img', 5) assertList = ['评论', '我要评论'] ElementOperate.switch_to_window(now_handle, assertList) print(u"结束验证列表详情********************************")
def test_subject_login(self): driver = self.driver now_handle = driver.current_window_handle #获取当前窗口句柄 ElementOperate = ElementOperation(driver) print (u"开始验证轮播图跳转******************************") ElementOperate.Mouse( 'next', 1) for i in range(10): time.sleep(0.5) ElementOperate.Mouse( 'next', 1) ElementOperate.Ergodic( '.car-news-wrap img', None) assertList = ['评论','车型库','经销商'] ElementOperate.switch_to_window(now_handle,assertList) print (u"结束验证轮播图跳转******************************") print (u"开始验证列表详情********************************") ElementOperate.CSSList('.info-info img',5) assertList = ['评论','我要评论'] ElementOperate.switch_to_window(now_handle,assertList) print (u"结束验证列表详情********************************")
def login(self): driver = self.driver c = ElementOperation(driver) c.Link('登录') driver.implicitly_wait(time2) c.ID('mobile', 'hp9005') driver.implicitly_wait(time2) c.ID('pwd', '111111') driver.implicitly_wait(time2) c.ID_click('loginButton')
def testhomepage(self): driver = self.driver now_handle = driver.current_window_handle #获取当前窗口句柄 ElementOperate = ElementOperation(driver) print u"开始证浮层及品牌选车****************************" ElementOperate.Mouse('.brand-btn', 0) #鼠标移动浮层 ElementOperate.CSSList('.letter a', 18) #点击浮层首字母 ElementOperate.CSSList('.brand-list a', 23) #点击车系 assertList = ['猫友口碑', '综述', '对比'] ElementOperate.switch_to_window(now_handle, assertList) print u"结束证浮层及品牌选车****************************" print "开始价格选车*************************************" ElementOperate.CSSList('.infos a', 3) assertList = [ '车型', '品牌', '热度', 'http://auto.emao.com/xuanche-8-0-0-0-0-0-0-0_0-0-1.html' ] ElementOperate.switch_to_window(now_handle, assertList) print "结束价格选车*************************************" print "开始类型选车*************************************" ElementOperate.CSSList('.info a', -4) assertList = [ '车型', '品牌', '热度', 'http://auto.emao.com/xuanche-0-0-8-0-0-0-0-0_0-0-1.html' ] ElementOperate.switch_to_window(now_handle, assertList) print "结束类型选车*************************************" print "开始精准选车*************************************" ElementOperate.ID_click("accurateBtn") assertList = ['猫友口碑', '综述', '对比', 'http://auto.emao.com/8/'] ElementOperate.switch_to_window(now_handle, assertList) print "结束精准选车*************************************" print u"开始验证城市*************************************" ElementOperate.Mouse(".city", 0) #鼠标移动浮层 ElementOperate.Selector(".city .arrow-down") ElementOperate.Ergodic(".city-bd a", "江苏") ElementOperate.Ergodic(".city-bd-choose a", '常州') #切换到常州 ElementOperate.ID_click('tj-car-market_url') #进入新车商城 assertList = [ '商城首页', '订单', '特价车源', 'http://mall.emao.com/city/beijing/' ] ElementOperate.switch_to_window(now_handle, assertList) ElementOperate.Selector(".city .arrow-down") ElementOperate.Ergodic(".city-bd a", "北京") ElementOperate.Ergodic(".city-bd-choose a", '北京') #切换到北京 print u"结束验证城市*************************************" print "开始验证新车导购*********************************" ElementOperate.CSSList('.newcar-box a', 5) assertList = ['车型动态', '评论', '相关文章'] ElementOperate.switch_to_window(now_handle, assertList) print "结束验证新车导购*********************************" print "开始验证本地车市*********************************" ElementOperate.CSSList('.box1-left .sale-brand .car-brand img', 1) assertList = ['基本信息', '查询'] ElementOperate.switch_to_window(now_handle, assertList) ElementOperate.CSSList('.showPic .list a', 5) #点击进入本地行情 assertList = ['经销商加盟', '北京推荐经销商', '一猫供稿'] ElementOperate.switch_to_window(now_handle, assertList) ElementOperate.CSSList('.showPic .box1-left .local-markets .address a', 2) #点击进入本地经销商 assertList = ['公司介绍', '经销商地图'] ElementOperate.switch_to_window(now_handle, assertList) print "结束验证本地车市*********************************" print "开始验证加载更多内容*****************************" ElementOperate.Selector('.load-more') ElementOperate.Selector('.load-more') #再次点击加载更多内容 ElementOperate.CSSList('.load-more', 1) assertList = ['http://news.emao.com/xinche/list.html#3'] ElementOperate.switch_to_window(now_handle, assertList) print "结束验证加载更多内容*****************************" print "开始验证购车资讯*********************************" ElementOperate.CSSList('.clearfix .boxs img', 4) assertList = ['车型动态', '收藏', '相关文章'] ElementOperate.switch_to_window(now_handle, assertList) ElementOperate.CSSList('.clearfix .bt a', 1) assertList = ['车型动态', '评论', '相关文章'] ElementOperate.switch_to_window(now_handle, assertList) print "结束验证购车资讯*********************************" print "开始验证底层二维码*******************************" ElementOperate.CSSList('.qr-code img', 0) assertList = ['http://app.emao.com/', '一猫移动应用下载中心'] ElementOperate.switch_to_window(now_handle, assertList) print "结束验证底层二维码*******************************"
def test_citystation_login(self): driver = self.driver now_handle = driver.current_window_handle #获取当前窗口句柄 ElementOperate = ElementOperation(driver) print u"开始点击加载更多验证***********************************" ElementOperate.Selector('#news_tuijian_div a') time.sleep(2) ElementOperate.Selector('#news_tuijian_div a') assertList = [ 'http://dealer.emao.com/beijing/hangqing/list-5-0-0-0_1.html' ] ElementOperate.switch_to_window(now_handle, assertList) print u"结束点击加载更多验证***********************************" print u"开始点击轮播图验证*************************************" #driver.get('http://dealer.emao.com/beijing/') ElementOperate.Mouse('.focus-picture', 0) if not driver.find_element_by_class_name( "global-bn_arr_r").is_displayed(): print "请先把鼠标移动到轮播图" else: print "可以点击下一张" driver.execute_script("window.scrollBy(0,-document.body.scrollHeight)", "") print '***' time.sleep(2) ElementOperate.Mouse('global-bn_arr_r', 1) for i in range(10): time.sleep(0.8) ElementOperate.Mouse('global-bn_arr_r', 1) ElementOperate.Ergodic('.focus-picture a', None) assertList = ['一猫供稿', '北京推荐经销商'] ElementOperate.switch_to_window(now_handle, assertList) print u"结束点击轮播图验证*************************************" print u"开始验证本地车市***************************************" ElementOperate.Partial_link('本地车市') assertList = ['商家查询', '车型详情', '降价提醒', '对比', '报价查询'] ElementOperate.Assert(assertList) print u"结束验证本地车市***************************************" print u"开始验证车型对比***************************************" ElementOperate.CSSList('.checkbox', 0) ElementOperate.CSSList('.checkbox', 2) ElementOperate.CSSList('.checkbox', 5) #ElementOperate.Selector( '.click-db-index') li = driver.find_elements_by_css_selector('.comparison-box li') print len(li) driver.find_element_by_css_selector('.click-db-index').click() assertList = ['排量', '功率', '规格', '车型名称', '厂商指导价'] ElementOperate.switch_to_window(now_handle, assertList) print u"结束验证车型对比***************************************" print u"开始验证经销商*****************************************" ElementOperate.Selector('#dealer_nav a') for i in range(3): ElementOperate.Classname('next') time.sleep(2) ElementOperate.CSSList('#case .case .case-text a', 3) assertList = ['经销商首页', '车型报价', '联系我们', '公司介绍'] ElementOperate.switch_to_window(now_handle, assertList) print u"结束验证经销商*****************************************" print u"开始验证资讯行情***************************************" ElementOperate.Selector('#hangqing_nav a') assertList = [ 'http://dealer.emao.com/beijing/hangqing/list-5-0-0-0_1.html', '一猫推荐', '北京推荐经销商' ] ElementOperate.Assert(assertList) for i in range(3): ElementOperate.Classname('next') time.sleep(2) ElementOperate.CSSList('.list-texts-con a', 3) assertList = ['经销商加盟', '北京推荐经销商'] ElementOperate.switch_to_window( now_handle, assertList, ) print u"结束验证资讯行情****************************************" driver.get('http://www.emao.com') if not driver.find_element_by_class_name('join').is_displayed(): print u'首页城市站链接没有加载'
def testhomepage(self): driver = self.driver now_handle = driver.current_window_handle #获取当前窗口句柄 ElementOperate = ElementOperation(driver) print u"开始证浮层及品牌选车****************************" ElementOperate.Mouse('.brand-btn', 0)#鼠标移动浮层 ElementOperate.CSSList('.letter a',18)#点击浮层首字母 ElementOperate.CSSList('.brand-list a',23)#点击车系 assertList = ['猫友口碑','综述','对比'] ElementOperate.switch_to_window(now_handle,assertList) print u"结束证浮层及品牌选车****************************" print "开始价格选车*************************************" ElementOperate.CSSList('.infos a',3) assertList = ['车型','品牌','热度','http://auto.emao.com/xuanche-8-0-0-0-0-0-0-0_0-0-1.html'] ElementOperate.switch_to_window(now_handle,assertList) print "结束价格选车*************************************" print "开始类型选车*************************************" ElementOperate.CSSList('.info a',-4) assertList = ['车型','品牌','热度','http://auto.emao.com/xuanche-0-0-8-0-0-0-0-0_0-0-1.html'] ElementOperate.switch_to_window(now_handle,assertList) print "结束类型选车*************************************" print "开始精准选车*************************************" ElementOperate.ID_click("accurateBtn") assertList = ['猫友口碑','综述','对比','http://auto.emao.com/8/'] ElementOperate.switch_to_window(now_handle,assertList) print "结束精准选车*************************************" print u"开始验证城市*************************************" ElementOperate.Mouse(".city",0)#鼠标移动浮层 ElementOperate.Selector(".city .arrow-down") ElementOperate.Ergodic( ".city-bd a", "江苏") ElementOperate.Ergodic( ".city-bd-choose a",'常州')#切换到常州 ElementOperate.ID_click( 'tj-car-market_url')#进入新车商城 assertList = ['商城首页','订单','特价车源','http://mall.emao.com/city/beijing/'] ElementOperate.switch_to_window(now_handle,assertList) ElementOperate.Selector(".city .arrow-down") ElementOperate.Ergodic( ".city-bd a", "北京") ElementOperate.Ergodic( ".city-bd-choose a",'北京')#切换到北京 print u"结束验证城市*************************************" print "开始验证新车导购*********************************" ElementOperate.CSSList( '.newcar-box a', 5) assertList = ['车型动态','评论','相关文章'] ElementOperate.switch_to_window(now_handle,assertList) print "结束验证新车导购*********************************" print "开始验证本地车市*********************************" ElementOperate.CSSList('.box1-left .sale-brand .car-brand img', 1) assertList = ['基本信息','查询'] ElementOperate.switch_to_window(now_handle,assertList) ElementOperate.CSSList('.showPic .list a', 5)#点击进入本地行情 assertList = ['经销商加盟','北京推荐经销商','一猫供稿'] ElementOperate.switch_to_window(now_handle,assertList) ElementOperate.CSSList('.showPic .box1-left .local-markets .address a', 2)#点击进入本地经销商 assertList = ['公司介绍','经销商地图'] ElementOperate.switch_to_window(now_handle,assertList) print "结束验证本地车市*********************************" print "开始验证加载更多内容*****************************" ElementOperate.Selector( '.load-more') ElementOperate.Selector('.load-more')#再次点击加载更多内容 ElementOperate.CSSList('.load-more', 1) assertList = ['http://news.emao.com/xinche/list.html#3'] ElementOperate.switch_to_window(now_handle,assertList) print "结束验证加载更多内容*****************************" print "开始验证购车资讯*********************************" ElementOperate.CSSList('.clearfix .boxs img', 4) assertList = ['车型动态','收藏','相关文章'] ElementOperate.switch_to_window(now_handle,assertList) ElementOperate.CSSList('.clearfix .bt a', 1) assertList = ['车型动态','评论','相关文章'] ElementOperate.switch_to_window(now_handle,assertList) print "结束验证购车资讯*********************************" print "开始验证底层二维码*******************************" ElementOperate.CSSList( '.qr-code img', 0) assertList = ['http://app.emao.com/','一猫移动应用下载中心'] ElementOperate.switch_to_window(now_handle,assertList) print "结束验证底层二维码*******************************"
def test_citystation_login(self): driver = self.driver now_handle = driver.current_window_handle #获取当前窗口句柄 ElementOperate = ElementOperation(driver) print u"开始点击加载更多验证***********************************" ElementOperate.Selector('#news_tuijian_div a') time.sleep(2) ElementOperate.Selector('#news_tuijian_div a') assertList = ['http://dealer.emao.com/beijing/hangqing/list-5-0-0-0_1.html'] ElementOperate.switch_to_window(now_handle,assertList) print u"结束点击加载更多验证***********************************" print u"开始点击轮播图验证*************************************" #driver.get('http://dealer.emao.com/beijing/') ElementOperate.Mouse('.focus-picture',0) if not driver.find_element_by_class_name("global-bn_arr_r").is_displayed(): print "请先把鼠标移动到轮播图" else: print "可以点击下一张" driver.execute_script("window.scrollBy(0,-document.body.scrollHeight)","") print '***' time.sleep(2) ElementOperate.Mouse('global-bn_arr_r',1) for i in range(10): time.sleep(0.8) ElementOperate.Mouse('global-bn_arr_r',1) ElementOperate.Ergodic('.focus-picture a',None) assertList = ['一猫供稿','北京推荐经销商'] ElementOperate.switch_to_window(now_handle,assertList) print u"结束点击轮播图验证*************************************" print u"开始验证本地车市***************************************" ElementOperate.Partial_link( '本地车市') assertList = ['商家查询','车型详情','降价提醒','对比','报价查询'] ElementOperate.Assert(assertList) print u"结束验证本地车市***************************************" print u"开始验证车型对比***************************************" ElementOperate.CSSList( '.checkbox', 0) ElementOperate.CSSList( '.checkbox', 2) ElementOperate.CSSList( '.checkbox', 5) #ElementOperate.Selector( '.click-db-index') li = driver.find_elements_by_css_selector('.comparison-box li') print len(li) driver.find_element_by_css_selector('.click-db-index').click() assertList = ['排量','功率','规格','车型名称','厂商指导价'] ElementOperate.switch_to_window(now_handle,assertList) print u"结束验证车型对比***************************************" print u"开始验证经销商*****************************************" ElementOperate.Selector( '#dealer_nav a') for i in range(3): ElementOperate.Classname('next') time.sleep(2) ElementOperate.CSSList('#case .case .case-text a',3) assertList = ['经销商首页','车型报价','联系我们','公司介绍'] ElementOperate.switch_to_window(now_handle, assertList) print u"结束验证经销商*****************************************" print u"开始验证资讯行情***************************************" ElementOperate.Selector( '#hangqing_nav a') assertList = ['http://dealer.emao.com/beijing/hangqing/list-5-0-0-0_1.html','一猫推荐','北京推荐经销商'] ElementOperate.Assert(assertList) for i in range(3): ElementOperate.Classname('next') time.sleep(2) ElementOperate.CSSList('.list-texts-con a',3) assertList = ['经销商加盟','北京推荐经销商'] ElementOperate.switch_to_window(now_handle,assertList,) print u"结束验证资讯行情****************************************" driver.get('http://www.emao.com') if not driver.find_element_by_class_name('join').is_displayed() : print u'首页城市站链接没有加载'
def testnews(self): driver = self.driver now_handle = driver.current_window_handle #获取当前窗口句柄 ElementOperate = ElementOperation(driver) print (u"开始验证轮播图**********************************") ElementOperate.Ergodic('.car-news-wrap .car-news-group img', None) assertList = ['评论'] ElementOperate.switch_to_window(now_handle,assertList) print (u"结束验证轮播图**********************************") print (u"开始验证列表************************************") ElementOperate.CSSList( '.mod-tt .select a', 2) assertList = ['http://news.emao.com/pingce/list.html#3','评测_一猫汽车资讯_一猫汽车网'] ElementOperate.CSSList('.mod-tt .select a', 7) assertList = ['http://news.emao.com/pingce/list.html#3','评测_一猫汽车资讯_一猫汽车网'] print (u"结束验证列表************************************") print (u"开始验证新闻详情************************************") ElementOperate.CSSList('.mod-tt .select a', 2) ElementOperate.CSSList('.mod-item .list-img a',1) assertList = ['一猫汽车网','车型动态'] ElementOperate.switch_to_window(now_handle,assertList) print (u"结束验证新闻详情************************************") print (u"开始验证买家关注************************************") ElementOperate.CSSList('.user-follow a', 1) assertList = ['买家关注','热门品牌','热门专题','热'] ElementOperate.switch_to_window(now_handle,assertList) print (u"结束验证买家关注************************************") print (u"开始验证热门专题************************************") ElementOperate.CSSList('.sidebar-ad img', 1) assertList = ['猫友评论'] ElementOperate.switch_to_window(now_handle,assertList) print (u"结束验证热门专题************************************") print (u"开始验证本地车市************************************") if 'right_bdcs' in driver.page_source: ElementOperate.CSSList('#right_bdcs a',0) assertList = ['快速查找','本地车市','经销商查询','http://dealer.emao.com/beijing/'] ElementOperate.switch_to_window(now_handle,assertList) else: print u"本地车市没有加载" print (u"结束验证本地车市************************************") print (u"开始验证热门品牌************************************") ElementOperate.CSSList( '.news-r a', 9) assertList = ['品牌广场','知豆','http://brand.emao.com/'] ElementOperate.switch_to_window(now_handle,assertList) driver.get('http://brand.emao.com/') ElementOperate.Ergodic( '.origin-box-left a', '福特') assertList = ['福特品牌故事','所有车型','http://brand.emao.com/32/'] ElementOperate.switch_to_window(now_handle,assertList) driver.back() print (u"结束验证热门品牌************************************")