Beispiel #1
0
class TestWebBaseCase(TestBaseCase):
    """
    web测试初始化
    """
    def setup(self):
        super(TestWebBaseCase, self).setup()
        self.driver = WebChrome()
        self.driver.implicitly_wait(5)
        self.driver.get(BASEURL)
        # 使用cookie打开浏览器
        with shelve.open(f"{mydbs_dir}/cookies") as db:
            # coo = self.driver.get_cookies()
            # db["cookies"] = coo
            cookies = db["cookies"]
        for cookie in cookies:
            if "expiry" in cookie.keys():
                cookie.pop("expiry")
                continue
            self.driver.add_cookie(cookie)
        self.driver.get(BASEURL)
        self.log.info("进入主界面")
        self.main_page = MainPage(self.driver)

    def teardown(self):
        super(TestWebBaseCase, self).teardown()
        self.log.info("关闭浏览器")
        self.driver.quit()
Beispiel #2
0
    def __init__(self, target_url):
        self.driver = WebChrome()
        self.driver.get(target_url)
        self.driver.implicitly_wait(20)

        self.exp_user_dic = [
            "admin' or 'a'='a", "'or'='or'", "admin' or '1'='1' or 1=1",
            "')or('a'='a", "'or 1=1 -- -"
        ]
        self.exp_pass_dic = self.exp_user_dic
        self.static_user_dic = [
            'admin', 'system', 'sa', 'test', 'manager', 'root', 'user', 'www',
            'web', 'username', 'guest', 'name', 'zhanghao', 'yonghu', 'email',
            'account'
        ]
        self.suffix_dic = ['', '123', '888', '666', '123456']
        self.static_pass_dic = [
            '{user}', '123456', '{user}888', '12345678', '123123', '88888888',
            '888888', 'password', '123456a', '{user}123', '{user}123456',
            '{user}666', '{user}2018', '123456789', '654321', '666666',
            '66666666', '1234567890', '8888888', '987654321', '0123456789',
            '12345', '1234567', '000000', '111111', '5201314', '123123',
            'pass', 'password', 'P@ssw0rd', 'P@ssw0rd2019', 'P@ssw0rd2020',
            'P@ssw0rd2021'
        ]

        self.password_inputbox_id = ''
        self.username_inputbox_id = ''
Beispiel #3
0
def web_driver(request):
    """返回driver,现在是Chrome"""
    global driver
    HEADLESS = get_web_config().get("HEADLESS")
    DEBUGGER = get_web_config().get("DEBUGGER")
    if HEADLESS is True:
        __options = Options()
        __options.add_argument('--headless')
        driver = WebChrome(chrome_options=__options)
    elif DEBUGGER is True:
        # 如果需要使用已经打开的,chrome浏览器的debugger模式,需要把以下三行代码释放
        chrome_options = Options()
        chrome_options.add_experimental_option("debuggerAddress",
                                               "127.0.0.1:9222")
        driver = WebChrome(options=chrome_options)
    else:
        __options = Options()
        # 设置全屏
        __options.add_argument('--start-maximized')
        # 设置开发者模式
        __options.add_experimental_option(
            "excludeSwitches",
            ["ignore-certificate-errors", "enable-automation"])
        driver = WebChrome(chrome_options=__options)

    yield driver
    driver.close()

    def end():
        driver.quit()

    request.addfinalizer(end)
Beispiel #4
0
from selenium import webdriver
from airtest_selenium.proxy import WebChrome
from time import sleep

options = webdriver.chrome.options.Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = WebChrome(chrome_options=options)
driver.implicitly_wait(20)
driver.get("http://td2.qingbaomofang.com/dashboard/market")
sleep(1)
#打开宝贝列表
driver.find_element_by_xpath(
    "/html/body/div[2]/div/div/div/div/div/ul/div/li[5]/div/span").click()
sleep(1)
driver.find_element_by_xpath(
    "/html/body/div[2]/div/div/div/div/div/ul/div/li[5]/ul/li/ul/li/span"
).click()
sleep(5)
#社媒流量分析
driver.find_element_by_xpath(
    "//a[@title='完美日记动物眼影盘锦鲤小狗小猫猫咪老虎斑虎小猪熊猫小鹿盘女']").click()
sleep(1)
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div[2]/div/div[3]/div/div/a[4]").click()
sleep(1)
#时间选择
driver.find_element_by_xpath("//input[@placeholder='选择日期']").click()
sleep(1)
driver.find_element_by_xpath(
    "/html/body/div[3]/div/div/div[2]/table/tbody/tr[2]/td[5]/div/span").click(
    )
from selenium import webdriver
from airtest_selenium.proxy import WebChrome
from time import sleep

