Beispiel #1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import configparser
import os.path
from selenium import webdriver
from framwork.logger import Logger
from pageobjects.ggb_Index import indexElement
import time

logger = Logger(logger="EngineLOG").getlog()


#定义浏览器类
class BrowserEngine(object):
    #浏览器的路径,因为只有谷歌的weidriver,所以只加了一个
    dir = os.path.dirname(os.path.abspath('.'))
    chrome_driver_path = dir + '/tools/chromedriver74.0.3.exe'

    #初始化这个类
    def __init__(self, driver):
        self.indexelement = indexElement(self)
        self.driver = driver

    def open_browser(self, driver):
        #这个是python调用配置文件的类
        config = configparser.ConfigParser()
        #读取配置文件的位置
        file_path = os.path.dirname(
            os.path.abspath('.')) + '/config/config.ini'
        #从这个位置读取配置文件
Beispiel #2
0
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait

from framwork.logger import Logger

logger = Logger(logger="Basic").getlog()


class Basic(object):
    def __init__(self, driver):
        self.driver = driver

    def log_in(self, url):
        self.driver.get(url)

    def back(self):  #浏览器后退
        self.driver.back()
        logger.info("后退")

    def forward(self):  # 浏览器前进
        self.driver.forward()
        logger.info("前进")

    def open_url(self, url):
        self.driver.get(url)
        #关闭浏览器
    def quit(self):
        self.driver.quit()

    #关闭窗口
    def close(self):
# @Software: PyCharm

from pageobjects.ggb_Index_pageobject import IndexPage
from pageobjects.ggb_customer_pageobject import Customer_page
from pageobjects.ggb_Addcustomer_pageobject import AddCustomer
from framwork.Get_login_token import Get_Login
from framwork.base_page import BassPage
from framwork.browser_engine import BrowserEngine
from selenium.webdriver.support.ui import WebDriverWait
from framwork.logger import Logger
from selenium import webdriver
import unittest2, time
import requests
import random

mylog = Logger(logger='customer-log').getlog()


class Test_Customer_Managements(unittest2.TestCase):
    def setUp(self):
        Broswer = BrowserEngine(self)
        self.driver = Broswer.open_browser(self)
        mylog.info(u'登录成功')

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

    def test_AddCustomer(self):
        AddCustomers = AddCustomer()
        driver = Customer_page(self)
        Index = IndexPage(self)
Beispiel #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''页面基类,存放所有页面操作方法'''
import time
import os.path
from selenium.common.exceptions import NoSuchElementException
from framwork.logger import Logger
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait

mylog = Logger(logger='Baselog').getlog()


class BassPage(object):
    def __init__(self, driver):
        self.driver = driver

    def quit_browser(self):
        self.driver.quit()
        mylog.info(u'测试完毕关闭浏览器')

    def forward(self):
        self.driver.forward()
        mylog.info(u'点击浏览器前进')

    def back(self):
        self.driver.back()
        mylog.info(u'点击浏览器退后')
Beispiel #5
0
import xlrd

from framwork.logger import Logger

logger = Logger(logger="Read_excel").getlog()


class Read_excel(object):
    @classmethod
    def read_excel(self, excelpath, sheetName="Sheet1"):
        # 读取Excel表格内容       先读行 再读列   以字典方式进行数据存储
        workbook = xlrd.open_workbook(excelpath)
        sheet = workbook.sheet_by_name(sheetName)
        keys = sheet.row_values(0)  # 获取第一个key值
        rownum = sheet.nrows  # 获取总行数
        clonum = sheet.ncols  # 获取总列数
        if rownum <= 1:
            logger.error("excel表中数据总行数小于1")
        else:
            r = []
            for i in range(1, rownum):
                sheet_data = {}
                values = sheet.row_values(i)
                for j in range(clonum):
                    sheet_data[keys[j]] = values[j]
                r.append(sheet_data)
        return r


if __name__ == "__main__":
    print(Read_excel().read_excel("yingyingy.xlsx", "Sheet1"))
Beispiel #6
0
from selenium import webdriver
from framwork.logger import Logger
import unittest
import logging
import time
import os
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait

logger = Logger(logger="Basepage").getlog()


class BaseCase(object):
    def __init__(self, driver):
        self.driver = driver

    def open_url(self, url):
        self.driver.get(url)

    def quit_browser(self):
        self.driver.quit()

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

    def click(self, *loc):
        self.find_element(*loc).click()

    def find_element(self, *loc):
        WebDriverWait(self.driver,
                      10).until(EC.visibility_of_element_located(loc))
Beispiel #7
0
import os.path
from configparser import ConfigParser
from selenium import webdriver
from framwork.logger import Logger

#创建一个日志记录器实例
logger = Logger(logger="BrowserEngin").getlog()


class BrowserEngin(object):
    dir = os.path.dirname(os.path.abspath("."))  #相对路径获取方法
    chrome_driver_path = dir + "/tools/chromedriver.exe"
    ie_driver_path = dir + "/tools/IEDdriverServer.exe"
    firefox_driver_path = dir + "/tools/geckodriver.exe"

    #read the browser type from config.ini file,return the driver
    #从config.ini文件读取浏览器类型,返回驱动程序
    def open_browser(self):
        config = ConfigParser()
        file_path = os.path.dirname(
            os.path.abspath(".")) + "/config/config.ini"
        config.read(file_path)

        browser = config.get("browserType", "browserName")
        logger.info("你选择了%s游览器" % browser)  #you had selectt %s browser
        url = config.get("testServer", "URL")
        logger.info("测试URL是:%s" % url)  # the test server url is

        if browser == "Firefox":
            driver = webdriver.Firefox(self.firefox_driver_path)  #启动Firefox
            logger.info("启动火狐游览器")