码迷,mamicode.com
首页 > 移动开发 > 详细

工作小脚本--通过插件向服务器上传APP

时间:2017-04-28 13:40:01      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:list   nav   lis   切换   通过   inpu   port   _id   file   

from selenium import webdriver
from time import sleep
import os

driver = webdriver.Firefox()
driver.get("xxx")
driver.find_element_by_name(‘account‘).send_keys(‘xxx‘)
driver.find_element_by_name(‘pwd‘).send_keys(‘xxx‘)
sleep(5)
driver.find_element_by_id(‘login-btn‘).click()
sleep(2)


#遍历整个文件夹并把所有文件路径放到FileList里面

FileList=[]
os.chdir(("D:\\app"))
a=os.listdir("D:\\app")
for i in a:
x=os.path.join("D:\\app",i)
FileList.append(x)

for m in FileList :
driver.find_element_by_link_text(‘安全管理‘).click()
sleep(0.3)
# 点击应用管理
driver.find_element_by_xpath(‘/html/body/div/nav/div[2]/div[1]/ul/li[4]/ul/li[1]/a‘).click()
sleep(0.3)

xp = driver.find_element_by_xpath("//div[@id=‘content-main‘]/iframe")
driver.switch_to.frame(xp)
sleep(0.3)
driver.find_element_by_link_text(‘APP审核‘).click()

#切换表单
xp = driver.find_element_by_xpath("//iframe[@id=‘control-frame‘]")

driver.switch_to.frame(xp)
sleep(0.3)
driver.find_element_by_id(‘btn-add‘).click()
sleep(0.3)
driver.find_element_by_id(‘apk-upload‘).send_keys(m)
sleep(1)
#点击上传
driver.find_element_by_xpath(‘/html/body/div[3]/div/div/div[2]/div/div/div/div/form/div[1]/div[1]/div[1]/div[2]/div[2]/a/span‘).click()
sleep(0.3)
#点击选择类别
driver.find_element_by_xpath(‘/html/body/div[3]/div/div/div[2]/div/div/div/div/form/div[2]/div[2]/span/div/button‘).click()
driver.find_element_by_xpath(‘/html/body/div[3]/div/div/div[2]/div/div/div/div/form/div[2]/div[2]/span/div/ul/li[1]/a/label/input‘).click()
sleep(0.3)
driver.find_element_by_id(‘btn-save‘).click()
#刷新
driver.refresh()

工作小脚本--通过插件向服务器上传APP

标签:list   nav   lis   切换   通过   inpu   port   _id   file   

原文地址:http://www.cnblogs.com/suim1218/p/6780781.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!