Ejemplo n.º 1
0
 def proinfo(self):  # 进入到“女装sss优质长绒棉A字型条纹连衣裙(七分袖) 412932 优衣库UNIQLO”商品详情页面
     # 滚动到页面中间
     self.driver.execute_script(
         "window.scrollTo(0, document.body.scrollHeight*0.5)")
     time.sleep(1)
     NewPage(self.driver).p_newpage(
         "//div[@class='detail'][1]/div/div/dl[4]/dd[1]/a")
Ejemplo n.º 2
0
    def proinfo1(self, way, text):  # 自定义进入商品详情页面,way代表控件的定位方式, text代表控件的定位信息
        # 滚动到页面中间
        self.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight*0.5)")
        time.sleep(1)
        if way == "xpath":
            # self.driver.find_element_by_xpath("//div[@class='detail'][1]/div/div/dl[1]/dd[1]/a").click()
            NewPage(self.driver).p_newpage(text)
            time.sleep(2)

        elif way == "css":
            NewPage(self.driver).c_newpage(text)
            time.sleep(2)
        elif way == "link":
            NewPage(self.driver).l_newpage(text)
            time.sleep(2)
Ejemplo n.º 3
0
 def testShouye01_11(self):
     '''验证秒杀功能是否有效'''
     # 调用pagenew模块新页面方法
     NewPage(self.driver).c_newpage("div.nav_pub>a:nth-child(2)")
     # 获取跳转后页面信息
     xs_text = self.driver.find_element_by_css_selector(
         'div.bnma>a:nth-child(1)').text
     jj_text = self.driver.find_element_by_css_selector(
         'div.bnma>a:nth-child(2)').text
     # 断言
     self.assertEqual("限时抢购", xs_text)
     self.assertEqual("即将开始", jj_text)
Ejemplo n.º 4
0
    def testShouye01_04(self):
        '''验证未登录情况下验证我的订单按钮是否有效,跳转是否正确'''
        # 调用pagenew模块新页面方法
        NewPage(self.driver).p_newpage("//div[@class='help']/a[2]")
        # 定位控件
        noassent_text = self.driver.find_element_by_css_selector(
            'div.reg_name>span:nth-child(1)')
        zhuce_text = self.driver.find_element_by_css_selector(
            'div.reg_name>a:nth-child(2)')
        uslogin_text = self.driver.find_element_by_xpath(
            "//div[@class='bname']/span")

        # 断言结果
        self.assertEqual("没有帐号", noassent_text.text)
        self.assertEqual("立即注册", zhuce_text.text)
        self.assertEqual("用户登录", uslogin_text.text)
Ejemplo n.º 5
0
    def testShouye01_02(self):
        '''验证登录按钮是否有效,跳转是否正确'''
        # 调用pagenew模块的新页面方法
        NewPage(self.driver).c_newpage("div.login>a:nth-child(1)")
        # 跳转后页面显示内容
        # 定位控件
        noassent_text = self.driver.find_element_by_css_selector(
            'div.reg_name>span:nth-child(1)')
        zhuce_text = self.driver.find_element_by_css_selector(
            'div.reg_name>a:nth-child(2)')
        uslogin_text = self.driver.find_element_by_xpath(
            "//div[@class='bname']/span")

        # 断言结果
        self.assertEqual("没有帐号", noassent_text.text)
        self.assertEqual("立即注册", zhuce_text.text)
        self.assertEqual("用户登录", uslogin_text.text)
Ejemplo n.º 6
0
    def testShouye01_12(self):
        '''验证商品链接能否正常跳转商品详情页'''
        # 搜索 女装
        self.driver.find_element_by_css_selector("input.but1").send_keys("女装")
        self.driver.find_element_by_css_selector("input.but2").click()
        time.sleep(2)
        # 获取第一条搜索结果的title
        aa = self.driver.find_element_by_xpath(
            "//div[@class='goodsbox']/div[1]/div[3]/div/a").text
        # 点击第一条搜索结果,调用新页面方法
        NewPage(self.driver).p_newpage(
            "//div[@class='goodsbox']/div[1]/div[3]/div/a")
        # 定位商品详情页的商品名
        good_name = self.driver.find_element_by_css_selector(
            "div.info>h1:nth-child(1)")

        # 断言
        self.assertEqual(aa, good_name.text)
Ejemplo n.º 7
0
    def testShouye01_03(self):
        '''验证免费注册按钮是否有效,跳转是否正确'''
        # 调用pagenew模块的新页面方法
        NewPage(self.driver).c_newpage("div.login>a:nth-child(3)")
        # 跳转后页面显示内容
        # 定位控件
        havassent_text = self.driver.find_element_by_css_selector(
            "div.reg_name>span:nth-child(1)")
        gologin_text = self.driver.find_element_by_css_selector(
            'div.reg_name>a:nth-child(2)')
        usregis_text = self.driver.find_element_by_css_selector(
            'div.reg_bname>span')
        klogin_text = self.driver.find_element_by_css_selector(
            'div.sub_frm2>h3')

        # 断言
        self.assertEqual(havassent_text.text, "已经有帐号")
        self.assertEqual(gologin_text.text, "立即登录")
        self.assertTrue(klogin_text.is_displayed())
Ejemplo n.º 8
0
    def testShouye01_05(self):
        '''未登录情况下未登录情况下联系客服按钮是否有效,页面跳转是否正确'''
        # 调用pagenew模块新页面方法
        NewPage(self.driver).p_newpage("//div[@class='help']/a[3]")
        # 定位控件
        contactus = self.driver.find_element_by_css_selector('div.nm>span')
        conphone = self.driver.find_element_by_xpath(
            '//div[@class="con"]/p[1]')
        phone = self.driver.find_element_by_xpath('//div[@class="con"]/p[2]')
        emai = self.driver.find_element_by_xpath('//div[@class="con"]/p[3]')
        website = self.driver.find_element_by_xpath('//div[@class="con"]/p[4]')
        adress = self.driver.find_element_by_xpath('//div[@class="con"]/p[5]')

        # 断言
        self.assertEqual("联系我们", contactus.text)
        self.assertEqual("联系我们:我们的电话是:", conphone.text)
        self.assertEqual(phone.text, "15030000000")
        self.assertEqual(emai.text, "邮箱地址是:[email protected]    ")
        self.assertEqual(website.text, "我们的网址是:www.aaa.com    ")
        self.assertEqual(adress.text, "地址:山西太原AA街AA号")