class RanZhiAddUserCase(unittest.TestCase):
    user_data = CsvHelp().get_csv_data(r'..\data\test_add_user.csv')

    # print(user_data)
    def setUp(self):
        # 实例化chrome浏览器对象,并登录
        self.driver = Base('c')
        RanZhiLogin(self.driver).ran_zhi_login('admin', '123456')

    def tearDown(self):
        # 关闭页面
        self.driver.close()

    @data(user_data)
    @unpack
    def test_add_user(self, user, real_name, sex, dept, role, password1,
                      password2, email):
        print(user)
        RanZhiAddUser(self.driver).add_user(user, real_name, sex, int(dept),
                                            int(role), password1, password2,
                                            email)
        self.driver.sleep(2)
        result = self.driver.get_elements('c,text-center')[-1].text.split(
            ' ')[2]
        self.assertEqual(self.user[0], result, msg='%s添加失败' % self.user[0])
class TTLogin(unittest.TestCase):
    user_data = [('15333606956', '420151175')]
    info = Info()
    cap = {}
    cap['platformName'] = 'Android'
    cap['platformVersion'] = info.get_platform_version()
    cap['deviceName'] = info.get_device_name()
    apk_path = r'apkpath\toutiao359.apk'
    apk_info = info.get_package_and_activity(apk_path)
    info.clear_app(apk_info[0])

    @classmethod
    def setUpClass(self):
        self.info.install_app(self.apk_path)
        pass

    @classmethod
    def tearDownClass(self):
        self.info.uninstall_app(self.apk_info[0])

    def setUp(self):
        self.driver = Base(self.cap)
        self.driver.open_app(*self.apk_info)
        self.driver.sleep(2)

    def tearDown(self):
        self.driver.close()

    @data(*user_data)
    @unpack
    def test_login(self, user, password):
        while True:
            try:
                self.driver.get_element('t,申请独家号').click()
                break
            except:
                self.driver.swipe('l')
                self.driver.sleep(2)
        self.driver.get_element('i,io.manong.developerdaily:id/login_btn').click()
        self.driver.sleep(2)
        self.driver.get_element('t,密码登录').click()
        self.driver.sleep(2)
        self.driver.get_element('i,io.manong.developerdaily:id/edt_phone').send_keys(user)
        self.driver.get_element('i,io.manong.developerdaily:id/edt_password').send_keys(password)
        self.driver.get_element('i,io.manong.developerdaily:id/btn_login').click()
        self.driver.sleep(1)
        result = self.driver.get_element('r,io.manong.developerdaily:id/nav_tv_name').text
        self.assertEqual('u571511', result, msg='登录失败')
 def setUp(self):
     self.driver = Base(self.cap)
     self.driver.open_app(*self.apk_info)
     self.driver.sleep(2)
Esempio n. 4
0
 def tou_tiao_login(self, user, password):
     driver = Base(self.cap)
     driver.open_app(*self.apk_info)
     while True:
         try:
             driver.get_element('t,申请独家号').click()
             break
         except:
             driver.swipe('l')
             driver.sleep(2)
     driver.get_element('i,io.manong.developerdaily:id/login_btn').click()
     driver.sleep(2)
     driver.get_element('t,密码登录').click()
     driver.sleep(2)
     driver.get_element(
         'i,io.manong.developerdaily:id/edt_phone').send_keys(user)
     driver.get_element(
         'i,io.manong.developerdaily:id/edt_password').send_keys(password)
     driver.get_element('i,io.manong.developerdaily:id/btn_login').click()
Esempio n. 5
0
class RanZhiDeleteBlog(BasePage):
    def delete_blog(self):
        driver = self.driver
        driver.sleep(2)
        driver.get_element('x,//*[@id="s-menu-4"]/button').click()
        driver.sleep(1)
        driver.switch_to_frame('i,iframe-4')
        driver.get_element('x,//*[@id="mainNavbar"]/div[2]/ul/li[3]').click()
        driver.sleep(1)
        driver.get_element(
            'x,//*[@id="articles"]/section/div/div[2]/span[4]/a[2]').click()
        driver.alert_accept()

    # def delete_blog_by_title(self,title):
    #     driver = self.driver
    #     driver.sleep(1)
    #     driver.get_element('x,//*[@id="s-menu-4"]/button').click()
    #     driver.sleep(1)
    #     driver.switch_to_frame('i,iframe-4')
    #     driver.get_element('x,//*[@id="mainNavbar"]/div[2]/ul/li[3]').click()
    #     driver.sleep(1)
    #     blogs = driver.get_elements('c,card')
    #     for i in blogs:


