shopweb autorun

作者在 2016-08-09 11:20:41 发布以下内容
from selenium import webdriver
import win32api,win32con,time
from selenium.webdriver import ActionChains


class shopWeb(object):
    def exit(self):
        s.implicitly_wait(3)
        s.quit()
    

    def bind(self,salesno,eslid):
        s.get("http://192.168.2.127:8080/shopweb/#/app/goods/goodsInfo")                                            #enter shop manage
 
        lexus = s.find_element_by_xpath(".//*[@id='goods']/div/div[2]/div[3]/div[1]/label/select")                  #100 line
        ActionChains(s).move_to_element(lexus).perform()
        s.find_element_by_xpath("//*[@id='goods']/div/div[2]/div[3]/div[1]/label/select/option[4]").click()
        time.sleep(3)
 
         
        try:
            print s.find_element_by_xpath(".//*[@id='goods']/div/div[2]/table/tbody/tr[100]/td[4]").text()
 
        except Exception,e:
            pass
 
     
        a = salesno[-1]
        b = salesno[-2]
        c = b + a 
         
        s.find_element_by_xpath(".//*[@id='goods']/div/div[2]/table/tbody/tr["+  c +"]/td[1]/label/i").click()             #salesno
        time.sleep(2)
        s.find_element_by_xpath(".//*[@id='goods']/div/div[2]/div[1]/button[4]").click()                            #click bind
        time.sleep(2)
 
        s.find_element_by_xpath("html/body/div[3]/div/div/div/form/div/div[2]/div[2]/div/input").send_keys(eslid)   #enter eslidno
        win32api.keybd_event(9,0,0,0)
        win32api.keybd_event(9,0,win32con.KEYEVENTF_KEYUP,0)
        win32api.keybd_event(9,0,0,0)
        win32api.keybd_event(9,0,win32con.KEYEVENTF_KEYUP,0)
         
        win32api.keybd_event(13,0,0,0)
        win32api.keybd_event(13,0,win32con.KEYEVENTF_KEYUP,0)
        time.sleep(3)
    def login(self,url,username,password):
        global s
        s = webdriver.Firefox()
        s.maximize_window()
        s.get(url)                                                  #enter url  
        s.implicitly_wait(5)      
        try:
            fu = s.find_element_by_xpath(".//*[@id='loginForm']/input").text()
            print fu                                                # robot wait
        except Exception,e:
            pass
        s.find_element_by_id("username").send_keys(username)      #enter account
        s.find_element_by_id("password").send_keys(password)        #enter password
        win32api.keybd_event(13,0,0,0)                              #click login 
        win32api.keybd_event(13,0,win32con.KEYEVENTF_KEYUP,0)    
公司 | 阅读 64744 次
文章评论,共0条
游客请输入验证码
浏览2344035次