options = webdriver.chrome.options.Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = WebChrome(chrome_options=options)
driver.implicitly_wait(20)
#打开网址
driver.get("http://47.111.14.225:30017/monitorPage/selfMonitor/shop")
sleep(1)
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div/div/div/div/div/div/dl/dd[2]/a").click()
sleep(1)
#查看品牌详情
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div[2]/div/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[9]/div/a"
).click()
sleep(1)
#查看店铺详情
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div[2]/div/div[3]/div[2]/div/div/div[3]/table/tbody/tr/td[8]/div/a"
).click()
sleep(1)
#时间选择
driver.find_element_by_xpath("//input[@placeholder='选择周']").click()
sleep(1)
#选择某一周
driver.find_element_by_xpath(
    "/html/body/div[3]/div/div/div[2]/table/tbody/tr[3]/td[3]/div").click()
sleep(1)
    else:
        pass
    if poco('一键购买').exists():
        poco('一键购买').click()
        sleep(20)
        if exists(Template(r"tpl1572316650111.png", record_pos=(-0.344, -0.186), resolution=(2560, 1440))):
            log('购买成功')
            pass
stop_app(app_id)    
sleep(3)
clear_app(app_id)
################################################################
from airtest.core.api import *
from airtest_selenium.proxy import WebChrome
game_id = '600144'
driver = WebChrome()
driver.implicitly_wait(20)
sleep(3)
driver.maximize_window()
driver.get("http://tech-support.upltv.com:82/index")

driver.find_element_by_xpath("//a[@href='/auth/login']").click()

driver.find_element_by_xpath("//input[@autocomplete='on']").send_keys('*****@*****.**')
driver.find_element_by_xpath("//input[@autocomplete='off']").send_keys('Temp2019')
driver.find_element_by_xpath("//input[@value='登录']").click()
sleep(5)
Logging('准备数据上报------------------------------------------')
driver.find_element_by_xpath("//*[@id=\"bs-example-navbar-collapse-1\"]/ul/li/a/span").click()
driver.find_element_by_xpath("//a[@href='/report/analysis']").click()
from selenium import webdriver
from airtest_selenium.proxy import WebChrome
from time import sleep

options = webdriver.chrome.options.Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = WebChrome(chrome_options=options)
driver.implicitly_wait(20)
driver.get("http://td2.qingbaomofang.com/dashboard/market")
sleep(1)
#抖音短视频
driver.find_element_by_xpath(
    "/html/body/div[2]/div/div/div/div/div/ul/div/li/ul/li/ul/li[4]/ul/li/ul/li/span"
).click()
sleep(3)
#选择时间
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div[2]/div/div/div/div[2]/div[2]/div/div/div/div/div/div[2]/input"
).click()
sleep(1)
driver.find_element_by_xpath(
    "/html/body/div[3]/div/div/div[2]/table/tbody/tr[2]/td/div/span").click()
driver.find_element_by_xpath(
    "/html/body/div[3]/div/div/div[2]/table/tbody/tr[2]/td[4]/div/span").click(
    )
sleep(3)
#平均值
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div[2]/div/div/div/div[2]/div[2]/div/div[1]/div[2]/div[1]/label/span[1]/span"
).click()
sleep(3)
Beispiel #8
0
from selenium import webdriver
from airtest_selenium.proxy import WebChrome
from time import sleep

options = webdriver.chrome.options.Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = WebChrome(chrome_options=options)
driver.implicitly_wait(20)
driver.get("http://td2.qingbaomofang.com/dashboard/market")
sleep(1)
#打开属性交叉分析
driver.find_element_by_xpath(
    "/html/body/div[2]/div/div/div/div/div/ul/div/li[2]/div").click()
sleep(1)
driver.find_element_by_xpath(
    "/html/body/div[2]/div/div/div/div/div/ul/div/li[2]/ul/li/ul/li[3]/span"
).click()
sleep(1)
#选择类目
driver.find_element_by_xpath("//a[@style='width: 232.021px;']").click()
sleep(1)
driver.find_element_by_xpath("//a[@title='彩妆/香水/美妆工具']").click()
sleep(3)
driver.find_element_by_xpath("//a[@title='唇膏/口红']").click()
sleep(1)
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div[2]/div/div[2]/h4").click()
#选择属性
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div[2]/div/div[2]/div/div/div[2]/div/div[2]/div[2]/div/a"
).click()
Beispiel #9
0
# -*- encoding=utf8 -*-
__author__ = "janson"
# 还款申请单

