1 Star 1 Fork 1

cow11023/GreaterWMSTest

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
asn_status.py 4.93 KB
一键复制 编辑 原始数据 按行查看 历史
import selenium.webdriver
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import unittest,time
from selenium.webdriver.common.keys import Keys
import GreaterWMSyaml
def chrome_driver():
driver = webdriver.Chrome()
driver.implicitly_wait(10)
driver.maximize_window()
return driver
class GreaterWMSInstellTest(unittest.TestCase):
cfg = GreaterWMSyaml.ReadYaml.read_yaml()
def __init__(self, driver, url=cfg['url']):
self.driver = driver
self.wait = WebDriverWait(driver=self.driver, timeout=5, poll_frequency=1.5)
self.driver.get(url)
def loc_wait(self, loc):
return self.wait.until(EC.presence_of_element_located(loc))
def loc_close(self):
#按ESC取消业已打开的注册页面
self.find_ele((By.XPATH,'/html/body/div[3]/div[2]/div/div[1]/button/span[2]/span/i')).click()
def find_ele(self, loc):
self.loc_wait(loc)
return self.driver.find_element(*(loc))
def find_eles(self, loc):
self.loc_wait(loc)
return self.driver.find_elements(*(loc))
def set_language(self):
self.find_ele((By.XPATH, '//i[text()="translate"]/ancestor::button')).click()
self.find_ele((By.XPATH, '//div[text()="中文简体"]/parent::div')).click()
time.sleep(5)
def login(self, username='1', passwrod='1'):
self.find_ele((By.XPATH, '//span[text()="登入"]/ancestor::button')).click()
#self.find_ele((By.XPATH, '//span[text()="管理员登入"]/ancestor::button')).click()
self.find_ele((By.XPATH,'/html/body/div[3]/div[2]/div/div[1]/div[1]/div/div[2]/div[2]')).click()
self.find_ele((By.XPATH, '//input[@aria-label="管理员"]')).send_keys(username)
self.find_ele((By.XPATH, '//input[@aria-label="密码"]')).send_keys(passwrod)
self.find_ele((By.XPATH, '//div[contains(@class,"justify-start")]//'
'span[text()="登入"]/ancestor::button')).click()
time.sleep(1)
def change_ans_status_confirm_arrival(self,asncode=cfg['asn']['asncode']):
self.find_ele((By.XPATH, '//div[contains(text(),"收货管理")]/parent::a')).click()
time.sleep(5)
#到货确认
self.find_ele((By.XPATH,'//td[text()="{}"]/parent::'
'tr//img[@src="statics/inbound/preloadstock.png"]/ancestor::button'.format(asncode))).click()
time.sleep(10)
self.find_ele((By.XPATH, '//span[text()="确认"]/ancestor::button')).click()
time.sleep(5)
def change_ans_status_confirm_unloading(self,asncode=cfg['asn']['asncode']):
#卸货确认
self.find_ele((By.XPATH,'//td[text()="{}"]/parent::'
'tr//img[@src="statics/inbound/presortstock.png"]/ancestor::button'.format(asncode))).click()
time.sleep(5)
self.find_ele((By.XPATH, '//span[text()="确认"]/ancestor::button')).click()
time.sleep(5)
def change_ans_status_sort_unload(self,asncode=cfg['asn']['asncode']):
#分拣确认,分拣数量默认为0
#self.find_ele((By.XPATH, '//div[contains(text(),"收货管理")]/parent::a')).click()
self.find_ele((By.XPATH,'//td[text()="{}"]/parent::'
'tr//img[@src="statics/inbound/sortstock.png"]/ancestor::button'.format(asncode))).click()
# self.find_ele((By.XPATH, '//input[@aria-label="实际到货数量"]')).send_keys('50')
time.sleep(5)
self.find_ele((By.XPATH, '//span[text()="确认"]/ancestor::button')).click()
time.sleep(5)
def change_ans_staus_sorting_areas(self,asncode=cfg['asn']['asncode'],asnsortingquantify=cfg['asn']['sortingquantify']):
#self.find_ele((By.XPATH, '//div[contains(text(),"收货管理")]/parent::a')).click()
time.sleep(5)
#分拣确认,配置分拣数量
self.find_ele((By.XPATH,'//td[text()="{}"]/parent::'
'tr//img[@src="statics/inbound/sortstock.png"]/ancestor::button'.format(asncode))).click()
self.find_ele((By.XPATH, '//input[@aria-label="实际到货数量"]')).send_keys(asnsortingquantify)
time.sleep(5)
self.find_ele((By.XPATH, '//span[text()="确认"]/ancestor::button'.format(asncode))).click()
time.sleep(5)
class TestInitGreaterWMS(unittest.TestCase):
def setUp(self):
self.driver = chrome_driver()
def test_asnstatus_001(self):
page = GreaterWMSInstellTest(self.driver)
page.loc_close()
page.set_language()
page.loc_close()
page.login()
page.change_ans_status_confirm_arrival()
page.change_ans_status_confirm_unloading()
#page.change_ans_status_sort_unload()
page.change_ans_staus_sorting_areas()
time.sleep(5)
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
unittest.main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/cow111023/greater-wmstest.git
[email protected]:cow111023/greater-wmstest.git
cow111023
greater-wmstest
GreaterWMSTest
master

搜索帮助