Exemplo n.º 1
0
class ProcessRecord():

    # @data(*ms)
    # @unpack
    mf = loginTo.LoginTo()
    md = mf.driver

    def test_02_pre(self):
        # 定位流程记录管理功能
        time.sleep(2)
        # self.driver.find_element_by_css_selector(".sub-menu:nth-child(3) span:nth-child(2)").click()
        self.md.find_element_by_link_text("流程记录管理").click()
        time.sleep(2)
        self.md.find_element_by_link_text("新增流程类别").click()

    def test_02_addRecord(self, p1, p2):

        time.sleep(2)
        self.md.find_element_by_css_selector(
            ".col-sm-4 > input:nth-child(1)").send_keys(p1)
        self.md.find_element_by_css_selector(
            "div.form-group:nth-child(2) > div:nth-child(2) > input:nth-child(1)"
        ).send_keys(p2)
        time.sleep(2)
        self.md.find_element_by_css_selector(".btn").click()
        time.sleep(0.5)
Exemplo n.º 2
0
class SourceRecord():
    ms = loginTo.LoginTo()
    md = ms.driver

    def test_search(self):
        # 搜索功能
        # time.sleep(1)
        # self.md.find_element_by_link_text("溯源实例管理").click()
        time.sleep(1)
        self.md.find_element_by_link_text("溯源操作记录").click()
        time.sleep(2)
        self.md.find_element_by_css_selector("input.form-control").send_keys(
            "2020")
        time.sleep(2)
        self.md.find_element_by_css_selector(".btn-success").click()
        time.sleep(2)

    def test_del(self):
        #刷新
        self.md.find_element_by_css_selector(".btn-default").click()
        time.sleep(1)
        #删除一条记录
        self.md.find_element_by_css_selector(
            ".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(3) > span:nth-child(1)"
        ).click()
        time.sleep(2)
        self.md.find_element_by_css_selector(".layui-layer-btn0").click()
        time.sleep(2)
        self.md.find_element_by_css_selector(".btn-default").click()
        # tx1 = self.md.find_element_by_css_selector(".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(3)").text
        # self.assertNotEqual(tx,tx1,msg="删除失败")
        #批量删除
        self.md.find_element_by_css_selector(
            ".table > tbody:nth-child(2) > tr:nth-child(25) > td:nth-child(1) > input:nth-child(1)"
        ).click()
        target_elem = self.md.find_element_by_css_selector("#del")
        self.md.execute_script("return arguments[0].scrollIntoView();",
                               target_elem)
        target_elem.click()
        time.sleep(1)
        alert = self.md.switch_to.alert
        alert.accept()
        time.sleep(1)
        xx = self.md.switch_to.alert.text
        ale = self.md.switch_to.alert
        time.sleep(2)
        ale.accept()
        return xx
Exemplo n.º 3
0
class Security_Del():
	ms = loginTo.LoginTo()
	md = ms.driver

	def test_del_Pc(self):
		time.sleep(2)
		self.md.find_element_by_link_text("批量删除防伪码").click()
		time.sleep(1)
		s1 = self.md.find_element_by_id("s1")
		self.md.execute_script("document.getElementById('s1').style.display='block';")
		Select(s1).select_by_visible_text("202011101006575")
		self.md.find_element_by_css_selector("div.row:nth-child(1) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(2) > div:nth-child(1) > button:nth-child(1)").click()
		time.sleep(1)

	def test_del_Product(self):
		time.sleep(2)
		s1 = self.md.find_element_by_id("cp")
		self.md.execute_script("document.getElementById('cp').style.display='block';")
		Select(s1).select_by_visible_text("ASD")
		self.md.find_element_by_css_selector(
			"div.row:nth-child(2) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(2) > div:nth-child(1) > button:nth-child(1)").click()
		time.sleep(1)

	def test_del_Date(self):
		time.sleep(2)
		s1 = self.md.find_element_by_id("s5")
		self.md.execute_script("document.getElementById('s5').style.display='block';")
		Select(s1).select_by_visible_text("2020-10-23")
		self.md.find_element_by_css_selector(
			"div.row:nth-child(3) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(2) > div:nth-child(1) > button:nth-child(1)").click()
		time.sleep(1)

	def test_del_Num(self):
		time.sleep(2)
		self.md.find_element_by_css_selector(".form-control").clear()
		self.md.find_element_by_css_selector(".form-control").send_keys("10000")
		self.md.find_element_by_css_selector(
			"div.row:nth-child(4) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(2) > div:nth-child(1) > button:nth-child(1)").click()
		time.sleep(1)

	def test_del_All(self):
		time.sleep(2)
		ll = self.md.find_element_by_css_selector(
			"div.form-group:nth-child(3) > div:nth-child(1) > button:nth-child(1)")
		self.md.execute_script("return arguments[0].scrollIntoView();", ll)
		self.md.find_element_by_css_selector(
			"div.form-group:nth-child(3) > div:nth-child(1) > button:nth-child(1)").click()
		time.sleep(1)
