Example #1
0
 def test_zprocurement(self):
     u"""一站式采购验证"""
     self.driver.get(self.comme.url)
     self.driver.implicitly_wait(30)
     self.driver.maximize_window()
     time.sleep(3)
     self.driver.find_element_by_class_name('apsClose').click()
     window_1 = self.driver.current_window_handle
     self.driver.find_element_by_xpath('//div[@class="titleMain"]/ul/li[2]/span').click()
     comme = CommonMethod()
     comme.WinMove(window_1,self.driver)
     self.add_img()
     text = self.driver.find_element_by_xpath('//*[@id="big-footer"]/div/div/div[3]/a').text
     self.assertIn(u'云集市',text)
     self.driver.close()
     self.driver.switch_to.window(window_1)
Example #2
0
 def step(self, check):
     """
     :param check: 检查点列表,传入列表或元组
     :return: 一站式购买中产品方法,无返回值
     """
     for i in range(1, len(check) + 1):
         window_2 = self.driver.current_window_handle
         self.driver.find_element_by_xpath(
             '//div[@class="shopping-content"]/div/div[%d]/div/img' %
             i).click()
         WinMov = CommonMethod()
         WinMov.WinMove(window_2, self.driver)
         text1 = self.driver.find_element_by_class_name('BlockName').text
         self.assertIn(check[i - 1], text1)
         self.add_img()
         self.driver.close()
         self.driver.switch_to.window(window_2)
Example #3
0
 def setUp(self):
     self.imgs = []
     self.comme = CommonMethod()
