connie_tong

导航

 

浏览器缩小75%

driver.execute_script("document.body.style.zoom='75%'")
from selenium import webdriver
import time
import csv

data = csv.reader(open("D:\\python\\jiuweicang\\添加无规格商品\\PRODUCT.csv", 'r'))

driver = webdriver.Chrome()
driver.get('http://172.16.2.80:8999/shop-web/index.html#/login?redirect=%2Findex')
driver.maximize_window()
# 登錄
driver.find_elements_by_xpath('//input[@placeholder="账号"]')[0].send_keys('connie')
driver.find_elements_by_xpath('//input[@placeholder="密码"]')[0].send_keys('Aa123456')
# code = input('請輸入驗證碼:')
# driver.find_elements_by_xpath('//input[@placeholder="验证码"]')[0].send_keys(code)

# 點擊登錄按鈕登錄
b = driver.find_element_by_xpath('//*[@id="app"]/div/form[1]/div[4]/div/button')
b.click()

time.sleep(3)

# 點擊仓库菜單
driver.find_element_by_xpath('//div/*[text()="仓库"]').click()
time.sleep(1)

# 库存
driver.find_element_by_xpath('//span[text()="库存"]').click()
time.sleep(3)

for text in data:
    driver.find_elements_by_xpath('//input[@placeholder="请输入商品名称"]')[0].clear()
    driver.find_elements_by_xpath('//input[@placeholder="请输入商品名称"]')[0].send_keys(text)
    driver.find_elements_by_xpath('//span[text()="搜索"]')[0].click()
    driver.find_element_by_xpath('//input[@placeholder="请选择"]').click()
    time.sleep(3)
    driver.find_element_by_xpath('//li//span[text()="50项/页"]').click()
    time.sleep(3)
    # 获取当前时间
    today = time.strftime("%Y-%M-%d %H%M%S", time.localtime())
    file_name = '截图/'+ today + str(text) + '库存.png'
    # 截图登录成功
    driver.get_screenshot_as_file(file_name)
    time.sleep(1)
    driver.find_element_by_xpath('//span[text()="库存流水"]').click()
    time.sleep(5)
    driver.find_elements_by_xpath('//input[@placeholder="请输入商品名称"]')[0].clear()
    driver.find_elements_by_xpath('//input[@placeholder="请输入商品名称"]')[0].send_keys(text)
    driver.find_elements_by_xpath('//span[text()="搜索"]')[0].click()
    driver.find_element_by_xpath('//input[@placeholder="请选择"]').click()
    time.sleep(3)
    driver.find_element_by_xpath('//li//span[text()="50项/页"]').click()
    time.sleep(3)
    driver.find_element_by_id('hamburger-container').click()
    driver.execute_script("document.body.style.zoom='75%'")
    time.sleep(1)
    # 获取当前时间
    today = time.strftime("%Y-%M-%d %H%M%S", time.localtime())
    file_name = '截图/'+ today + str(text) + '库存流水.png'
    # 截图登录成功
    driver.get_screenshot_as_file(file_name)
    time.sleep(1)
    driver.execute_script("document.body.style.zoom='100%'")
    driver.find_element_by_id('hamburger-container').click()
    time.sleep(1)
    driver.find_element_by_xpath('//span[text()="库存"]').click()
    time.sleep(3)

driver.quit()

 

posted on 2021-11-18 13:01  connie_tong  阅读(305)  评论(0编辑  收藏  举报