Exemplo n.º 4
0
class SecurityBatchGen():
    ms = loginTo.LoginTo()
    md = ms.driver

    #溯源实例管理
    def test_01_add(self):
        self.md.find_element_by_link_text("防伪码管理").click()
        time.sleep(1)
        self.md.find_element_by_link_text("批量生成防伪码").click()
        time.sleep(1)
        self.md.find_element_by_css_selector(
            "div.form-group:nth-child(2) > div:nth-child(2) > input:nth-child(1)"
        ).clear()
        self.md.find_element_by_css_selector(
            "div.form-group:nth-child(2) > div:nth-child(2) > input:nth-child(1)"
        ).send_keys("8")
        self.md.find_element_by_css_selector(
            "div.form-group:nth-child(3) > div:nth-child(2) > input:nth-child(1)"
        ).send_keys("WG")
        ct = self.md.find_element_by_id("code_type")
        Select(ct).select_by_visible_text("前缀+数字")
        time.sleep(1)
        tt = self.md.find_element_by_id("txm_type")
        Select(tt).select_by_visible_text("纯数字")
        time.sleep(1)
        self.md.find_element_by_css_selector(
            "div.col-sm-2:nth-child(4) > input:nth-child(1)").send_keys("10")
        self.md.find_element_by_css_selector(
            "div.form-group:nth-child(6) > div:nth-child(2) > input:nth-child(1)"
        ).send_keys("10")
        dd = self.md.find_element_by_id("s1")
        self.md.execute_script(
            "document.getElementById('s1').style.display='block';")
        Select(dd).select_by_visible_text("飞来峰")
        time.sleep(1)
        d1 = self.md.find_element_by_id("s2")
        self.md.execute_script(
            "document.getElementById('s2').style.display='block';")
        Select(d1).select_by_visible_text("66")
        d2 = self.md.find_element_by_id("qiyong")
        Select(d2).select_by_value("no")
        time.sleep(1)
        self.md.find_element_by_id("tj").click()
        time.sleep(2)
Exemplo n.º 5
0
class AddRecord():
	ms = loginTo.LoginTo()
	md = ms.driver

	def test_01_add(self,wlh):
		# self.md.find_element_by_link_text("流程记录管理").click()
		time.sleep(1)
		self.md.find_element_by_link_text("录入流程记录").click()
		time.sleep(2)
		# self.md.execute_script("document.getElementById('s001').removeAttribute('style')")
		self.md.execute_script("document.getElementById('s001').style.display='block';")
		time.sleep(3)
		Select(self.md.find_element_by_id("s001")).select_by_visible_text("装箱/打包")
		time.sleep(2)
		self.md.find_element_by_css_selector("textarea.form-control").send_keys(wlh)
		self.md.find_element_by_css_selector("div.col-sm-6:nth-child(2) > input:nth-child(1)").send_keys("testmessage")
		self.md.find_element_by_css_selector("div.form-group:nth-child(5) > div:nth-child(2) > input:nth-child(1)").clear()
		self.md.find_element_by_css_selector("div.form-group:nth-child(5) > div:nth-child(2) > input:nth-child(1)").send_keys("wcg")
		time.sleep(1)
		self.md.find_element_by_css_selector(".btn").click()
		time.sleep(1)