if __name__ == '__main__':
    driver = Base('c')
    RanZhiLogin(driver).ran_zhi_login('admin', '123456')
    RanZhiDeleteBlog(driver).delete_blog()
    # RanZhiDeleteBlog(driver).delete_blog_by_title('cs')
Esempio n. 6
0
# #  ranzhi.sys_user
# sql = 'select * from  ranzhi.sys_user'
#
# cursor.execute(sql)
#
# print(cursor.execute(sql))
#
# data = cursor.fetchall()
#
# for i in data:
#     print(i)
#
# db.close()

# driver = webdriver.Chrome()
#
# driver.get('https://www.baidu.com/')
# # driver.open_url('https://www.baidu.com/')
# driver.find_element(By.XPATH, '//*[contains(text(),"特朗普")]').click()
# l = driver.window_handles
# driver.switch_to.window(l[-1])
# driver.find_element(By.XPATH, '//*[@id="channel-all"]/div/ul/li[11]/a').click()

driver = Base('c')

driver.open_url('https://www.mail.163.com/')
driver.sleep(2)
driver.switch_to_frame('x,//*[@id="loginDiv"]/iframe')
driver.get_element('x,//*[@id="account-box"]/div[2]/input').send_keys(
    '15243344')
Esempio n. 7
0
from base.box import Base
from pages.ranzhi_add_user import RanZhiAddUser
from pages.ranzhi_delete_user_by_user_name import RanZhiDeleteUser
from pages.ranzhi_deleteblog import RanZhiDeleteBlog
from pages.ranzhi_login import RanZhiLogin
from pages.ranzhi_send_blog import RanZhiSendBlog

driver = Base('c')
RanZhiLogin(driver).ran_zhi_login('admin', '123456')
driver.implicitly_wait(10)
driver.switch_to_default_content()
driver.get_element('x,//*[@id="s-menu-superadmin"]/button').click()
# RanZhiAddUser(driver).add_user('mike', 'mike', '女', 2, 1, '123456', '123456', '*****@*****.**')
# driver.switch_to_default_content()
# RanZhiSendBlog(driver).send_blog_by_params(1,0,2,3,'添加一个博客','博客','这是我写的第一个博客')
# driver.switch_to_default_content()
# RanZhiDeleteBlog(driver).delete_blog()
# driver.switch_to_default_content()
# RanZhiDeleteUser(driver).delete('mike')
 def setUp(self):
     # 实例化chrome浏览器对象,并登录
     self.driver = Base('c')
     RanZhiLogin(self.driver).ran_zhi_login('admin', '123456')
Esempio n. 9
0
 def setUp(self):
     self.driver = Base('c')
Esempio n. 10
0
class SuiBia(unittest.TestCase):
    csv_data = CsvHelp().get_csv_data(r'data\test44.csv')

    def setUp(self):
        self.driver = Base('c')

    def tearDown(self):
        # self.driver.switch_to_default_content()
        self.driver.close()

    @data(*csv_data)
    @unpack
    def test_001(self, user, password):
        RanZhiLogin(self.driver).ran_zhi_login(user, password)
        self.driver.sleep(2)
        result = self.driver.get_element('x,/html/body/div[2]/div/div/div[1]/div').text
        self.assertIn('登录失败', result, msg='随便都能登录')

    @unittest.skip('stop')
    def test_01(self):
        for i in self.users:
            RanZhiLogin(self.driver).ran_zhi_login(*i)
            self.driver.sleep(2)
            result = self.driver.get_element('x,/html/body/div[2]/div/div/div[1]/div').text
            self.assertIn('登录失败', result, msg='随便都能登录')

    @unittest.skip('stop')
    def test_1(self):
        RanZhiAddUser(self.driver).add_user(*self.user)
        self.driver.sleep(2)
        result = self.driver.get_elements('c,text-center')[-1].text.split(' ')[2]
        self.assertEqual(self.user[0], result, msg='%s添加失败' % self.user[0])

    @unittest.skip('stop')
    def test_2(self):
        RanZhiSendBlog(self.driver).send_blog_by_params(*self.blog)
        self.driver.sleep(2)
        result = self.driver.get_elements('c,card-heading')[0].text
        self.assertEqual(self.blog[4], result, msg='添加博客失败')

    @unittest.skip('stop')
    def test_3(self):
        RanZhiDeleteBlog(self.driver).delete_blog()
        result = []
        self.driver.sleep(2)
        for i in self.driver.get_elements('c,card-heading'):
            print(i.text)
            result.append(i.text)
        self.assertNotIn(self.blog[4], result, msg='%s删除失败' % self.blog[4])

    @unittest.skip('stop')
    def test_4(self):
        RanZhiDeleteUser(self.driver).delete('mike')