Пример #1
0
class EditTopicPage(object):
    def __init__(self):
        self.driver = SingleDriver()

    @property
    def breadcrumb_text(self):
        return self.driver.find_element_by_css_selector(
            'div.header>ol>li.active').text

    @property
    def error_msg_text(self):
        '''
        错误的提示信息
        :return:
        '''
        return self.driver.find_element_by_css_selector(
            'div[class="alert alert-error"]>strong').text

    @property
    def alert_msg_text(self):
        '''
        弹出对话框
        :return:
        '''
        alert = self.driver.switch_to.alert
        text = alert.text
        alert.accept()
        return text
Пример #2
0
class UserPage(object):
    def __init__(self):
        self.driver = SingleDriver()

    @property
    def username_input(self):
        return self.driver.find_element_by_css_selector('#name')
Пример #3
0
class UserCenterPage(object):
    def __init__(self):
        self.driver = SingleDriver()

    @property
    def current_create_topic(self):
        return self.driver.find_elements_by_css_selector(
            'div#content > div.panel:nth-child(2) a.topic_title')
Пример #4
0
class TopicPage(object):
    def __init__(self):
        self.driver = SingleDriver()

    def click_edit_icon(self):
        '''
        点击编辑按钮
        :return:
        '''
        self.driver.find_element_by_css_selector('i[title="编辑"]').click()

    @property
    def title_text(self):
        return self.driver.find_element_by_css_selector(
            'span[class="topic_full_title"]').text

    @property
    def content_text(self):
        return self.driver.find_element_by_css_selector(
            'div[class="markdown-text"]').text
Пример #5
0
class ViewManage(object):
    def __init__(self):
        self.driver = SingleDriver()

    def go_to_home_page(self):
        self.driver.get('http://49.233.108.117:3000/')

    def go_to_login_page(self):
        self.driver.get('http://49.233.108.117:3000/signin')

    def go_to_register_page(self):
        self.driver.get('http://49.233.108.117:3000/signup')

    def go_to_user_center(self, user):
        self.driver.get(f'http://49.233.108.117:3000/user/{user}')

    def go_to_newtopic_page(self):
        '''
        从首页打开到新建话题页面
        :return:
        '''
        self.driver.find_element_by_css_selector(
            'a[id="create_topic_btn"]').click()
Пример #6
0
class TopicAction(object):
    '''
    话题相关操作
        发布话题
        修改话题
        删除话题
        回复话题
    '''
    def __init__(self):
        self.driver = SingleDriver()
        self._tab_css = 'select[id="tab-value"]'
        self._title_css = 'textarea[id="title"]'
        self._content_css = 'div[class="CodeMirror-scroll"]'
        self._submit_css = 'input[value="提交"]'

    def __create_topic(self, tab=None, title=None, content=None):
        if tab is not None:
            select_tab = self.driver.find_element_by_css_selector(
                self._tab_css)
            Select(select_tab).select_by_value(tab)
        if title is not None:
            title_area = self.driver.find_element_by_css_selector(
                self._title_css)
            title_area.clear()
            title_area.send_keys(title)

        if content is not None:
            content_area = self.driver.find_element_by_css_selector(
                self._content_css)
            actions = ActionChains(self.driver)
            content_area.click()
            print('----点击一下----')
            if sys.platform == 'win32':
                #用于windows系统
                actions.move_to_element(content_area).key_down(
                    Keys.CONTROL).send_keys('a').key_up(
                        Keys.CONTROL).send_keys(Keys.DELETE).perform()
            else:
                #用于mac系统
                actions.move_to_element(content_area).key_down(
                    Keys.COMMAND).send_keys('a').key_up(
                        Keys.COMMAND).send_keys(Keys.DELETE).perform()

            actions.move_to_element(content_area).send_keys(content).perform()

            submit = self.driver.find_element_by_css_selector(self._submit_css)
            submit.click()

    def add_topic(self, tab, title, content):
        # self.driver.find_element_by_css_selector('select[id="tab-value"]').click()
        # self.driver.find_element_by_css_selector(f'option[value="{tab}"]').click()
        # self.driver.find_element_by_css_selector('textarea[id="title"]').send_keys(title)
        # self.driver.find_element_by_css_selector('div[class="CodeMirror-scroll"]').send_keys(content)
        # self.driver.find_element_by_css_selector('input[class="span-primary submit_btn"]').click()
        self.__create_topic(tab, title, content)

    def edit_topic(self, new_title=None, new_tab=None, new_content=None):
        self.__create_topic(new_title, new_tab, new_content)

    def del_topic(self, title):
        pass

    def reply_topic(self, title, reply_content):
        pass

    @property
    def tipmessage(self):
        '''
        发布话题页面 错误提示信息
        :return:
        '''
        return self.driver.find_element_by_css_selector(
            'div[class="alert alert-error"]>strong').text
Пример #7
0
 def __init__(self):
     self.driver = SingleDriver()
     self._tab_css = 'select[id="tab-value"]'
     self._title_css = 'textarea[id="title"]'
     self._content_css = 'div[class="CodeMirror-scroll"]'
     self._submit_css = 'input[value="提交"]'
Пример #8
0
from test_project.common.singdriver import SingleDriver
from test_project.common.utils import util_demo
from test_project.business.user import UserAction
from test_project.business.topics import TopicAction
from test_project.business.viewmanage import ViewManage
from test_project.business.usercenter import UserCenter
from test_project.pom.topic_page import TopicPage
import os, sys, pytest

userAction = UserAction()
topicAction = TopicAction()
viewManage = ViewManage()
driver = SingleDriver()
topicpage = TopicPage()
usercenter = UserCenter()
util = util_demo()


@pytest.fixture(scope='module', autouse=True)
def module():
    '''
    所有的操作依赖登录,所有的用例执行之前应该先登录
    :return:
    '''
    userAction.user_login('testuser1', '123456')
    yield
    driver.quit()


@pytest.fixture(scope='function', autouse=True)
def func():
Пример #9
0
 def __init__(self):
     self.driver = SingleDriver()
Пример #10
0
class UserAction(object):
    '''
    用户相关业务
    用户注册
    用户登录
    '''
    def __init__(self):
        #确保浏览器实例是有一个
        self.driver=SingleDriver()

    def user_login(self,username,password):
        self.driver.get('http://49.233.108.117:3000/signin')
        userpage.username_input.send_keys(username)
        self.driver.find_element_by_css_selector('#pass').send_keys(password)
        self.driver.find_element_by_css_selector('input[value="登录"]').click()

    def user_register(self,username,password,repasswd,email):
        self.driver.get('http://49.233.108.117:3000/signup')
        self.driver.find_element_by_css_selector('#loginname').send_keys(username)
        self.driver.find_element_by_css_selector('#pass').send_keys(password)
        self.driver.find_element_by_css_selector('#re_pass').send_keys(repasswd)
        self.driver.find_element_by_css_selector('#email').send_keys(email)
        self.driver.find_element_by_css_selector('input[class="span-primary"]').click()
Пример #11
0
 def __init__(self):
     #确保浏览器实例是有一个
     self.driver=SingleDriver()