Exemplo n.º 6
0
class SecurityOne():
    ms = loginTo.LoginTo()
    md = ms.driver

    def test_One(self):
        self.md.find_element_by_link_text("单个生成防伪码").click()
        time.sleep(1)
        self.md.find_element_by_css_selector(
            ".col-sm-3 > input:nth-child(1)").clear()
        self.md.find_element_by_css_selector(
            ".col-sm-3 > input:nth-child(1)").send_keys("11111111111")
        self.md.find_element_by_css_selector(
            "div.form-group:nth-child(2) > div:nth-child(2) > input:nth-child(1)"
        ).clear()
        self.md.find_element_by_css_selector(
            "div.form-group:nth-child(2) > div:nth-child(2) > input:nth-child(1)"
        ).send_keys("QWEQWEQWE")
        self.md.find_element_by_css_selector(
            "div.form-group:nth-child(3) > div:nth-child(2) > input:nth-child(1)"
        ).clear()
        self.md.find_element_by_css_selector(
            "div.form-group:nth-child(3) > div:nth-child(2) > input:nth-child(1)"
        ).send_keys("8888888888")
        time.sleep(1)
        s1 = self.md.find_element_by_id("s1")
        self.md.execute_script(
            "document.getElementById('s1').style.display='block';")
        Select(s1).select_by_visible_text("飞来峰")
        time.sleep(1)
        s2 = self.md.find_element_by_id("s2")
        self.md.execute_script(
            "document.getElementById('s2').style.display='block';")
        Select(s2).select_by_visible_text("katherine")
        time.sleep(1)
        Select(self.md.find_element_by_id("qiyong")).select_by_value("no")
        time.sleep(1)
        self.md.find_element_by_css_selector(".btn").click()
        time.sleep(1)
Exemplo n.º 7
0
class SecurityImp():
	ms = loginTo.LoginTo()
	md = ms.driver

	def test_Imp(self):
		self.md.find_element_by_link_text("批量导入防伪码").click()
		time.sleep(1)
		xx = self.md.find_element_by_css_selector(".form-control")
		Select(xx).select_by_value("gbk")
		time.sleep(1)
		pyautogui.click(x=553, y=612, clicks=1, interval=0.0, button='left', duration=0.0, tween=pyautogui.linear)
		time.sleep(2)

		path = os.path.abspath(r"../data/testdata/code.txt")
		# path1 = unicode(path, 'utf8')
		# print(path1)
		pyautogui.write(path)
		time.sleep(2)
		# pyautogui.click(x=801, y=510, clicks=1, interval=0.0, button='left', duration=0.0, tween=pyautogui.linear)
		pyautogui.press('enter', presses=1)
		time.sleep(2)
		self.md.find_element_by_css_selector(".btn").click()
		time.sleep(2)
Exemplo n.º 8
0
class AddSource():
    ms = loginTo.LoginTo()
    md = ms.driver

    def test_01_pre(self):
        self.md.find_element_by_link_text("溯源实例管理").click()
        time.sleep(1)
        # self.md.find_element_by_link_text("新增溯源实例").click()
        # time.sleep(1)

    #溯源实例管理
    def test_02_add(self, a, b):

        self.md.find_element_by_css_selector(".form-control").send_keys(a)
        f1 = self.md.find_element_by_css_selector(".ke-edit-iframe")
        xx = self.md.switch_to.frame(
            self.md.find_element_by_class_name("ke-edit-iframe"))
        time.sleep(1)
        self.md.find_element_by_xpath("/html/body").send_keys(Keys.TAB)
        self.md.find_element_by_xpath("/html/body").send_keys(b)
        time.sleep(1)
        self.md.switch_to.default_content()
        self.md.find_element_by_css_selector(".btn").click()
        time.sleep(1)
