首页 > 代码库 > 工作小脚本--通过插件向服务器上传APP

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

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