Esempio n. 1
0
def logout(driver):

    #above=driver.find_element_by_class_name("global-set")
    above = driver.find_element_by_link_text(u"设置")
    ActionChains(driver).move_to_element(above).perform()
    time.sleep(time1)
    driver.implicitly_wait(time1)

    driver.find_element_by_link_text(u"退出登录").click()
    time.sleep(time1)
    driver.implicitly_wait(time1)
Esempio n. 2
0
def execute_case(driver,element,operate):
    elementList = element.split('\r\n')
    operateList = operate.split('\r\n')
    now_handle = driver.current_window_handle #获取当前窗口句柄
    global count
    for ope in operateList:
        if ope =='click':
            for ele in elementList:        
                if ele >= u'\u4e00' and ele<=u'\u9fa5':
                            #Partial_link(driver,element)
                            driver.find_element_by_partial_link_text(ele).click()
                            if len(driver.window_handles) > count:
                                count = count + 1
                                ElementOperation.switch_to_window(driver, now_handle)
                            break
                elif ele.startswith('#') or ele.startswith('.'):
                            #Selector(driver,element)
                            driver.find_element_by_css_selector(ele).click()
                            if len(driver.window_handles) > count:
                                count = count + 1
                                ElementOperation.switch_to_window(driver, now_handle)
                            break
                elif '/' in ele or '*' in ele:
                            driver.find_element_by_xpath(ele).click()
                            if len(driver.window_handles) > count:
                                count = count + 1
                                ElementOperation.switch_to_window(driver, now_handle)
                            break
                else:
                            driver.find_element_by_id(ele).click()
                            if len(driver.window_handles) > count:
                                count = count + 1
                                ElementOperation.switch_to_window(driver, now_handle)
                            break
                    
        elif ope == 'send_keys':
            pass   
         
        elif ope == u'移动鼠标':
            for ele in elementList:
                if ele.startswith('#') or ele.startswith('.'):
                    driver.implicitly_wait(time2)
                    img = driver.find_element_by_css_selector(ele)
                    actions = ActionChains(driver)
                    actions.move_to_element(img)
                    actions.perform()
                    print u"鼠标 已移动到轮播图"
                    driver.implicitly_wait(time2)
                    
                    return driver.find_element_by_class_name("global-bn_arr_r").is_displayed()
                    break
Esempio n. 3
0
 def Mouse(self,element,switch):
     driver = self.driver 
     # 0表示移动鼠标 1表示左键点击
     try:
         if switch == 0:
             driver.implicitly_wait(time1)
             menu = driver.find_element_by_css_selector(element)
             actions = ActionChains(driver)
             actions.move_to_element(menu)
             actions.perform()
         elif switch == 1:
             driver.implicitly_wait(time1)
             next = driver.find_element_by_class_name(element)
             ActionChains(driver).click(next).perform()
     except NoSuchElementException,e:
         c = send()
         c.people(str(e))