Exemplo n.º 9
0
class MsgManage():
    ms = loginTo.LoginTo()
    md = ms.driver

    def test_02_searchMsg(self):
        # 搜索功能
        # time.sleep(1)
        # self.md.find_element_by_link_text("流程记录管理").click()
        time.sleep(3)
        self.md.find_element_by_css_selector(
            ".sub-menu:nth-child(3) li:nth-child(4) > a").click()
        time.sleep(2)
        self.md.find_element_by_css_selector("input.form-control").send_keys(
            "5")
        time.sleep(2)
        self.md.find_element_by_css_selector(".btn-success").click()
        time.sleep(2)
        # 断言

    def test_03_editMsg(self):
        #编辑记录
        self.md.find_element_by_css_selector(".btn-default").click()
        time.sleep(1)
        self.md.find_element_by_css_selector(
            ".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(9) > a:nth-child(1)"
        ).click()
        time.sleep(2)
        self.md.execute_script(
            "document.getElementById('s001').style.display='block';")
        Select(
            self.md.find_element_by_id("s001")).select_by_visible_text("发货/出库")
        time.sleep(1)
        self.md.find_element_by_css_selector(
            "div.col-sm-4:nth-child(2) > input:nth-child(1)").clear()
        self.md.find_element_by_css_selector(
            "div.col-sm-4:nth-child(2) > input:nth-child(1)").send_keys(
                "61695154")
        time.sleep(1)
        self.md.find_element_by_css_selector(
            "div.form-group:nth-child(6) > div:nth-child(2) > input:nth-child(1)"
        ).clear()
        self.md.find_element_by_css_selector(
            "div.form-group:nth-child(6) > div:nth-child(2) > input:nth-child(1)"
        ).send_keys("666")
        Select(self.md.find_element_by_name("zt")).select_by_value("no")
        time.sleep(1)
        self.md.find_element_by_css_selector(".btn").click()
        time.sleep(0.5)

    def test_04_delMsg(self):
        #刷新
        time.sleep(1)
        # self.md.find_element_by_css_selector(".btn-default").click()
        # time.sleep(1)
        #删除一条记录
        # tx = self.md.find_element_by_css_selector(".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(3)").text
        self.md.find_element_by_css_selector(
            ".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(9) > span:nth-child(2)"
        ).click()
        time.sleep(2)
        self.md.find_element_by_css_selector(".layui-layer-btn0").click()
        time.sleep(2)
        self.md.find_element_by_css_selector(".btn-default").click()

        self.md.find_element_by_css_selector(
            ".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(1) > input:nth-child(1)"
        ).click()
        target_elem = self.md.find_element_by_css_selector("#del")
        self.md.execute_script("return arguments[0].scrollIntoView();",
                               target_elem)
        target_elem.click()
        time.sleep(1)
        alert = self.md.switch_to.alert
        alert.accept()
        time.sleep(0.2)
Exemplo n.º 10
0
class BatchSource():
    ms = loginTo.LoginTo()
    md = ms.driver

    def batch_Logistic(self):
        time.sleep(2)
        self.md.find_element_by_link_text("批量溯源操作").click()
        self.md.find_element_by_id("txm").send_keys("53355")
        self.md.find_element_by_id("txm").send_keys(Keys.ENTER)
        self.md.find_element_by_id("txm").send_keys("45453")
        self.md.execute_script(
            "document.getElementById('s001').style.display='block';")
        Select(self.md.find_element_by_id("s001")).select_by_visible_text(
            "产品质量不合格")
        time.sleep(1)
        self.md.find_element_by_css_selector(
            "div.row:nth-child(1) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(5) > div:nth-child(1) > button:nth-child(1)"
        ).click()
        time.sleep(1)

    def batch_Id(self):
        self.md.find_element_by_css_selector(
            "div.col-sm-2:nth-child(2) > input:nth-child(1)").send_keys("0000")
        time.sleep(1)
        self.md.find_element_by_css_selector(
            "div.col-sm-2:nth-child(3) > input:nth-child(1)").send_keys("9999")
        time.sleep(2)
        self.md.execute_script(
            "document.getElementById('s00').style.display='block';")
        Select(self.md.find_element_by_id("s00")).select_by_visible_text(
            "产品质量不合格")
        time.sleep(1)
        self.md.find_element_by_xpath(
            "/html/body/section/section/section/div[2]/div/section/div/form/div[3]/div/button"
        ).click()
        time.sleep(1)

    def batch_Pc(self):
        tar_element = self.md.find_element_by_css_selector(
            "div.row:nth-child(3) > div:nth-child(1) > section:nth-child(1) > header:nth-child(1) > h3:nth-child(1)"
        )
        self.md.execute_script("return arguments[0].scrollIntoView();",
                               tar_element)
        time.sleep(1)
        self.md.execute_script(
            "document.getElementById('s1').style.display='block';")
        Select(self.md.find_element_by_id("s1")).select_by_visible_text(
            "20201124181008")
        time.sleep(1)
        self.md.execute_script(
            "document.getElementById('s01').style.display='block';")
        Select(self.md.find_element_by_id("s01")).select_by_visible_text("寇旭珂")
        time.sleep(1)
        self.md.find_element_by_css_selector(
            "div.row:nth-child(3) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(5) > div:nth-child(1) > button:nth-child(1)"
        ).click()
        time.sleep(1)

    def batch_name(self):
        tar_element = self.md.find_element_by_css_selector(
            "div.row:nth-child(4) > div:nth-child(1) > section:nth-child(1) > header:nth-child(1) > h3:nth-child(1)"
        )
        self.md.execute_script("return arguments[0].scrollIntoView();",
                               tar_element)
        time.sleep(1)
        self.md.execute_script(
            "document.getElementById('cp').style.display='block';")
        Select(self.md.find_element_by_id("cp")).select_by_visible_text("飞来峰")
        time.sleep(1)
        self.md.execute_script(
            "document.getElementById('s03').style.display='block';")
        Select(self.md.find_element_by_id("s03")).select_by_visible_text("寇旭珂")
        time.sleep(1)
        self.md.find_element_by_css_selector(
            "div.row:nth-child(4) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(5) > div:nth-child(1) > button:nth-child(1)"
        ).click()
        time.sleep(1)

    def batch_date(self):
        tar_element = self.md.find_element_by_css_selector(
            "div.row:nth-child(5) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(5) > div:nth-child(1) > button:nth-child(1)"
        )
        self.md.execute_script("return arguments[0].scrollIntoView();",
                               tar_element)
        time.sleep(1)
        self.md.execute_script(
            "document.getElementById('s5').style.display='block';")
        Select(self.md.find_element_by_id("s5")).select_by_visible_text(
            "2020-10-24")
        time.sleep(1)

        self.md.execute_script(
            "document.getElementById('s04').style.display='block';")
        Select(self.md.find_element_by_id("s04")).select_by_visible_text("寇旭珂")
        self.md.find_element_by_id("s04").send_keys(Keys.END)
        time.sleep(1)
        self.md.find_element_by_css_selector(
            "div.row:nth-child(5) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(5) > div:nth-child(1) > button:nth-child(1)"
        ).click()
        time.sleep(1)
