def ym_check_link(url, islogined): from seleniumDEMO import webdriver import time, urllib2, sys import codecs sys.path.append("/root/home/projects/emao/public") import login, logout, ff_configure, check_link, wait_time if islogined == True: check_link.check_link(url,'/root/home/projects/emao/test_report/emao_log_ok.txt',\ '/root/home/projects/emao/test_report/emao_log_error.txt') print u'验证完毕!' else: #ff_driver=ff_configure.ff_configure() ff_driver = webdriver.PhantomJS() ff_driver.get(url) wait_time.wait_time(ff_driver, 1, 60) ff_driver.maximize_window() wait_time.wait_time(ff_driver, 1, 60) check_link.check_link(url,'/root/home/projects/emao/test_report/emao_log_ok.txt',\ '/root/home/projects/emao/test_report/emao_log_error.txt') print u'验证完毕!' ff_driver.close()
def ym_check_link(url,islogined): from seleniumDEMO import webdriver import time,urllib2,sys import codecs sys.path.append("/root/home/projects/emao/public") import login,logout,ff_configure,check_link,wait_time if islogined==True: check_link.check_link(url,'/root/home/projects/emao/test_report/emao_log_ok.txt',\ '/root/home/projects/emao/test_report/emao_log_error.txt') print u'验证完毕!' else: #ff_driver=ff_configure.ff_configure() ff_driver = webdriver.PhantomJS() ff_driver.get(url) wait_time.wait_time(ff_driver,1,60) ff_driver.maximize_window() wait_time.wait_time(ff_driver,1,60) check_link.check_link(url,'/root/home/projects/emao/test_report/emao_log_ok.txt',\ '/root/home/projects/emao/test_report/emao_log_error.txt') print u'验证完毕!' ff_driver.close()
def test_club_mycenter_leftmenu_link(self): u'''验证【个人中心左侧导航】链接''' print u'开始验证【个人中心左侧导航】链接:' login = Login(self.driver) login.login() login.getName() wait_time.wait_time(self.driver,1,60) self.driver.find_element_by_partial_link_text(u'欢迎您').click() wait_time.wait_time(self.driver,1,60) mycenter_leftmenu_links=self.driver.find_elements_by_css_selector('.car-ucenter-sidebar ul li a') for leftmenu_link in mycenter_leftmenu_links: print leftmenu_link.get_attribute('text') check_single_link.check_single_link(leftmenu_link.get_attribute('href')) print u'验证【个人中心左侧导航】链接结束!'
def check_link_login(ff_driver,success_file,error_file): links = ff_driver.find_elements_by_tag_name("a") wait_time.wait_time(ff_driver,1,60) count_url=0 str2='http' str3='javascript' str4='#' #log_ok = codecs.open('E:/Python_emao_demo/test_report/emao_log_ok.txt','a','utf-8') #log_error=codecs.open('E:/Python_emao_demo/test_report/emao_log_error.txt','a','utf-8') log_ok = codecs.open(success_file,'a','utf-8') log_error=codecs.open(error_file,'a','utf-8') log_ok.truncate()#清空 log_error.truncate()#清空 for link in links: str1=link.get_attribute("href") #print str1 if (str3 not in str1) and (str4 not in str1) and str1 !='': count_url+=1 try: s=urllib2.urlopen(str1) print str1,s.getcode(),str(count_url) #print '**********************************************************' #print 'url:%s\nstatus:%s\ncount_url:%s\n'%(str1,s.getcode(),str(count_url)) log_ok.write('**********************************************************\r\n') log_ok.write('url:%s\r\nstatus:%s\r\ncount_url:%s\r\n'%(str1,s.getcode(),str(count_url))) except urllib2.HTTPError,e: #print e.code #print e.read() #print e.geturl() print str1,e.getcode(),str(count_url) #print 'url:%s\nstatus:%s\ncount_url:%s\n'%(str1,e.getcode(),str(count_url)) log_error.write('**********************************************************\r\n') log_error.write('url:%s\r\nstatus:%s\r\ncount_url:%s\r\n'%(str1,e.getcode(),str(count_url))) except urllib2.URLError,e: print str(e) print e.reason
def setUp(self): self.url= 'http://club.emao.com' #self.firefoxBin = os.path.abspath(r"D:\Program Files\Mozilla Firefoxfirefox.exe") #os.environ["webdriver.firefox.bin"] = self.firefoxBin #self.driver = webdriver.Remote("http://localhost:4444/wd/hub",desired_capabilities=DesiredCapabilities.HTMLUNIT) #self.profileDir = "D:\Program Files\Mozilla Firefox\MozillaProfile" #self.profile = webdriver.FirefoxProfile(self.profileDir) #self.driver = webdriver.Firefox(self.profile) self.driver = webdriver.PhantomJS() wait_time.wait_time(self.driver,1,60) self.driver.maximize_window() self.driver.get(self.url) self.driver.maximize_window() self.verificationErrors = [] #是否继续接受下一个警告 self.accept_next_alert = True
def test_club_mycenter_leftmenu_link(self): u'''验证【个人中心左侧导航】链接''' print u'开始验证【个人中心左侧导航】链接:' login = Login(self.driver) login.login() login.getName() wait_time.wait_time(self.driver, 1, 60) self.driver.find_element_by_partial_link_text(u'欢迎您').click() wait_time.wait_time(self.driver, 1, 60) mycenter_leftmenu_links = self.driver.find_elements_by_css_selector( '.car-ucenter-sidebar ul li a') for leftmenu_link in mycenter_leftmenu_links: print leftmenu_link.get_attribute('text') check_single_link.check_single_link( leftmenu_link.get_attribute('href')) print u'验证【个人中心左侧导航】链接结束!'
def setUp(self): self.url = 'http://club.emao.com' #self.firefoxBin = os.path.abspath(r"D:\Program Files\Mozilla Firefoxfirefox.exe") #os.environ["webdriver.firefox.bin"] = self.firefoxBin #self.driver = webdriver.Remote("http://localhost:4444/wd/hub",desired_capabilities=DesiredCapabilities.HTMLUNIT) #self.profileDir = "D:\Program Files\Mozilla Firefox\MozillaProfile" #self.profile = webdriver.FirefoxProfile(self.profileDir) #self.driver = webdriver.Firefox(self.profile) self.driver = webdriver.PhantomJS() wait_time.wait_time(self.driver, 1, 60) self.driver.maximize_window() self.driver.get(self.url) self.driver.maximize_window() self.verificationErrors = [] #是否继续接受下一个警告 self.accept_next_alert = True
def test_club_mycenter_index_link(self): u'''验证【个人中心首页】链接''' print u'开始验证【用户登录】:' login = Login(self.driver) login.login() login.getName() print u'验证【用户登录】结束!' print '*****************************************************************************' print u'开始验证【个人中心首页-最佳阅读】链接:' wait_time.wait_time(self.driver,1,60) self.driver.find_element_by_partial_link_text(u'欢迎您').click() wait_time.wait_time(self.driver,1,60) first_image=self.driver.find_element_by_css_selector('.car-ucenter-ct-reading-pic li:first-child a') first_image_url=first_image.get_attribute('href') check_single_link.check_single_link(first_image_url) print u'【个人中心首页-最佳阅读】链接验证结束!' print '*****************************************************************************' print u'开始验证【个人中心首页-平行进口车】链接:' handaishu_image=self.driver.find_elements_by_css_selector('.car-ucenter-ct-import-box a') handaishu_image_url=first_image.get_attribute('href') check_single_link.check_single_link(handaishu_image_url) print u'【个人中心首页-平行进口车】链接验证结束!'
def test_club_cheji_index_link(self): u'''验证【社区首页】链接''' print u'开始验证【社区首页】链接:' club_url = 'http://club.emao.com' check_single_link.check_single_link(club_url) print u'验证【社区首页】链接结束!' print '*********************************************************' print u'开始验证轮播图链接:' lunbo_images = self.driver.find_elements_by_css_selector( '.pic-group img') current_handle = self.driver.current_window_handle for image in lunbo_images: if image.is_displayed(): image.click() wait_time.wait_time(self.driver, 1, 60) all_handles = self.driver.window_handles for handle in all_handles: if handle != current_handle: self.driver.switch_to_window(handle) lunbo_image_url = self.driver.current_url check_single_link.check_single_link(lunbo_image_url) wait_time.wait_time(self.driver, 1, 60) self.driver.close() self.driver.switch_to_window(current_handle) break break print u'验证轮播图链接结束!' print '*********************************************************' print u'开始验证【攻略首页】链接:' gonglue_url = 'http://club.emao.com/mygl/' check_single_link.check_single_link(gonglue_url) print u'验证【攻略首页】链接结束!' print '*********************************************************' u'''验证【小组首页】链接''' print u'开始验证【小组首页】链接:' group_url = 'http://club.emao.com/group.php' check_single_link.check_single_link(group_url) print u'验证【小组首页】链接结束!'
def test_club_cheji_index_link(self): u'''验证【社区首页】链接''' print u'开始验证【社区首页】链接:' club_url='http://club.emao.com' check_single_link.check_single_link(club_url) print u'验证【社区首页】链接结束!' print '*********************************************************' print u'开始验证轮播图链接:' lunbo_images=self.driver.find_elements_by_css_selector('.pic-group img') current_handle = self.driver.current_window_handle for image in lunbo_images: if image.is_displayed(): image.click() wait_time.wait_time(self.driver,1,60) all_handles=self.driver.window_handles for handle in all_handles: if handle != current_handle: self.driver.switch_to_window(handle) lunbo_image_url= self.driver.current_url check_single_link.check_single_link(lunbo_image_url) wait_time.wait_time(self.driver,1,60) self.driver.close() self.driver.switch_to_window(current_handle) break break print u'验证轮播图链接结束!' print '*********************************************************' print u'开始验证【攻略首页】链接:' gonglue_url='http://club.emao.com/mygl/' check_single_link.check_single_link(gonglue_url) print u'验证【攻略首页】链接结束!' print '*********************************************************' u'''验证【小组首页】链接''' print u'开始验证【小组首页】链接:' group_url='http://club.emao.com/group.php' check_single_link.check_single_link(group_url) print u'验证【小组首页】链接结束!'
def test_club_mycenter_index_link(self): u'''验证【个人中心首页】链接''' print u'开始验证【用户登录】:' login = Login(self.driver) login.login() login.getName() print u'验证【用户登录】结束!' print '*****************************************************************************' print u'开始验证【个人中心首页-最佳阅读】链接:' wait_time.wait_time(self.driver, 1, 60) self.driver.find_element_by_partial_link_text(u'欢迎您').click() wait_time.wait_time(self.driver, 1, 60) first_image = self.driver.find_element_by_css_selector( '.car-ucenter-ct-reading-pic li:first-child a') first_image_url = first_image.get_attribute('href') check_single_link.check_single_link(first_image_url) print u'【个人中心首页-最佳阅读】链接验证结束!' print '*****************************************************************************' print u'开始验证【个人中心首页-平行进口车】链接:' handaishu_image = self.driver.find_elements_by_css_selector( '.car-ucenter-ct-import-box a') handaishu_image_url = first_image.get_attribute('href') check_single_link.check_single_link(handaishu_image_url) print u'【个人中心首页-平行进口车】链接验证结束!'
def ym_check_link_login(ff_driver,url,islogined): from seleniumDEMO import webdriver import time,urllib2,sys import codecs sys.path.append("E:\\svn\\develop\\AutoTest_Emao\\public") import login,logout,ff_configure,check_link_login,wait_time if islogined==True: check_link_login.check_link_login(ff_driver,'E:/svn/develop/AutoTest_Emao/public/test_report/emao_log_ok.txt',\ 'E:/svn/develop/AutoTest_Emao/public/test_report/emao_log_error.txt') print u'验证完毕!' else: ff_driver=ff_configure.ff_configure() ff_driver.get(url) wait_time.wait_time(ff_driver,1,60) ff_driver.maximize_window() wait_time.wait_time(ff_driver,1,60) check_link_login.check_link_login(ff_driver,'E:/svn/develop/AutoTest_Emao/public/test_report/emao_log_ok.txt',\ 'E:/svn/develop/AutoTest_Emao/public/test_report/emao_log_error.txt') print u'验证结束!'
def ym_check_link_login(ff_driver, url, islogined): from seleniumDEMO import webdriver import time, urllib2, sys import codecs sys.path.append("E:\\svn\\develop\\AutoTest_Emao\\public") import login, logout, ff_configure, check_link_login, wait_time if islogined == True: check_link_login.check_link_login(ff_driver,'E:/svn/develop/AutoTest_Emao/public/test_report/emao_log_ok.txt',\ 'E:/svn/develop/AutoTest_Emao/public/test_report/emao_log_error.txt') print u'验证完毕!' else: ff_driver = ff_configure.ff_configure() ff_driver.get(url) wait_time.wait_time(ff_driver, 1, 60) ff_driver.maximize_window() wait_time.wait_time(ff_driver, 1, 60) check_link_login.check_link_login(ff_driver,'E:/svn/develop/AutoTest_Emao/public/test_report/emao_log_ok.txt',\ 'E:/svn/develop/AutoTest_Emao/public/test_report/emao_log_error.txt') print u'验证结束!'
def login(driver, username, password): driver.find_element_by_link_text(u"登录").click() wait_time.wait_time(driver, 1, 60) driver.find_element_by_id("mobile").clear() driver.find_element_by_id("mobile").send_keys(username) wait_time.wait_time(driver, 1, 60) driver.find_element_by_id("pwd").clear() driver.find_element_by_id("pwd").send_keys(password) wait_time.wait_time(driver, 1, 60) driver.find_element_by_id("loginButton").click() wait_time.wait_time(driver, 1, 60) ele = driver.find_element_by_partial_link_text(u"欢迎您").is_displayed() if ele: print u'用户名:' + username + u'\t登录成功!' else: print u'用户名:' + username + u'\t登录失败!'
def login(driver,username,password): driver.find_element_by_link_text(u"登录").click() wait_time.wait_time(driver,1,60) driver.find_element_by_id("mobile").clear() driver.find_element_by_id("mobile").send_keys(username) wait_time.wait_time(driver,1,60) driver.find_element_by_id("pwd").clear() driver.find_element_by_id("pwd").send_keys(password) wait_time.wait_time(driver,1,60) driver.find_element_by_id("loginButton").click() wait_time.wait_time(driver,1,60) ele=driver.find_element_by_partial_link_text(u"欢迎您").is_displayed() if ele: print u'用户名:'+username+u'\t登录成功!' else: print u'用户名:'+username+u'\t登录失败!'
source = rm.open_resource('GPIB0::7::INSTR') lockin = rm.open_resource('GPIB0::5::INSTR') source.write('SOUR:WAVE:FUNC SIN') source.write(f'SOUR:WAVE:AMPL {amp}') source.write('SOUR:WAVE:PMAR:STAT ON') source.write('SOUR:WAVE:PMAR:OLIN 1') source.write(f'SOUR:WAVE:FREQ {freq_values[0]}') lockin.write('PHAS 0.00') source.write('SOUR:WAVE:ARM') source.write('SOUR:WAVE:INIT') for i in range(length): tau = time_const(freq_values[i]) t = wait_time(tau) source.write(f'SOUR:WAVE:FREQ {freq_values[i]}') lockin.write(f'OFLT {tau}') sleep(t+1) vals = lockin.query_ascii_values('SNAP? 1,2') Vx_values[i] = vals[0] Vy_values[i] = vals[1] source.write('SOUR:WAVE:ABOR') res_x = Vx_values / amp res_y = Vy_values / amp figure(1) plot(log10(freq_values), res_x) plot(log10(freq_values), res_y)