from airtest.core.api import *
using(r"E:\黄振旭\费用管理系统自动化测试用例\conf\common.air")
from common import common
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from airtest_selenium.proxy import WebChrome
driver = WebChrome()
driver.implicitly_wait(20)
driver.get("http://14.21.59.70:1000/")
driver.maximize_window()  #放大浏览器
# 登录夏子霞支付借款单
common.login(driver, "xiazixia")
common.pay_loan(driver)
common.quit(driver)
# 登录huangzhenxu账号,提交还款申请单
common.login(driver, "huangzhenxu")
driver.find_element_by_xpath(
    "//*[@id=\"app\"]/div/div/div[2]/div/div/ul/div[3]/li/ul/div[3]/a/li/span"
).click()

driver.assert_template(
    Template(r"tpl1595316700201.png",
             record_pos=(11.41, 1.0),
             resolution=(100, 100)), "进入还款申请单")
driver.airtest_touch(
    Template(r"tpl1595316722041.png",
             record_pos=(11.645, 1.825),
Beispiel #10
0
import unittest

from selenium import webdriver
from airtest_selenium.proxy import WebChrome
from time import sleep

options = webdriver.chrome.options.Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = WebChrome(chrome_options=options)
driver.implicitly_wait(20)
driver.get("http://td2.qingbaomofang.com/dashboard/market")
sleep(1)
# 打开宝贝列表
driver.find_element_by_xpath(
    "/html/body/div[2]/div/div/div/div/div/ul/div/li[5]/div/span").click()
sleep(1)
driver.find_element_by_xpath(
    "/html/body/div[2]/div/div/div/div/div/ul/div/li[5]/ul/li/ul/li/span"
).click()
sleep(5)

# 宝贝趋势分析
driver.find_element_by_xpath(
    "//a[@title='完美日记动物眼影盘锦鲤小狗小猫猫咪老虎斑虎小猪熊猫小鹿盘女']").click()
sleep(1)

# 按月
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div[2]/div/div[3]/div[2]/div/div[1]/div/div[1]/div[1]/div[3]/div[1]/span"
).click()
sleep(1)
Beispiel #11
0
from selenium import webdriver
from airtest_selenium.proxy import WebChrome
from time import sleep

options = webdriver.chrome.options.Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = WebChrome(chrome_options=options)
driver.implicitly_wait(20)
driver.get("http://td2.qingbaomofang.com/dashboard/market")
sleep(1)
#关注列表
driver.find_element_by_xpath(
    "/html/body/div[2]/div/div/div/div/div/ul/div/li[4]/div").click()
sleep(1)
driver.find_element_by_xpath(
    "/html/body/div[2]/div/div/div/div/div/ul/div/li[4]/ul/li/ul/li/span"
).click()
sleep(5)
driver.find_element_by_xpath("//a[@title='perfectdiary旗舰店']").click()
sleep(2)
#价格分析
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div[2]/div/div[3]/div/div/a[2]").click()
#选择日期
driver.find_element_by_xpath("//input[@placeholder='选择日期']").click()
sleep(1)
driver.find_element_by_xpath(
    "/html/body/div[3]/div/div/div[2]/table/tbody/tr[2]/td[5]/div/span").click(
    )
sleep(1)
Beispiel #12
0
class Mytest(unittest.TestCase):
    """
    基类:整个用例执行前的操作以及公共的方法
    """
    dr = WebChrome(globalparam.executable_path)
    logger = Log()

    @classmethod
    def setUpClass(cls):
        """
        整个用例执行的前置条件
        """
        cls.logger.info('############################### START ###############################')
        cls.dr.maximize_window()

    def setUp(self):
        pass

    def tearDown(self):
        """
        每个用例执行的后置条件
        """
        # 用例执行报错立即截图
        errors = self._outcome.errors
        for test, exc_info in errors:
            if exc_info:
                self.save_img('test')
                pass
            else:
                pass

    @classmethod
    def tearDownClass(cls):
        """
        整个用例执行的后置条件
        """
        cls.dr.quit()
        cls.logger.info('###############################  End  ###############################')

    @classmethod
    def save_img(self, img_name):
        """
        保存图片
        保存的图片同时可用于展示在报告里
        :param img_name: 要保存的图片的名称
        """

        img_path = abs_dir + '\{}-{}.png'.format(img_name, time.strftime('%Y-%m-%d_%H_%M_%S'))
        img_path = img_path.replace('\\', '/')  # 将反斜杠\替换成/
        print(img_path)
        # cls.dr.snapshot(filename=img_path)
        self.take_screenshot(self, file_path=img_path)
        img_path = img_path[img_path.index("/web_UItest"):]  # 截取图片路径后面部分,用来拼接成相对路径
        img_path ='http://localhost:63342'+ '{}'.format(img_path)
        print("<img src='" + img_path + "' width=600 />")  # 把图片发送到 BR 报告里,BR 的特性

    def take_screenshot(self, file_path):
        """
        Get the current window screenshot.

        Usage:
        dr.take_screenshot('c:/test.png')
        """
        t1 = time.time()
        try:
            self.dr.get_screenshot_as_file(file_path)
            self.my_print(msg="{0} Get the current window screenshot,path: {1}, Spend {2} seconds".format(success,
                                                                                                          file_path,
                                                                                                          time.time() - t1))
        except Exception:
            self.my_print(msg="{0} Unable to get the current window screenshot,path: {1}, Spend {2} seconds".format(
                fail,
                file_path,
                time.time() - t1))
            raise

    def my_print(msg):
        logger.info(msg)
Beispiel #13
0
# -*- encoding=utf8 -*-
__author__ = "janson"
# 提交出差借款借款申请单,进入审核流程,有影响,使用huangzhenxu
from airtest.core.api import *
using(r"E:\黄振旭\费用管理系统自动化测试用例\conf\common.air")
from common import common
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from airtest_selenium.proxy import WebChrome

driver = WebChrome()
driver.implicitly_wait(20)

driver.get("http://14.21.59.70:1000/")
driver.maximize_window()  #放大浏览器
#登录黄振旭账号
common.login(driver, "huangzhenxu")
common.create_loan(driver)
driver.close()

auto_setup(__file__)
Beispiel #14
0
 def __init__(self):
     self.dr = WebChrome(globalparam.executable_path)
Beispiel #15
0
for j in range(counts):
    ordl = []
    testl = []
    for i in ords:
        if int(i['ord'][:3]) == j:
            ordl.append(i['ord'])
            ordl.sort()
    for j in ordl:
        for i in ords:
            if i['ord'] == j:
                testl.append(i)

    testcases.append(testl)

for k in testcases:
    driver = WebChrome()
    driver.implicitly_wait(8)
    #测试执行
    driver.get("https://member.163220.com/#/home")
    driver.maximize_window()

    pid = psutil.Process(
        driver.service.process.pid).children(recursive=True)[0].pid
    #元素绑定方法
    try:
        runtest(driver, pid, k, testcases)

    except:
        raise
    finally:
        driver.close()
Beispiel #16
0
from selenium import webdriver
from airtest_selenium.proxy import WebChrome
from time import sleep

options =webdriver.chrome.options.Options()
options.add_experimental_option("debuggerAddress","127.0.0.1:9222")
driver = WebChrome(chrome_options=options)
driver.implicitly_wait(20)
driver.get("http://td2.qingbaomofang.com/dashboard/market")
sleep(1)
#打开品牌列表
driver.find_element_by_xpath("/html/body/div[2]/div/div/div/div/div/ul/div/li[3]/div/span").click()
sleep(1)
driver.find_element_by_xpath("/html/body/div[2]/div/div/div/div/div/ul/div/li[3]/ul/li/ul/li/span").click()
sleep(4)
driver.find_element_by_xpath("/html/body/div[2]/div[2]/div[2]/div/div/div/div[2]/div/div/div[3]/table/tbody/tr[13]/td[2]/div/a").click()
sleep(2)
#打开关联分析
driver.find_element_by_xpath("/html/body/div[2]/div[2]/div[2]/div/div[3]/div/div/a[3]").click()
sleep(2)
#店铺列表
#飙升排行
driver.find_element_by_xpath("/html/body/div[2]/div[2]/div[2]/div/div[3]/div[2]/div/div/div[2]/div/div/div[1]/div[1]/span").click()
sleep(1)
driver.find_element_by_xpath("/html/body/ul/li[2]").click()
sleep(1)
#周时间选择
driver.find_element_by_xpath("//input[@placeholder='选择周']").click()
sleep(1)
driver.find_element_by_xpath("/html/body/div[3]/div/div/div[2]/table/tbody/tr[2]/td[5]/div/span").click()
sleep(1)
Beispiel #17
0
# -*- encoding=utf8 -*-
from airtest.core.api import *

__author__ = "zxfn4514"

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from airtest_selenium.proxy import WebChrome
driver = WebChrome()
driver.implicitly_wait(20)

driver.get("https://github.com/AirtestProject")
driver.find_element_by_xpath(
    "//*[@id=\"js-pjax-container\"]/div/header/div/nav/a[2]").click()
driver.find_element_by_xpath("//a[@data-hotkey='g b']").click()
driver.airtest_touch(
    Template(r"tpl1534930299434.png",
             record_pos=(12.015, 2.275),
             resolution=(100, 100)))
driver.assert_template(
    Template(r"tpl1534930307633.png",
             record_pos=(8.61, 2.925),
             resolution=(100, 100)), "Please fill in the test point.")
Beispiel #18
0
# -*- encoding=utf8 -*-

__author__ = "lenovo"

from airtest.core.api import *
from poco.drivers.android.uiautomation import AndroidUiautomationPoco
poco = AndroidUiautomationPoco(use_airtest_input=True,
                               screenshot_each_action=False)
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from airtest_selenium.proxy import WebChrome
driver = WebChrome()
driver.implicitly_wait(20)

auto_setup(__file__)


# 检查当前是否在【我的】模块界面
def check_whether_WoDe():
    try:
        wait(Template(r"tpl1582873438022.png",
                      record_pos=(-0.301, 0.356),
                      resolution=(1080, 2220)),
             timeout=1.0)
    except TargetNotFoundError:
        print("当前界面不是我的界面")
        poco(text="我的").click()  #点击切换到我的界面
        print("手动切换到我的界面")
    else:
        print("当前界面是我的界面")
Beispiel #19
0
# -*- encoding=utf8 -*-
__author__ = "janson"
#上传、搜索、查看、删除发票
from airtest.core.api import *
from airtest.core.api import using
using(r"E:\黄振旭\费用管理系统自动化测试用例\conf\common.air")
from common import common
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from airtest_selenium.proxy import WebChrome

driver = WebChrome()
driver.maximize_window()  #放大浏览器
driver.get("http://14.21.59.70:1000/#/mrp/base/warehouseList")
common.login(driver, "huangzhenxu")

driver.find_element_by_xpath(
    "//*[@id=\"app\"]/div/div/div[2]/div/div/ul/div/li/ul/div/a/li/span"
).click()  #进入【上传发票】页面
driver.assert_template(
    Template(r"tpl1594800342361.png",
             record_pos=(7.415, 2.15),
             resolution=(100, 100)), "成功打开发票管理页面")
driver.airtest_touch(
    Template(r"tpl1594800381828.png",
             record_pos=(7.82, 2.985),
             resolution=(100, 100)))
driver.assert_template(
    Template(r"tpl1594800422516.png",
             record_pos=(13.66, 4.545),
             resolution=(100, 100)), "打开识别发票接界面")
Beispiel #20
0
Datei: daka.py Projekt: gsj5533/-
def job1(useid, password):
    #通过python自带的模块判断是不是节假日
    nowTime = datetime.date(datetime.datetime.now().year,
                            datetime.datetime.now().month,
                            datetime.datetime.now().day)
    print(is_workday(nowTime))

    if is_workday(nowTime):
        print('Its weekday')
        driver = WebChrome()
        driver.implicitly_wait(20)
        driver.get(
            "http://sso.portal.unicom.local/eip_sso/aiportalLogin.html?appid=na186&success=http://service.aiportal.unicom.local/ssoclient/ssologin&error=http://sso.portal.unicom.local/eip_sso/aiportalLogin.html&return=http://sso.portal.unicom.local/eip_sso/aiportalLogin.html"
        )
        driver.find_element_by_id('login').send_keys(useid)
        driver.find_element_by_id('password').send_keys(password)
        driver.find_element_by_xpath("//button[@class='login_botton']").click()
        driver.find_element_by_xpath(
            "//div[@class='pan' and @label='人力资源2.0']").click()
        driver.switch_to_new_tab()
        driver.find_element_by_xpath(
            "//a[@class = 'gn_block gn_block1']").click()
        driver.switch_to_new_tab()
        driver.find_element_by_xpath(
            "//button[@class='ant-btn sign-btn signout ant-btn-primary']"
        ).click()
        driver.quit()
    else:
        print('Its holiday')
Beispiel #21
0
from selenium import webdriver
from airtest_selenium.proxy import WebChrome
from time import sleep

options = webdriver.chrome.options.Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = WebChrome(chrome_options=options)
driver.implicitly_wait(20)
#打开网址
driver.get("http://47.111.14.225:30017/monitorPage/selfMonitor/shop")
sleep(2)

#打开医务泄露列表
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div/div/div/div/div/div/dl[2]/dd[3]/a").click()
sleep(2)

#宝贝搜索
driver.find_element_by_xpath("//input[@placeholder='请输入宝贝名称搜索']").send_keys(
    "超启能恩")
sleep(1)
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div[2]/div/div/div/div/div/button").click()
sleep(1)
Beispiel #22
0
# -*- encoding=utf8 -*-
__author__ = "janson"
# 差旅报销申请单审批流程
from airtest.core.api import *
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from airtest_selenium.proxy import WebChrome
using(r"E:\黄振旭\费用管理系统自动化测试用例\conf\common.air")
from common import common


driver = WebChrome()
driver.implicitly_wait(20)
driver.get("http://14.21.59.70:1000/")
driver.maximize_window()#放大浏览器


# 登录黄振旭账号,提交差旅报销申请单
common.login(driver,"huangzhenxu")
driver.assert_exist("//*[@id=\"tags-view-container\"]/div/div/div/span", "xpath", "验证是否登录进入主页.")


common.upload_invoice(driver) # 上传一张发票
driver.airtest_touch(Template(r"tpl1597398632931.png", record_pos=(0.36, 7.65), resolution=(100, 100)))
driver.assert_template(Template(r"tpl1595237905970.png", record_pos=(9.16, 1.595), resolution=(100, 100)), "打开差旅报销申请单")
driver.airtest_touch(Template(r"tpl1595238021979.png", record_pos=(9.275, 2.43), resolution=(100, 100)))
driver.assert_template(Template(r"tpl1595238038956.png", record_pos=(8.545, 2.035), resolution=(100, 100)), "进入新增页面")
driver.airtest_touch(Template(r"tpl1595238520371.png", target_pos=4, record_pos=(7.775, 4.005), resolution=(100, 100)))
driver.assert_template(Template(r"tpl1595238613863.png", record_pos=(3.855, 4.43), resolution=(100, 100)), "进入选择出差申请单界面")
driver.airtest_touch(Template(r"tpl1595238654302.png", record_pos=(14.395, 5.615), resolution=(100, 100)))
driver.find_element_by_id("erp_txtMEMO").send_keys("租金")
from selenium import webdriver
from airtest_selenium.proxy import WebChrome
from time import sleep

options = webdriver.chrome.options.Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = WebChrome(chrome_options=options)
driver.implicitly_wait(20)
#打开网址
driver.get("http://47.111.14.225:30017/monitorPage/selfMonitor/shop")
sleep(1)
#打开竞品监控
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div/div/div/div/div/div/dl/dd[2]/a").click()
sleep(1)
#查看品牌详情
driver.find_element_by_xpath(
    "/html/body/div[2]/div[2]/div[2]/div/div[2]/div[2]/div/div/div[3]/table/tbody/tr/td[9]/div/a"
).click()
sleep(1)

#时间选择
driver.find_element_by_xpath("//input[@placeholder='选择周']").click()
sleep(1)
#选择某一周
driver.find_element_by_xpath(
    "/html/body/div[3]/div/div/div[2]/table/tbody/tr[3]/td[3]/div").click()
sleep(1)

#导出
#driver.find_element_by_xpath("/html/body/div[2]/div[2]/div[2]/div/div[3]/div/div[2]/div/button").click()
Beispiel #24
0
options = Options()
options.add_argument('--dns-prefetch-disable')
options.add_argument("--disable-features=VizDisplayCompositor")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument('start-maximized')
options.add_argument('enable-automation')
options.add_argument('--no-sandbox')
options.add_argument('--disable-infobars')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-browser-side-navigation')
options.add_argument('--disable-gpu')
options.add_argument('--disable-extensions')

driver = WebChrome(executable_path=chrome, options=options)
driver.implicitly_wait(40)
dfx = driver.find_element_by_xpath
ser = CaseService()


def main_setup():
    try:
        driver.get(test_url)
        driver.maximize_window()
        dfx("//button[@type='submit']").click()
    except Exception as e:
        ser.find_JSerror(driver)
        print(
            '================================================================')
        print(e.args)
Beispiel #25
0
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from airtest_selenium.proxy import WebChrome
driver = WebChrome()
driver.implicitly_wait(10)
driver.maximize_window()
driver.get("https://www.yigongla.com/")
driver.find_element_by_xpath("//a[@href='/index/index/index']").click()
driver.find_element_by_xpath("//a[@href='/index/qyserve/qyserve']").click()

driver.assert_exist("/html/body/div[3]/div/h3", "xpath", "我的价值")

driver.find_element_by_xpath("//a[@href='/index/inquiry/inquiry']").click()
driver.find_element_by_xpath("//a[@href='/index/about/about']").click()
driver.find_element_by_xpath("/html/body/div/div[2]/a/button").click()
driver.assert_exist("/html/body/div/div/div/div/div/div", "xpath", "密码登录")
driver.assert_exist("/html/body/div/div/div/div/div/div[2]", "xpath", "验证码登录")
driver.assert_exist("/html/body/div/div/div/div[3]/p", "xpath", "还没有易工账号")
driver.assert_exist("/html/body/div/div/div/div[3]/div/a/span", "xpath", "立即注册")
driver.assert_exist("passwordLogin", "id", "登录")
driver.assert_exist("/html/body/div[2]/p", "xpath", "从蓝领招聘开始解决缺工现象.")

driver.quit()
Beispiel #26
0
    def open_browser(
            self,
            url: Optional[str] = None,
            browser: str = "Chrome",
            alias: Optional[str] = None,
            remote_url: Union[bool, str] = False,
            headless: Optional[bool] = False,
            options: Any = None,
            device: Optional[str] = None,
            executable_path: Optional[str] = None,
            service_args: Union[dict, None, str] = None,
            desired_capabilities: Union[dict, None, str] = None) -> str:
        """
        启动浏览器类型可选: Firefox, Chrome, Ie, Opera, Safari, PhantomJS, 可模拟移动设备
        """
        if browser not in [
                'Firefox', 'Chrome', 'Ie', 'Opera', 'Safari', 'PhantomJS'
        ]:
            raise Exception(
                '浏览器类型不对, 仅可选: Firefox, Chrome, Ie, Opera, Safari, PhantomJS')

        remote_url = remote_url or self.remote_url
        browser = browser or self.browser
        headless = headless or self.headless
        alias = alias or self.alias
        device = device or self.device
        executable_path = executable_path or self.executable_path
        options or self.options
        service_args = service_args or self.service_args
        desired_capabilities = desired_capabilities or self.desired_capabilities

        if remote_url:
            if browser == 'Chrome':
                chrome_options = webdriver.ChromeOptions()
                chrome_options.add_argument('--no-sandbox')
                chrome_options.add_argument('--disable-setuid-sandbox')
                chrome_options.add_argument('--disable-dev-shm-usage')
                if headless:
                    chrome_options.add_argument('--headless')
                    chrome_options.add_argument('--disable-gpu')
                if device:
                    mobile_emulation = {'deviceName': device}
                    chrome_options.add_experimental_option(
                        'mobileEmulation', mobile_emulation)
                browser_options = chrome_options
            elif browser == 'Firefox':
                firefox_options = webdriver.FirefoxOptions()
                firefox_options.add_argument('--disable-dev-shm-usage')
                if headless:
                    firefox_options.add_argument('--headless')
                    firefox_options.add_argument('--disable-gpu')
                browser_options = firefox_options
            else:
                browser_options = options
            desired_capabilities = desired_capabilities or {}
            desired_capabilities['browserName'] = browser.lower()
            driver = WebRemote(command_executor=remote_url,
                               desired_capabilities=desired_capabilities,
                               options=options or browser_options)
            # ctx.create_webdriver(driver_name='Remote', alias=alias, command_executor=remote_url, options=options, desired_capabilities=desired_capabilities)
        elif browser == 'Chrome':
            chrome_options = webdriver.ChromeOptions()
            chrome_options.add_argument('--no-sandbox')
            chrome_options.add_argument('--disable-setuid-sandbox')
            if headless:
                chrome_options.add_argument('--headless')
                chrome_options.add_argument('--disable-gpu')
            if device:
                mobile_emulation = {'deviceName': device}
                chrome_options.add_experimental_option('mobileEmulation',
                                                       mobile_emulation)
            if executable_path:
                driver = WebChrome(executable_path=executable_path,
                                   options=options or chrome_options,
                                   service_args=service_args,
                                   desired_capabilities=desired_capabilities)
                # ctx.create_webdriver(driver_name=browser, alias=alias, executable_path=executable_path, options=options or chrome_options, service_args=service_args, desired_capabilities=desired_capabilities)
            else:
                driver = WebChrome(options=options or chrome_options,
                                   service_args=service_args,
                                   desired_capabilities=desired_capabilities)
                # ctx.create_webdriver(driver_name=browser, alias=alias, options=options or chrome_options, service_args=service_args, desired_capabilities=desired_capabilities)
        elif browser == 'Firefox':
            firefox_options = webdriver.FirefoxOptions()
            if headless:
                firefox_options.add_argument('--headless')
                firefox_options.add_argument('--disable-gpu')
            if executable_path:
                driver = WebFirefox(executable_path=executable_path,
                                    options=options or firefox_options,
                                    service_args=service_args,
                                    desired_capabilities=desired_capabilities)
                # ctx.create_webdriver(driver_name=browser, alias=alias, executable_path=executable_path, options=options or firefox_options, service_args=service_args, desired_capabilities=desired_capabilities)
            else:
                driver = WebFirefox(options=options or firefox_options,
                                    service_args=service_args,
                                    desired_capabilities=desired_capabilities)
                # ctx.create_webdriver(driver_name=browser, alias=alias, options=options or firefox_options, service_args=service_args, desired_capabilities=desired_capabilities)
        else:
            if executable_path:
                self.create_webdriver(
                    driver_name=browser,
                    alias=alias,
                    executable_path=executable_path,
                    service_args=service_args,
                    desired_capabilities=desired_capabilities)
            else:
                self.create_webdriver(
                    driver_name=browser,
                    alias=alias,
                    service_args=service_args,
                    desired_capabilities=desired_capabilities)
            driver = self.driver
        index = self.ctx.register_driver(driver=driver, alias=alias)
        if url: self.go_to(url)
        return index
# -*- encoding=utf8 -*-
__author__ = "janson"
from airtest.core.api import *
# 查看借还款界面
from airtest.core.api import *
using(r"E:\黄振旭\费用管理系统自动化测试用例\conf\common.air")
from common import common
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from airtest_selenium.proxy import WebChrome
driver = WebChrome()
driver.implicitly_wait(20)

driver.get("http://14.21.59.70:1000")
driver.maximize_window()  #放大浏览器
common.login(driver, "huangzhenxu")
driver.assert_exist("//*[@id=\"tags-view-container\"]/div/div/div/span",
                    "xpath", "验证是否登录进入主页.")
driver.find_element_by_xpath(
    "//*[@id=\"app\"]/div/div/div[2]/div/div/ul/div[3]/li/ul/div/a/li/span"
).click()
driver.assert_template(
    Template(r"tpl1594869543864.png",
             record_pos=(10.415, 1.0),
             resolution=(100, 100)), "进入借还款追踪管理")
driver.close()

auto_setup(__file__)
Beispiel #28
0
import unittest

from selenium import webdriver
from airtest_selenium.proxy import WebChrome
from time import sleep

options = webdriver.chrome.options.Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = WebChrome(chrome_options=options)
driver.implicitly_wait(20)
driver.get("http://td2.qingbaomofang.com/dashboard/market")
sleep(1)


class Assert_test(unittest.TestCase):
    # 选择类目
    driver.find_element_by_xpath("//a[@title='彩妆/香水/美妆工具>唇膏/口红']").click()
    sleep(1)
    driver.find_element_by_xpath("//a[@title='彩妆/香水/美妆工具']").click()
    sleep(2)
    driver.find_element_by_xpath("//a[@title='唇膏/口红']").click()
    sleep(1)

    # 获取头部销售额
    toolmoney = driver.find_element_by_xpath(
        "/html/body/div[2]/div[2]/div[2]/div/div/div[2]/div/div[1]/div[2]/p[1]/span"
    ).get_attribute("textContent")
    print(toolmoney)
    # 获取头部销售量
    toolamount = driver.find_element_by_xpath(
        "/html/body/div[2]/div[2]/div[2]/div/div/div[2]/div/div[2]/div[2]/p[1]"
Beispiel #29
0
import unittest

from selenium import webdriver
from airtest_selenium.proxy import WebChrome
from time import sleep

options = webdriver.chrome.options.Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = WebChrome(chrome_options=options)
driver.implicitly_wait(20)
driver.get("http://td2.qingbaomofang.com/dashboard/market")
sleep(1)
# 关注列表
driver.find_element_by_xpath(
    "/html/body/div[2]/div/div/div/div/div/ul/div/li[4]/div").click()
sleep(1)
driver.find_element_by_xpath(
    "/html/body/div[2]/div/div/div/div/div/ul/div/li[4]/ul/li/ul/li/span"
).click()
sleep(5)


class Assert_test(unittest.TestCase):
    # 打开店铺详情
    driver.find_element_by_xpath("//a[@title='perfectdiary旗舰店']").click()
    # 按月
    driver.find_element_by_xpath(
        "/html/body/div[2]/div[2]/div[2]/div/div[3]/div[2]/div/div[1]/div/div[1]/div[1]/div[3]/div[1]/span"
    ).click()
    sleep(1)
    driver.find_element_by_xpath("/html/body/ul/li[2]").click()
Beispiel #30
0
# -*- encoding=utf8 -*-
__author__ = "Administrator"
# 新增费用报销申请单(冲账),进入审批流程,有影响,需要上传一张发票,需要已付款的借款申请单,使用heying
from airtest.core.api import *
import unittest
using(r"E:\黄振旭\费用管理系统自动化测试用例\conf\common.air")
from common import common
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from airtest_selenium.proxy import WebChrome

driver = WebChrome()
driver.implicitly_wait(20)
driver.get("http://14.21.59.70:1000")
driver.maximize_window()  #放大浏览器

print("登录黄振旭账号")
common.login(driver, "huangzhenxu")
common.create_loan(driver)
print("登录夏子霞")
common.login(driver, "xiazixia")
common.pay_loan(driver)
sleep(2)
common.quit(driver)
print("登录何英账号")
common.login(driver, "huangzhenxu")
print("上传一张发票")
common.upload_invoice(driver)
driver.find_element_by_xpath(
    "//*[@id=\"app\"]/div/div/div[2]/div/div/ul/div[4]/li/ul/div/a/li/span"
).click()