Exemplo n.º 11
0
class MainFun(unittest.TestCase):
    mm = loginTo.LoginTo()
    md = mm.driver

    @classmethod
    def setUpClass(cls):
        time.sleep(5)
        cls.mm.login()
        cls.md.maximize_window()
        time.sleep(2)

    # 新增流程类别
    def test_01(self):
        self.x1 = processRecord.ProcessRecord()
        self.x1.test_02_pre()

    ms = getdata.GetData(r"../data/testdata/data.xlsx",
                         "addrecord").login_data()

    @data(*ms)
    @unpack
    def test_02(self, p1, p2):
        self.x2 = processRecord.ProcessRecord()
        self.x2.test_02_addRecord(p1, p2)
        # a = self.md.find_element_by_css_selector(".layui-layer-content")
        # self.assertTrue(a, "失败")
        #流程类别管理
    def test_03(self):
        #搜索流程
        self.x3 = reordManage.RecordManage()
        self.x3.test_02_searchRecord()
        a = self.md.find_element_by_css_selector(
            ".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(3)"
        ).text
        self.assertIn("取消", a, msg="搜索失败")
        #编辑流程类别记录
        self.x3.test_03_editRecord()
        x = self.md.find_element_by_css_selector(".layui-layer-content")
        self.assertTrue(x, msg="编辑失败")

        #删除流程记录
        a = self.x3.test_04_delRecord()
        b = "批量删除成功"
        self.assertEqual(a, b, msg="失败")

    ms1 = getdata.GetData(r"../data/testdata/data.xlsx", "lcjl").login_data()

    @data(*ms1)
    @unpack
    def test_04(self, lgs):
        #录入流程记录
        wlh = lgs
        self.ad = addRecord.AddRecord()
        self.ad.test_01_add(wlh)
        a = self.md.find_element_by_css_selector(".layui-layer-content")
        self.assertTrue(a, msg="录入流程记录失败")

    def test_05(self):
        #流程记录管理
        self.x5 = msgManage.MsgManage()
        self.x5.test_02_searchMsg()
        a = self.md.find_element_by_css_selector(
            ".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(4) > span:nth-child(1)"
        ).text
        self.assertIn("5", a, msg="搜索失败")
        self.x5.test_03_editMsg()
        b = self.md.find_element_by_css_selector(".layui-layer-content")
        self.assertTrue(b, msg="更新失败")
        self.x5.test_04_delMsg()
        c = self.md.find_element_by_css_selector(".layui-layer-content")
        self.assertTrue(c, msg="删除失败")