Example #4
0
class TitleSpan(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        options = webdriver.ChromeOptions()
        options.binary_location = "C:\\Users\\amallayev\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"
        chrome_driver_binary = "C:\\Python27\\chromedriver.exe"
        cls.driver = webdriver.Chrome(chrome_driver_binary, chrome_options=options)

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()

    def setUp(self):
        self.imgs = []
        self.comme = CommonMethod()

    def add_img(self):
        #截图添加到测试报告中的方法
        self.imgs.append(self.driver.get_screenshot_as_base64())
        return True

    def setup_get(self):
        self.driver.get(self.comme.url)
        self.driver.maximize_window()
        self.driver.find_element_by_class_name('apsClose').click()


    def step_test(self,firstsort,secondsort,product):
        """
        :param firstsort:第一级位置
        :param secondsort:第二级位置
        :param product:检查产品列表,传入列表或者元组
        :return: 测试步骤,无返回值
        """
        for h in range(1,len(product)+1):
            self.comme.hover('//div[@class="titleMain"]/ul/li[1]/span',self.driver)
            time.sleep(1)
            self.comme.hover('//div[@class="titleMain"]/div[3]/ul/li[1]/ul/li[%d]'%firstsort,self.driver)
            time.sleep(1)
            self.comme.hover('//div[@class="titleMain"]/div[3]/ul/li[2]/ul/li[%d]'%secondsort,self.driver)
            time.sleep(1)
            self.driver.find_element_by_xpath('//div[@class="titleMain"]/div[3]/ul/li[3]/div/div/span[%d]'%h).click()
            time.sleep(3)
            text = self.driver.find_element_by_xpath('//div[@class="product-item-title"]/span').text
            self.assertIn(product[h-1],text)
            #self.comme.roll('//div[@class="DraftEditor-root"]/div/div/div/div[3]/div/h1/span/span',self.driver)
            self.add_img()
            self.driver.back()

    def test_cloudservice(self):
        u'''云服务'''
        self.setup_get()
        time.sleep(1)
        check_list = [u'OSS',u'SLB',u'COS']
        self.step_test(1,1,check_list)

    def test_zprocurement(self):
        u"""一站式采购验证"""
        self.driver.get(self.comme.url)
        self.driver.implicitly_wait(30)
        self.driver.maximize_window()
        time.sleep(3)
        self.driver.find_element_by_class_name('apsClose').click()
        window_1 = self.driver.current_window_handle
        self.driver.find_element_by_xpath('//div[@class="titleMain"]/ul/li[2]/span').click()
        comme = CommonMethod()
        comme.WinMove(window_1,self.driver)
        self.add_img()
        text = self.driver.find_element_by_xpath('//*[@id="big-footer"]/div/div/div[3]/a').text
        self.assertIn(u'云集市',text)
        self.driver.close()
        self.driver.switch_to.window(window_1)

    # def test_zsupport(self):
    #     u"""支持"""
    #     self.driver.get(self.comme.url)
    #     self.driver.implicitly_wait(30)
    #     self.driver.maximize_window()
    #     self.driver.find_element_by_class_name('apsClose').click()
    #     time.sleep(3)
    #     self.driver.find_element_by_xpath('//div[@class="titleMain"]/ul/li[5]/span').click()
    #     self.add_img()
    #     text = self.driver.find_element_by_xpath('//*[@class="supportList"]/h5/a').text
    #     self.assertIn(u'营销',text)
    #
    #     texts = [u'营销',u'推荐',u'付款',u'佣金',u'配置',u'查看',u'链接',u'报告']
    #     #循环点击内容
    #     for i in range(0, 8):
    #         self.driver.find_elements_by_class_name('supportList')[i].click()
    #         time.sleep(2)
    #         text =self.driver.find_element_by_xpath('//*[@class="supportTit"]').text
    #         self.assertIn(texts[i],text)
    #         self.add_img()
    #         self.driver.back()

    def test_zpartner(self):
        u"""成为合作伙伴"""
        self.driver.get(self.comme.url)
        self.driver.implicitly_wait(30)
        self.driver.maximize_window()
        time.sleep(2)
        self.driver.find_element_by_class_name('apsClose').click()
        self.comme.hover('//div[@class="titleMain"]/ul/li[4]/span',self.driver)
        time.sleep(1)
        #-----代理商------#
        self.driver.find_element_by_xpath('//*[@id="root"]/div/div[1]/div[2]/ul/li[1]/ul/li/a').click()#点击成为代理商
        text = self.driver.find_element_by_class_name('contact-form-div-title').text
        self.assertIn(u'代理',text)

        self.driver.find_element_by_id('userName').send_keys('*****@*****.**') #用户名
        self.driver.find_element_by_id("companyName").send_keys(u'测试邮件,请忽略')#公司名称
        #公司规模
        self.driver.find_element_by_xpath('//div[@class="contact-form-content"]/form/div[1]/div[3]/div/div/div[2]/div/span/div/div/span').click()
        self.driver.find_element_by_xpath('/html/body/div[2]/div/div/div/ul/li[1]').click()
        #行业
        self.driver.find_element_by_xpath('//div[@class="contact-form-content"]/form/div[1]/div[4]/div/div/div[2]/div/span/div/div/span').click()
        self.driver.find_element_by_xpath('/html/body/div[3]/div/div/div/ul/li[1]').click()

        self.driver.find_element_by_id('companyTel').send_keys('13737374646')#公司电话
        self.driver.find_element_by_id('contactName').send_keys(u'忽略')#联系人姓名
        #联系人职务
        self.driver.find_element_by_xpath('//div[@class="contact-form-content"]/form/div[1]/div[7]/div/div/div[2]/div/span/div/div/span').click()
        self.driver.find_element_by_xpath('/html/body/div[4]/div/div/div/ul/li[1]').click()

        self.driver.find_element_by_id('contactTel').send_keys("13223234545")#联系人电话
        self.driver.find_element_by_id('partnerNumber').send_keys('123321')#微软合作伙伴编号

        #点击提交
        self.driver.find_element_by_xpath('//div[@class="contact-form-content"]/form/div[2]/div/div/div/div/span/button').click()
        time.sleep(2)
        self.add_img()
        time.sleep(6)
        #-----厂商-----#
        self.comme.hover('//div[@class="titleMain"]/ul/li[4]/span',self.driver)
        time.sleep(1)
        self.driver.find_element_by_xpath('//*[@id="root"]/div/div[1]/div[2]/ul/li[2]/ul/li/a').click()
        self.driver.find_element_by_id('companyName').send_keys(u'测试邮件请忽略') #公司名称
        self.driver.find_element_by_id('userName').send_keys(u'忽略') #联系人姓名
        self.driver.find_element_by_id('userPhone').send_keys('13434344545') #联系人电话
        self.driver.find_element_by_id('userEmail').send_keys('*****@*****.**') #电子邮箱

        #厂商相关问题
        self.driver.find_element_by_id('yearTurnover').send_keys('100')#年营业额
        self.driver.find_element_by_xpath('//*[@id="api"]/label[1]/span[1]/input').click()#是否文档化
        self.driver.find_element_by_id('incomeRatio').send_keys('0.33')#年收入比例
        self.driver.find_element_by_id('decemberBudget').send_keys('100')#营销预算
        self.driver.find_element_by_id('twelveBudget').send_keys('100')#销售预算
        self.driver.find_element_by_id('channelDiscounts').send_keys('0.22')#渠道折扣
        self.driver.find_element_by_id('overlayArea').send_keys('10')#几个区域
        self.driver.find_element_by_id('solutionIntegration').send_keys('100')#方案集成
        self.driver.find_element_by_id('marketShare').send_keys(u'测试测试测试')#市场份额
        self.driver.find_element_by_id('targetMarket').send_keys(u'99人-100人')#目标市场
        self.driver.find_element_by_xpath('//*[@id="varChannelStrategy"]/label[1]/span[1]/input').click()#VAR
        self.driver.find_element_by_xpath('//*[@id="mspChannelStrategy"]/label[1]/span[1]/input').click()#MSP
        self.driver.find_element_by_xpath('//*[@id="providerChannelStrategy"]/label[1]/span[1]/input').click()#通讯
        self.driver.find_element_by_xpath('//*[@id="policySupport"]/label[1]/span[1]/input').click()#政策支撑
        self.driver.find_element_by_xpath('//*[@id="soleDuty"]/label[1]/span[1]/input').click()#销售团队
        self.driver.find_element_by_xpath('//*[@id="edxclusivedistribution"]/label[1]/span[1]/input').click()#转售协议
        #self.driver.find_element_by_xpath('//*[@id="cooperativePartner"]/label[1]/span[1]/input').click()#合作伙伴
        self.driver.find_element_by_id('cooperativePartner').send_keys('10000')
        self.driver.find_element_by_xpath('//*[@id="authorizationCertification"]/label[1]/span[1]/input').click()#销售产品
        self.driver.find_element_by_xpath('//*[@id="monthSubscribe"]/label[1]/span[1]/input').click()#订阅选项

        self.driver.find_element_by_xpath('//div[@class="contact-form-content"]/form/div[6]/div/div/div/div/span/button').click()
        time.sleep(2)
        self.add_img()
Example #5
0
class Company(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        options = webdriver.ChromeOptions()
        options.binary_location = "C:\\Users\\amallayev\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"
        chrome_driver_binary = "C:\\Python27\\chromedriver.exe"
        cls.driver = webdriver.Chrome(chrome_driver_binary,
                                      chrome_options=options)

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()

    def setUp(self):
        self.imgs = []
        self.comme = CommonMethod()
        self.log = Log()

    def add_img(self):
        #截图添加到测试报告中的方法
        self.imgs.append(self.driver.get_screenshot_as_base64())
        return True

    def setup_get(self):
        self.driver.get(self.comme.url)
        self.driver.maximize_window()
        self.driver.find_element_by_class_name('apsClose').click()

    def wall_step(self, page, counts):
        """
        :param page:验证第几页的logo墙
        :param counts:当前页有几个logo
        :return:logo墙测试方法,无返回值
        """
        self.comme.roll(
            '//div[@class="company-prefecture-two-content"]/div[5]',
            self.driver)

        time.sleep(0.8)
        for i in range(1, counts + 1):
            self.comme.hover(
                '//div[@class="company-prefecture-three-div"]/div/div[1]',
                self.driver)
            time.sleep(0.1)

            self.driver.find_element_by_xpath(
                '//div[@class="company-prefecture-three-div-number"]/div[%d]/div'
                % page).click()
            time.sleep(2)
            self.comme.hover(
                '//div[@class="company-prefecture-three-div"]/div/div[%d]' % i,
                self.driver)
            try:
                self.driver.find_element_by_xpath(
                    '//div[@class="company-prefecture-three-div"]/div/div[%d]'
                    % i).click()
            except Exception as e:
                self.log.error(e)
                self.driver.find_element_by_xpath(
                    '//div[@class="company-prefecture-three-div-number"]/div[%d]/div'
                    % page).click()
                time.sleep(1.8)
                self.driver.find_element_by_xpath(
                    '//div[@class="company-prefecture-three-div"]/div/div[%d]'
                    % i).click()
            time.sleep(1)
            self.add_img()
            self.driver.back()

    def test_company_1_ex(self):
        u"""金山云"""
        self.setup_get()
        time.sleep(1)
        self.comme.roll('//div[@class="company-prefecture-title"]',
                        self.driver)
        self.driver.find_element_by_xpath(
            '//div[@class="company-prefecture-content-title-div"]/div[2]/button'
        ).click()
        self.add_img()
        time.sleep(0.5)
        text1 = self.driver.find_element_by_xpath(
            '//div[@class="company-read-info-content-content-title"]/div/div'
        ).text
        self.assertIn(u'金山', text1)
        self.driver.back()

    def test_company_1_com(self):
        u"""金山云服务器,弹性IP,WPS+云办公"""
        self.setup_get()
        checklist = (u'服务器', u'弹性', u'云办公')
        for i in range(1, 4):
            self.comme.roll('//div[@class="company-prefecture-title"]',
                            self.driver)
            self.driver.find_element_by_xpath(
                '//div[@class="company-prefecture-content-title-div-middle"]/div[%d]'
                % i).click()
            time.sleep(0.5)
            self.add_img()
            text2 = self.driver.find_element_by_xpath(
                '//div[@class="product-item-title"]/span').text
            self.assertIn(checklist[i - 1], text2)

            self.driver.back()

    def test_company_2(self):
        u"""微软,今目标,阿里云,腾讯云,华为云,绿盟,并行,云势"""
        self.setup_get()
        checklist = (u'微软', u'今目标', u'阿里云', u'腾讯云', u'华为云', u'绿盟', u'并行',
                     u'云势')
        self.comme.roll('//div[@class="company-prefecture-title"]',
                        self.driver)
        for i in range(1, 9):
            self.driver.find_element_by_xpath(
                '//div[@class="company-prefecture-two-content"]/div[%d]' %
                i).click()
            time.sleep(0.8)
            self.add_img()
            text1 = self.driver.find_element_by_xpath(
                '//div[@class="company-read-info-content-content-title"]/div/div'
            ).text
            self.assertIn(checklist[i - 1], text1)
            self.driver.back()

    def test_logowall(self):
        u'''logo墙'''
        self.setup_get()

        self.wall_step(1, 15)

        self.wall_step(2, 15)

        self.wall_step(3, 7)

    def test_company_contact_us(self):
        u'''公司联系我们'''
        self.setup_get()
        time.sleep(1)
        self.comme.roll('//div[@class="company-prefecture-title"]',
                        self.driver)
        self.driver.find_element_by_xpath(
            '//div[@class="company-prefecture-content-title-div"]/div[2]/button'
        ).click()
        #点击联系我们
        time.sleep(1)
        self.driver.find_element_by_xpath(
            '//div[@class="company-read-info-content"]/div[1]/div[3]/button'
        ).click()
        #填入信息并提交
        self.comme.contact_us(u'厂商联系测试', u'厂商', u'15656567878', u'测试测试',
                              self.driver, u'*****@*****.**')
        time.sleep(1)
Example #6
0
class OtherTest(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        options = webdriver.ChromeOptions()
        options.binary_location = "C:\\Users\\amallayev\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"
        chrome_driver_binary = "C:\\Python27\\chromedriver.exe"
        cls.driver = webdriver.Chrome(chrome_driver_binary,
                                      chrome_options=options)

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()

    def setUp(self):
        self.imgs = []
        self.comme = CommonMethod()
        self.log = Log()

    def add_img(self):
        #截图添加到测试报告中的方法
        self.imgs.append(self.driver.get_screenshot_as_base64())
        return True

    def setup_get(self):
        self.driver.get(self.comme.url)
        self.driver.maximize_window()
        self.driver.find_element_by_class_name('apsClose').click()

    def test_partner_homepage(self):
        u'''两个申请'''
        self.setup_get()
        self.comme.roll(
            '//div[@class="main-div-container-hompage"]/div[8]/div/div/div[1]',
            self.driver)

        #分销商
        #--点击分销商
        self.driver.find_element_by_xpath(
            '//div[@class="main-div-container-hompage"]/div[8]/div/div/div[2]/div[1]/div[3]'
        ).click()
        #--点击申请
        self.driver.find_element_by_xpath(
            '//div[@class="main-div-container-hompage"]/div[8]/div/div/div[2]/div[4]/button'
        ).click()
        #--填写信息
        self.driver.find_element_by_id('userName').send_keys(
            '*****@*****.**')  #用户名
        self.driver.find_element_by_id("companyName").send_keys(
            u'测试邮件,请忽略')  #公司名称
        #公司规模
        self.driver.find_element_by_xpath(
            '//div[@class="contact-form-content"]/form/div[1]/div[3]/div/div/div[2]/div/span/div/div/span'
        ).click()
        time.sleep(2)
        self.driver.find_elements_by_class_name(
            'ant-select-dropdown-menu-item')[0].click()
        #行业
        self.driver.find_element_by_xpath(
            '//div[@class="contact-form-content"]/form/div[1]/div[4]/div/div/div[2]/div/span/div/div/span'
        ).click()
        time.sleep(2)
        try:
            self.driver.find_element_by_xpath(
                '/html/body/div[3]/div/div/div/ul/li[1]').click()
        except Exception as e:
            self.log.error(e)

        self.driver.find_element_by_id('companyTel').send_keys(
            '13737374646')  #公司电话
        self.driver.find_element_by_id('contactName').send_keys(u'忽略')  #联系人姓名
        #联系人职务
        self.driver.find_element_by_xpath(
            '//div[@class="contact-form-content"]/form/div[1]/div[7]/div/div/div[2]/div/span/div/div/span'
        ).click()
        time.sleep(2)
        try:
            self.driver.find_element_by_xpath(
                '/html/body/div[4]/div/div/div/ul/li[1]').click()
        except Exception as e:
            self.log.error(e)

        self.driver.find_element_by_id('contactTel').send_keys(
            "13223234545")  #联系人电话
        #self.driver.find_element_by_id('partnerNumber').send_keys('123321')#微软合作伙伴编号

        #点击提交
        self.driver.find_element_by_xpath(
            '//div[@class="contact-form-content"]/form/div[2]/div/div/div/div/span/button'
        ).click()
        time.sleep(2)
        self.add_img()
        time.sleep(6)

        #厂商
        self.comme.roll(
            '//div[@class="main-div-container-hompage"]/div[8]/div/div/div[1]',
            self.driver)

        self.driver.find_element_by_xpath(
            '//div[@class="main-div-container-hompage"]/div[8]/div/div/div[2]/div[4]/button'
        ).click()
        self.driver.find_element_by_id('companyName').send_keys(
            u'测试邮件,请忽略')  #公司名称
        self.driver.find_element_by_id('userName').send_keys(u'忽略')  #联系人姓名
        self.driver.find_element_by_id('userPhone').send_keys(
            '13434344545')  #联系人电话
        self.driver.find_element_by_id('userEmail').send_keys(
            '*****@*****.**')  #电子邮箱

        #厂商相关问题
        self.driver.find_element_by_id('yearTurnover').send_keys('100')  #年营业额
        self.driver.find_element_by_xpath(
            '//*[@id="api"]/label[1]/span[1]/input').click()  #是否文档化
        self.driver.find_element_by_id('incomeRatio').send_keys('0.33')  #年收入比例
        self.driver.find_element_by_id('decemberBudget').send_keys(
            '100')  #营销预算
        self.driver.find_element_by_id('twelveBudget').send_keys('100')  #销售预算
        self.driver.find_element_by_id('channelDiscounts').send_keys(
            '0.22')  #渠道折扣
        self.driver.find_element_by_id('overlayArea').send_keys('10')  #几个区域
        self.driver.find_element_by_id('solutionIntegration').send_keys(
            '100')  #方案集成
        self.driver.find_element_by_id('marketShare').send_keys(
            u'测试测试测试')  #市场份额
        self.driver.find_element_by_id('targetMarket').send_keys(
            u'99人-100人')  #目标市场
        self.driver.find_element_by_xpath(
            '//*[@id="varChannelStrategy"]/label[1]/span[1]/input').click(
            )  #VAR
        self.driver.find_element_by_xpath(
            '//*[@id="mspChannelStrategy"]/label[1]/span[1]/input').click(
            )  #MSP
        self.driver.find_element_by_xpath(
            '//*[@id="providerChannelStrategy"]/label[1]/span[1]/input').click(
            )  #通讯
        self.driver.find_element_by_xpath(
            '//*[@id="policySupport"]/label[1]/span[1]/input').click()  #政策支撑
        self.driver.find_element_by_xpath(
            '//*[@id="soleDuty"]/label[1]/span[1]/input').click()  #销售团队
        self.driver.find_element_by_xpath(
            '//*[@id="edxclusivedistribution"]/label[1]/span[1]/input').click(
            )  #转售协议
        #self.driver.find_element_by_xpath('//*[@id="cooperativePartner"]/label[1]/span[1]/input').click()#合作伙伴
        self.driver.find_element_by_id('cooperativePartner').send_keys('10000')
        self.driver.find_element_by_xpath(
            '//*[@id="authorizationCertification"]/label[1]/span[1]/input'
        ).click()  #销售产品
        self.driver.find_element_by_xpath(
            '//*[@id="monthSubscribe"]/label[1]/span[1]/input').click()  #订阅选项

        self.driver.find_element_by_xpath(
            '//div[@class="contact-form-content"]/form/div[6]/div/div/div/div/span/button'
        ).click()
        time.sleep(2)
        self.add_img()

    def test_product_and_server(self):
        u"""产品与服务"""
        self.setup_get()
        self.comme.roll(
            '//div[@class="bottom-info-items-div"]/div[1]/div/div[1]',
            self.driver)
        time.sleep(1)
        checklist = [u'365', u'WPS', u'目标', u'金山', u'绿盟']
        for i in range(1, len(checklist) + 1):
            window_2 = self.driver.current_window_handle
            self.driver.find_element_by_xpath(
                '//div[@class="bottom-info-items-div"]/div[1]/div/div[%d]/a' %
                (i + 1)).click()
            time.sleep(2)
            self.comme.WinMove(window_2, self.driver)
            text1 = self.driver.find_element_by_class_name('BlockName').text
            self.assertIn(checklist[i - 1], text1)
            self.add_img()
            self.driver.close()
            self.driver.switch_to.window(window_2)

    def test_about(self):
        u"""关于我们"""
        self.setup_get()
        self.comme.roll(
            '//div[@class="bottom-info-items-div"]/div[2]/div/div[1]',
            self.driver)
        time.sleep(1)
        checklist = [u'海航', u'协议']
        for i in range(1, len(checklist) + 1):
            self.driver.find_element_by_xpath(
                '//div[@class="bottom-info-items-div"]/div[2]/div/div[%d]/a' %
                (i + 1)).click()
            time.sleep(2)
            if self.comme.isElementExist('//div[@class="usInfo"]/p',
                                         self.driver):
                text = self.driver.find_element_by_xpath(
                    '//div[@class="usInfo"]/p').text
                self.assertIn(checklist[i - 1], text)

            elif self.comme.isElementExist(
                    '//*[@id="userAgreement"]/div[1]/h2', self.driver):
                text = self.driver.find_element_by_xpath(
                    '//*[@id="userAgreement"]/div[1]/h2').text
                self.assertIn(checklist[i - 1], text)

            # elif self.comme.isElementExist('//div[@class="main-div-container"]/div[2]/div/div/div[1]/h5/a',self.driver):
            #     text = self.driver.find_element_by_xpath('//div[@class="main-div-container"]/div[2]/div/div/div[1]/h5/a').text
            #     self.assertIn(checklist[i-1],text)

            self.add_img()
            self.driver.back()

    def test_down_blog(self):
        u"""页脚博客与进入博客中的各个刷选标签"""
        self.setup_get()
        self.comme.roll(
            '//div[@class="bottom-info-items-div"]/div[3]/div/div[1]',
            self.driver)
        time.sleep(1)
        #点击进入博客
        self.driver.find_element_by_xpath(
            '//div[@class="bottom-info-items-div"]/div[3]/div/div[2]/a').click(
            )
        #点击展开标识
        self.driver.find_element_by_xpath(
            '//div[@class="ant-anchor"]/div[2]/a').click()
        #点击标签
        self.driver.find_element_by_xpath(
            '//div[@class="ant-anchor"]/div[2]/div[2]/div[%d]' %
            (random.randint(1, 11))).click()
        time.sleep(2)
        #点击关键词
        self.driver.find_element_by_xpath(
            '//div[@class="main-div-panel-right "]/div[2]/div[2]/div/div[%d]' %
            (random.randint(1, 30))).click()
        time.sleep(2)
        #点击行业
        self.driver.find_element_by_xpath(
            '//div[@class="main-div-panel-right "]/div[3]/div[2]/div/div[%d]' %
            (random.randint(1, 25))).click()
        time.sleep(3)
        self.add_img()
        #点击top博主
        index = random.randint(2, 4)
        text1 = self.driver.find_element_by_xpath(
            '//div[@class="main-div-panel-right "]/div[4]/div[2]/div[%d]/div[1]/div/div[2]/a'
            % index).text
        self.driver.find_element_by_xpath(
            '//div[@class="main-div-panel-right "]/div[4]/div[2]/div[%d]/div[1]/div/div[2]/a'
            % index).click()
        time.sleep(1)
        text2 = self.driver.find_element_by_xpath(
            '//div[@class="personal-info-panel-info"]/div[2]').text
        self.assertIn(text1, text2)
        self.comme.roll('//div[@class="main-div-panel-left "]/div[1]/div/div',
                        self.driver)
        time.sleep(2)
        self.add_img()
        self.log.info(u'验证完成')

    def test_contact_us(self):
        u'''页脚联系我们'''
        self.setup_get()
        self.comme.roll(
            '//div[@class="bottom-info-items-div"]/div[4]/div/div[1]',
            self.driver)
        #点击支持邮箱
        self.driver.find_element_by_xpath(
            '//div[@class="bottom-info-items-div"]/div[4]/div/div[1]').click()
        text = u'测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试'
        self.comme.contact_us(u'测试厂商', u'测试用户', u'13434345656', text,
                              self.driver, 3, u'*****@*****.**')
        time.sleep(2)

    def test_consult(self):
        u'''咨询'''
        self.setup_get()
        self.comme.hover(
            '//div[@class="customer-service-title-content-img"]/img',
            self.driver)
        time.sleep(1)
        window_2 = self.driver.current_window_handle
        #点击在线客服
        self.driver.find_element_by_class_name(
            'customer-service-content-select-content-one').click()
        time.sleep(1)
        self.comme.WinMove(window_2, self.driver)
        #输入信息
        self.driver.find_element_by_id('msg').click()
        self.driver.find_element_by_id('msg').send_keys(u'你好')
        #提交
        self.driver.find_element_by_xpath(
            '//div[@class="online_btn"]/span').click()
        time.sleep(0.5)
        text = self.driver.find_element_by_xpath(
            '//*[@id="chatContent"]/li[1]/li/div[2]').text
        self.assertIn(u'你好', text)
        time.sleep(1)
        url = 'http://www.zxccc.net/am-mcs-web/ws/288/31d096dabe0933f576e04d6124f4b8f7/websocket'
        a = urllib.urlopen(url).getcode()
        self.assertEquals(200, a)
        self.log.info(a)
        self.driver.close()
        self.driver.switch_to.window(window_2)
Example #7
0
class Shopping(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        options = webdriver.ChromeOptions()
        options.binary_location = "C:\\Users\\amallayev\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"
        chrome_driver_binary = "C:\\Python27\\chromedriver.exe"
        cls.driver = webdriver.Chrome(chrome_driver_binary,
                                      chrome_options=options)

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()

    def setUp(self):
        self.imgs = []
        self.comme = CommonMethod()

    def add_img(self):
        #截图添加到测试报告中的方法
        self.imgs.append(self.driver.get_screenshot_as_base64())
        return True

    def step(self, check):
        """
        :param check: 检查点列表,传入列表或元组
        :return: 一站式购买中产品方法,无返回值
        """
        for i in range(1, len(check) + 1):
            window_2 = self.driver.current_window_handle
            self.driver.find_element_by_xpath(
                '//div[@class="shopping-content"]/div/div[%d]/div/img' %
                i).click()
            WinMov = CommonMethod()
            WinMov.WinMove(window_2, self.driver)
            text1 = self.driver.find_element_by_class_name('BlockName').text
            self.assertIn(check[i - 1], text1)
            self.add_img()
            self.driver.close()
            self.driver.switch_to.window(window_2)

    def step_last(self, check):
        """
        :param check: 检查点列表,传入产品名列表或者元组
        :return:一站式购买点击左移后的产品的测试步骤,无返回值
        """
        self.comme.roll('//div[@class="shopping-content"]/div/div[4]/div/img',
                        self.driver)
        time.sleep(1)
        for i in range(1, len(check) + 1):
            window_2 = self.driver.current_window_handle
            self.driver.find_element_by_xpath(
                '//div[@class="main-div-container-hompage"]/div[2]/div/div/div[2]/img'
            ).click()
            time.sleep(2)
            self.driver.find_element_by_xpath(
                '//div[@class="shopping-content"]/div/div[5]/div/img').click()
            self.comme.WinMove(window_2, self.driver)
            text1 = self.driver.find_element_by_class_name('BlockName').text
            self.assertIn(check[i - 1], text1)
            self.add_img()
            self.driver.close()
            self.driver.switch_to.window(window_2)

    def test_shopping(self):
        u'''首页中一站式购买'''
        self.driver.get(self.comme.url)
        self.driver.maximize_window()
        self.driver.find_element_by_class_name('apsClose').click()
        checklist = [u'365', u'WPS', u'金山', u'今目标']
        self.step(checklist)

        checklist_last = [u'绿盟']
        self.step_last(checklist_last)
Example #8
0
class Product(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        options = webdriver.ChromeOptions()
        options.binary_location = "C:\\Users\\amallayev\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"
        chrome_driver_binary = "C:\\Python27\\chromedriver.exe"
        cls.driver = webdriver.Chrome(chrome_driver_binary,
                                      chrome_options=options)

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()

    def setUp(self):
        self.imgs = []
        self.comme = CommonMethod()
        self.log = Log()

    def add_img(self):
        #截图添加到测试报告中的方法
        self.imgs.append(self.driver.get_screenshot_as_base64())
        return True

    def step(self, ele1, ele2, check_list):
        """
        :param ele1: 元素在第几行
        :param ele2: 元素是该行的第几个
        :param check_list: 传入检查点,列表或者元组,ps:最好别传元组,因为要是检查项就一个少写一个逗号就出错了。。。被坑了两次了!
        :return: 云产品区操作方法,无返回值
        """
        self.driver.find_element_by_xpath(
            '//div[@class="main-div-container-hompage"]/div[4]/div/div/div[%d]/div[1]/div[%d]/div'
            % (ele1 + 1, ele2)).click()
        time.sleep(2)
        for i in range(1, len(check_list) + 1):
            self.driver.find_element_by_xpath(
                '//div[@class="main-div-container-hompage"]/div[4]/div/div/div[%d]/div[3]/div/div/div[%d]'
                % (ele1 + 1, i)).click()
            time.sleep(1)
            self.add_img()
            if self.comme.isElementExist(
                    '//div[@class="company-read-info-content-content-title"]/div/div',
                    self.driver):
                text1 = self.driver.find_element_by_xpath(
                    '//div[@class="company-read-info-content-content-title"]/div/div'
                ).text
                self.assertIn(check_list[i - 1], text1)
                self.log.info(u'厂商检查')
            else:
                self.log.info(u'厂商XPATH不存在')

            if self.comme.isElementExist(
                    '//div[@class="product-item-title"]/span', self.driver):
                text2 = self.driver.find_element_by_xpath(
                    '//div[@class="product-item-title"]/span').text
                self.assertIn(check_list[i - 1], text2)
                self.log.info(u'产品检查')
            else:
                self.log.info(u'产品XPATH不存在')

            if self.comme.isElementExist('//div[@class="serviceMain"]/h5',
                                         self.driver):
                text3 = self.driver.find_element_by_xpath(
                    '//div[@class="serviceMain"]/h5').text
                self.assertIn(check_list[i - 1], text3)
                self.log.info(u'服务检查')
            else:
                self.log.info(u'服务XPATH不存在')

            self.driver.back()
            self.driver.find_element_by_xpath(
                '//div[@class="main-div-container-hompage"]/div[4]/div/div/div[%d]/div[1]/div[%d]/div'
                % (ele1 + 1, ele2)).click()
            time.sleep(2)

    def test_Product_1(self):
        u'''不断更新的云产品第一行'''
        self.driver.get(self.comme.url)
        self.driver.maximize_window()
        self.driver.find_element_by_class_name('apsClose').click()
        self.comme.login(self.driver, '150xxxx5530', 'l12345')
        time.sleep(0.5)
        #IaaS
        checks = (u'阿里', u'腾讯', u'华为', u'京东', u'金山', u'华云')
        self.step(1, 1, checks)

        #PaaS
        checks = (u'AWS', u'IM', u'环信')
        self.step(1, 2, checks)

        #数字营销
        checks = (u'军犬', u'博雅', u'编++')
        self.step(1, 3, checks)

        #通用办公
        checks = (u'Office365', u'今目标', u'与真云视', u'科天', u'Proces')
        self.step(1, 4, checks)

        #企业管理
        checks = (u'英盛网', u'法大大', u'用友', u'云势', u'由你飞')
        self.step(1, 5, checks)

        #安全运维
        checks = (u'服网', u'景安', u'监控', u'绿盟', u'亚洲')
        self.step(1, 6, checks)

    def test_Product_2(self):
        u'''不断更新的云产品第二行'''
        self.driver.get(self.comme.url)
        self.driver.maximize_window()
        self.driver.find_element_by_class_name('apsClose').click()

        #新技术
        checks = (u'拓尔思', )
        self.step(2, 1, checks)

        #服务

        checks = (u'专业', u'咨询', u'实施', u'备份', u'运维', u'云技')
        self.step(2, 2, checks)

    def test_product_contact_us(self):
        u'''产品联系我们'''
        self.driver.get(self.comme.url)
        self.driver.maximize_window()
        self.driver.find_element_by_class_name('apsClose').click()
        self.driver.find_element_by_xpath(
            '//div[@class="main-div-container-hompage"]/div[4]/div/div/div[2]/div[1]/div[2]'
        ).click()
        self.driver.find_element_by_xpath(
            '//div[@class="main-div-container-hompage"]/div[4]/div/div/div[2]/div[3]/div/div/div[1]'
        ).click()
        #点击联系我们
        time.sleep(1)
        self.driver.find_element_by_xpath(
            '//div[@class="library-product-main"]/div[3]/button').click()
        #填入邮件信息并发送
        self.comme.contact_us(u'产品详情厂商', u'产品', u'13223233434', u'测试测试',
                              self.driver)
        time.sleep(1)
Example #9
0
class ToBuy(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        options = webdriver.ChromeOptions()
        options.binary_location = "C:\\Users\\amallayev\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"
        chrome_driver_binary = "C:\\Python27\\chromedriver.exe"
        cls.driver = webdriver.Chrome(chrome_driver_binary, chrome_options=options)

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()

    def setUp(self):
        self.imgs = []
        self.comme = CommonMethod()

    def add_img(self):
        #截图添加到测试报告中的方法
        self.imgs.append(self.driver.get_screenshot_as_base64())
        return True

    def setup_get(self):
        self.driver.get(self.comme.url)
        self.driver.maximize_window()
        self.driver.find_element_by_class_name('apsClose').click()

    def test_kingsoftwps(self):
        u'''金山WPS与金山服务器'''
        self.setup_get()
        self.comme.roll('//div[@class="company-prefecture-title"]',self.driver)
        time.sleep(1)
        #
        self.driver.find_element_by_xpath('//div[@class="company-prefecture-content-title-div"]/div[2]/button').click()
        #点击查看详情
        time.sleep(1)
        self.driver.find_element_by_xpath('//div[@class="product-list-div"]/div[1]/div[3]/button').click()
        #点击立即购买
        window_1 = self.driver.current_window_handle
        time.sleep(1)
        self.driver.find_element_by_xpath('//div[@class="library-product"]/div/div[3]/button').click()
        self.comme.WinMove(window_1,self.driver)
        text1 = self.driver.find_element_by_class_name('BlockName').text
        self.assertIn(u'WPS',text1)
        self.driver.close()
        self.driver.switch_to.window(window_1)
        time.sleep(1)
        self.driver.back()
        #点击查看详情
        time.sleep(1)
        self.driver.find_element_by_xpath('//div[@class="product-list-div"]/div[2]/div[3]/button').click()
        #点击立即购买
        window_1 = self.driver.current_window_handle
        time.sleep(1)
        self.driver.find_element_by_xpath('//div[@class="library-product"]/div/div[3]/button').click()
        self.comme.WinMove(window_1,self.driver)
        text1 = self.driver.find_element_by_class_name('BlockName').text
        self.assertIn(u'金山',text1)
        self.driver.close()
        self.driver.switch_to.window(window_1)


    def test_office365(self):
        u'''OFFICE365'''
        self.setup_get()
        self.comme.roll('//div[@class="company-prefecture-title"]',self.driver)
        time.sleep(1)
        self.driver.find_element_by_xpath('//div[@class="company-prefecture-two-content"]/div[1]').click()
        #点击查看详情
        time.sleep(1)
        self.driver.find_element_by_xpath('//div[@class="product-list-div"]/div[1]/div[3]/button').click()
        #点击立即购买
        window_1 = self.driver.current_window_handle
        time.sleep(1)
        self.driver.find_element_by_xpath('//div[@class="library-product"]/div/div[3]/button').click()
        self.comme.WinMove(window_1,self.driver)
        text1 = self.driver.find_element_by_class_name('BlockName').text
        self.assertIn(u'365',text1)
        self.driver.close()
        self.driver.switch_to.window(window_1)

    def test_jgoal(self):
        u'''今目标'''
        self.setup_get()
        self.comme.roll('//div[@class="company-prefecture-title"]',self.driver)
        time.sleep(1)
        self.driver.find_element_by_xpath('//div[@class="company-prefecture-two-content"]/div[2]').click()
        #点击查看详情
        time.sleep(1)
        self.driver.find_element_by_xpath('//div[@class="product-list-div"]/div[1]/div[3]/button').click()
        #点击立即购买
        window_1 = self.driver.current_window_handle
        time.sleep(1)
        self.driver.find_element_by_xpath('//div[@class="library-product"]/div/div[3]/button').click()
        self.comme.WinMove(window_1,self.driver)
        text1 = self.driver.find_element_by_class_name('BlockName').text
        self.assertIn(u'今目标',text1)
        self.driver.close()
        self.driver.switch_to.window(window_1)


    def test_NSFOCUS_Cloud(self):
        u'''今目标'''
        self.setup_get()
        self.comme.roll('//div[@class="company-prefecture-title"]',self.driver)
        time.sleep(1)
        self.driver.find_element_by_xpath('//div[@class="company-prefecture-two-content"]/div[6]').click()
        #点击查看详情
        time.sleep(1)
        self.driver.find_element_by_xpath('//div[@class="product-list-div"]/div[1]/div[3]/button').click()
        #点击立即购买
        window_1 = self.driver.current_window_handle
        time.sleep(1)
        self.driver.find_element_by_xpath('//div[@class="library-product"]/div/div[3]/button').click()
        self.comme.WinMove(window_1,self.driver)
        text1 = self.driver.find_element_by_class_name('BlockName').text
        self.assertIn(u'绿盟',text1)
        self.driver.close()
        self.driver.switch_to.window(window_1)