Esempio n. 1
0
 def setup_class(self):
     #创建driver
     self.driver = Driver.get_driver()
     #创建Login对象
     self.login = Login(self.driver)
     # 创建base对象,调用page_source的方法
     self.base = Base(self.driver)
Esempio n. 2
0
 def setup_class(self):
     # 创建谷歌浏览器
     self.driver = Driver().get_driver()
     # 调用成功的登录方法
     Login(self.driver).login_success()
     self.baseApi = Base(self.driver)
     # 创建购物车的对象
     self.cart = Cart(self.driver)
Esempio n. 3
0
 def setup_class(self):
     # 创建谷歌浏览器
     self.driver = Driver().get_driver()
     # 创建login的页面对象
     # 调用成功的登录方法
     Login(self.driver).login_success()
     self.baseApi = Base(self.driver)
     # 创建新地址的对象
     self.address = Address(self.driver)
Esempio n. 4
0
 def setup_class(self):
     '''
     初始化chrome浏览器
     :return:
     '''
     # 创建谷歌浏览器
     self.driver = Driver().get_driver()
     # 创建login的页面对象
     self.login = Login(self.driver)
     self.baseApi = Base(self.driver)
Esempio n. 5
0
def session_setup():
    """
    Obtains web driver instance from driver factory to be used by the tests for the entire
    session. The function is run twice as follows:
    a) once before the start of session
    b) after the end of session
    """
    driver = Driver.instance()
    yield
    driver.quit()
Esempio n. 6
0
 def setup_class(self):
     #创建driver
     self.driver = Driver.get_driver()
     #创建Login对象
     self.login = Login(self.driver)
     # 创建base对象,调用page_source的方法
     self.base = Base(self.driver)
     # 调用登录成功方法
     self.login.login_success()
     time.sleep(2)
     #创建AddAddress对象
     self.addaddress = AddAddress(self.driver)
Esempio n. 7
0
 def setup_class(self):
     #创建driver
     self.driver = Driver.get_driver()
     #创建Login对象
     self.login = Login(self.driver)
     #调用登录成功方法
     self.login.login_success()
     time.sleep(2)
     #创建Order对象
     self.order = Order(self.driver)
     #创建base对象,获取page_source
     self.base = Base(self.driver)
Esempio n. 8
0
 def __init__(self):  # 传递driver对象
     self.driver = Driver.get_app_driver()
Esempio n. 9
0
 def teardown(self):
     Driver.quit_driver()
Esempio n. 10
0
 def setup(self):
     self.driver = Driver().get_driver(page.url)
     self.pagein = PageIn(self.driver)
     self.PageArticle = self.pagein.get_PageArticle()
     self.PageLogin = self.pagein.get_PageLogin()
     self.PageLogin.login('13911111111', '246810')
Esempio n. 11
0
 def __init__(self):
     self.driver = Driver().driver_open()
 def teardown_class(self):
     Driver.quit_app_driver()
Esempio n. 13
0
 def __init__(self):
     self.driver = Driver.get_driver_open()
Esempio n. 14
0
 def setup(self):
     self.driver = Driver().get_driver(page.url)
     self.pagein = PageIn(self.driver)
Esempio n. 15
0
 def __init__(self):
     self.driver = Driver.instance()
Esempio n. 16
0
 def teardown(cls):
     Driver().quit_driver()
Esempio n. 17
0
 def setup(self):
     self.driver = Driver().get_driver(page.url_back)
     self.PageCheckArticle = PageIn(self.driver).get_PageCheckArticle()
     self.PageBackLogin = PageIn(self.driver).get_PageBackLogin()
     self.PageBackLogin.back_login('testid', 'testpwd123')
Esempio n. 18
0
    def teardown_class(self):

        Driver.close_driver()
Esempio n. 19
0
 def setup_class(cls):
     cls.driver = Driver.create(os.environ["BROWSER"])
Esempio n. 20
0
 def __init__(self):
     self.driver = Driver.get_app_driver()
Esempio n. 21
0
 def setup(self):
     self.driver = Driver().get_driver(page.url_back)
     self.pagein = PageIn(self.driver)
     self.PageBackLogin = self.pagein.get_PageBackLogin()
Esempio n. 22
0
class Base:

    # 初始化
    def __init__(self):
        self.driver = Driver().driver_open()

    def search_ele(self, loc, timeout=5, poll_frequency=1.0):
        """
        定位单个元素
        :param loc: 元组 (By.ID,属性值) (By.XPATH,属性值) (By.CLASS_NAME,属性值)
        :param timeout: 搜索超时时间
        :param poll_frequency: 搜索间隔
        :return: 返回定位对象
        """
        return WebDriverWait(
            self.driver, timeout,
            poll_frequency).until(lambda x: x.find_element(*loc))

    def search_eles(self, loc, timeout=5, poll_frequency=1.0):
        """
        定位一组元素
        :param loc: 元组 (By.ID,属性值) (By.XPATH,属性值) (By.CLASS_NAME,属性值)
        :param timeout: 搜索超时时间
        :param poll_frequency: 搜索间隔
        :return: 返回定位对象列表
        """
        return WebDriverWait(
            self.driver, timeout,
            poll_frequency).until(lambda x: x.find_elements(*loc))

    def click_ele(self, loc, timeout=5, poll_frequency=1.0):
        """
        点击元素
        :param loc: 元组 (By.ID,属性值) (By.XPATH,属性值) (By.CLASS_NAME,属性值)
        :param timeout: 搜索超时时间
        :param poll_frequency: 搜索间隔
        :return:
        """
        self.search_ele(loc, timeout, poll_frequency).click()

    def send_ele(self, loc, text, timeout=5, poll_frequency=1.0):
        """
        输入文本内容
        :param loc: 元组 (By.ID,属性值) (By.XPATH,属性值) (By.CLASS_NAME,属性值)
        :param text: 文本内容
        :param timeout: 搜索超时时间
        :param poll_frequency: 搜索间隔
        :return:
        """
        # 定位
        input_text = self.search_ele(loc, timeout, poll_frequency)
        # 清空
        input_text.clear()
        # 输入
        input_text.send_keys(text)

    def swipe_screen(self, tag=1):
        """
        滑动屏幕
        :param tag: 1:向上 2:向下 3:向左 4: 向右
        :return:
        """
        # 分辨率
        size = self.driver.get_window_size()
        # 宽
        width = size.get("width")
        # 高
        height = size.get("height")
        time.sleep(1)
        # 滑动 上下 高80 -高20 宽50   左右 宽80 -宽20 高50
        if tag == 1:
            # 向上滑动
            self.driver.swipe(width * 0.5, height * 0.8, width * 0.5,
                              height * 0.2, 2000)
        if tag == 2:
            # 向下滑动
            self.driver.swipe(width * 0.5, height * 0.2, width * 0.5,
                              height * 0.8, 2000)
        if tag == 3:
            # 向左滑动
            self.driver.swipe(width * 0.8, height * 0.5, width * 0.2,
                              height * 0.5, 2000)
        if tag == 4:
            # 向右滑动
            self.driver.swipe(width * 0.2, height * 0.5, width * 0.8,
                              height * 0.5, 2000)
Esempio n. 23
0
def method_setup():
    """
    Every test would start from the base url (landing page)
    """
    driver = Driver.instance()
    driver.get(globalconfig.base_url)