Exemplo n.º 12
0
class RecordManage():
    ms = loginTo.LoginTo()
    md = ms.driver

    # def __init__(self):
    # 	lt = loginTo.LoginTo().login()

    def test_02_searchRecord(self):
        #搜索功能
        # time.sleep(1)
        # self.md.find_element_by_link_text("流程记录管理").click()
        time.sleep(3)
        self.md.find_element_by_link_text("流程类别管理").click()
        time.sleep(2)
        self.md.find_element_by_css_selector(".form-control").send_keys("取消")
        time.sleep(2)
        self.md.find_element_by_css_selector(".btn-success").click()
        time.sleep(2)
        #断言
        # a = self.md.find_element_by_css_selector(".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(3)").text
        #
        # self.unittest.assertIn("取消",a,msg="搜索失败")

    def test_03_editRecord(self):
        #编辑记录
        self.md.find_element_by_css_selector(".btn-default").click()
        time.sleep(1)
        self.md.find_element_by_css_selector(
            ".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(7) > a:nth-child(1)"
        ).click()
        time.sleep(2)
        self.md.find_element_by_css_selector(
            ".col-sm-3 > input:nth-child(1)").clear()
        self.md.find_element_by_css_selector(
            ".col-sm-3 > input:nth-child(1)").send_keys("testmessage")
        time.sleep(1)
        self.md.find_element_by_css_selector(
            "div.form-group:nth-child(3) > div:nth-child(2) > input:nth-child(1)"
        ).clear()
        self.md.find_element_by_css_selector(
            "div.form-group:nth-child(3) > div:nth-child(2) > input:nth-child(1)"
        ).send_keys("121")
        Select(self.md.find_element_by_name("zt")).select_by_value("no")
        time.sleep(1)
        self.md.find_element_by_css_selector(".btn").click()
        time.sleep(0.5)

    def test_04_delRecord(self):
        #刷新
        time.sleep(2)
        self.md.find_element_by_css_selector(".btn-default").click()
        time.sleep(1)
        #删除一条记录
        # tx = self.md.find_element_by_css_selector(".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(3)").text
        self.md.find_element_by_css_selector(
            ".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(7) > span:nth-child(2)"
        ).click()
        time.sleep(2)
        self.md.find_element_by_css_selector(".layui-layer-btn0").click()
        time.sleep(1)
        # self.md.find_element_by_css_selector(".btn-default").click()
        # tx1 = self.md.find_element_by_css_selector(".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(3)").text
        # self.assertNotEqual(tx,tx1,msg="删除失败")
        #批量删除
        self.md.find_element_by_css_selector(
            ".table > tbody:nth-child(2) > tr:nth-child(1) > td:nth-child(1) > input:nth-child(1)"
        ).click()
        self.md.find_element_by_css_selector(
            ".table > tbody:nth-child(2) > tr:nth-child(2) > td:nth-child(1) > input:nth-child(1)"
        ).click()
        target_elem = self.md.find_element_by_css_selector("#del")
        self.md.execute_script("return arguments[0].scrollIntoView();",
                               target_elem)
        target_elem.click()
        time.sleep(1)
        alert = self.md.switch_to.alert
        alert.accept()
        time.sleep(1)
        b = self.md.switch_to.alert
        a = b.text
        print(a)
        self.md.switch_to.alert.accept()
        return a
Exemplo n.º 13
0
class Security_Edit():
    ms = loginTo.LoginTo()
    md = ms.driver

    def test_logistic(self):
        time.sleep(2)
        self.md.find_element_by_link_text("批量修改防伪码").click()
        time.sleep(1)
        self.md.find_element_by_id("txm").send_keys("53355")
        s1 = self.md.find_element_by_id("s000")
        self.md.execute_script(
            "document.getElementById('s000').style.display='block';")
        Select(s1).select_by_visible_text("飞来峰")
        s2 = self.md.find_element_by_id("s001")
        self.md.execute_script(
            "document.getElementById('s001').style.display='block';")
        Select(s2).select_by_visible_text("66")
        self.md.find_element_by_css_selector(
            "div.row:nth-child(1) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(4) > div:nth-child(1) > button:nth-child(1)"
        ).click()
        time.sleep(1)

    def test_ID(self):
        time.sleep(2)
        self.md.find_element_by_css_selector(
            "div.col-sm-2:nth-child(2) > input:nth-child(1)").send_keys("0000")
        self.md.find_element_by_css_selector(
            "div.col-sm-2:nth-child(3) > input:nth-child(1)").send_keys("9999")
        s1 = self.md.find_element_by_id("s00")
        self.md.execute_script(
            "document.getElementById('s00').style.display='block';")
        Select(s1).select_by_visible_text("飞来峰")
        s2 = self.md.find_element_by_id("s01")
        self.md.execute_script(
            "document.getElementById('s01').style.display='block';")
        Select(s2).select_by_visible_text("66")
        self.md.find_element_by_css_selector(
            "div.row:nth-child(2) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(4) > div:nth-child(1) > button:nth-child(1)"
        ).click()
        time.sleep(1)

    def test_Pc(self):
        time.sleep(2)
        ll = self.md.find_element_by_css_selector(
            "div.row:nth-child(3) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(4) > div:nth-child(1) > button:nth-child(1)"
        )
        self.md.execute_script("return arguments[0].scrollIntoView();", ll)
        time.sleep(1)
        s1 = self.md.find_element_by_id("s1")
        self.md.execute_script(
            "document.getElementById('s1').style.display='block';")
        Select(s1).select_by_visible_text("202011201752087")
        time.sleep(1)
        s2 = self.md.find_element_by_id("s2")
        self.md.execute_script(
            "document.getElementById('s2').style.display='block';")
        Select(s2).select_by_visible_text("飞来峰")
        time.sleep(1)
        s3 = self.md.find_element_by_id("s3")
        self.md.execute_script(
            "document.getElementById('s3').style.display='block';")
        Select(s3).select_by_visible_text("66")
        self.md.find_element_by_css_selector(
            "div.row:nth-child(3) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(4) > div:nth-child(1) > button:nth-child(1)"
        ).click()
        time.sleep(1)

    def test_product(self):
        time.sleep(2)
        ll = self.md.find_element_by_css_selector(
            "div.row:nth-child(4) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(3) > div:nth-child(1) > button:nth-child(1)"
        )
        self.md.execute_script("return arguments[0].scrollIntoView();", ll)
        time.sleep(1)
        s1 = self.md.find_element_by_id("cp")
        self.md.execute_script(
            "document.getElementById('cp').style.display='block';")
        Select(s1).select_by_visible_text("飞来峰")
        time.sleep(1)
        s2 = self.md.find_element_by_id("s4")
        self.md.execute_script(
            "document.getElementById('s4').style.display='block';")
        Select(s2).select_by_visible_text("66")
        time.sleep(1)
        self.md.find_element_by_css_selector(
            "div.row:nth-child(4) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(3) > div:nth-child(1) > button:nth-child(1)"
        ).click()
        time.sleep(1)

    def test_date(self):
        time.sleep(2)
        ll = self.md.find_element_by_css_selector(
            "div.row:nth-child(5) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(4) > div:nth-child(1) > button:nth-child(1)"
        )
        self.md.execute_script("return arguments[0].scrollIntoView();", ll)
        s1 = self.md.find_element_by_id("s5")
        self.md.execute_script(
            "document.getElementById('s5').style.display='block';")
        Select(s1).select_by_visible_text("2020-11-22")
        time.sleep(1)
        s2 = self.md.find_element_by_id("s6")
        self.md.execute_script(
            "document.getElementById('s6').style.display='block';")
        Select(s2).select_by_visible_text("飞来峰")
        time.sleep(1)
        s3 = self.md.find_element_by_id("s7")
        self.md.execute_script(
            "document.getElementById('s7').style.display='block';")
        Select(s3).select_by_visible_text("66")
        time.sleep(1)
        self.md.find_element_by_css_selector(
            "div.row:nth-child(5) > div:nth-child(1) > section:nth-child(1) > div:nth-child(2) > form:nth-child(1) > div:nth-child(4) > div:nth-child(1) > button:nth-child(1)"
        ).click()
        time.sleep(1)