예제 #1
0
from selenium import webdriver
import time
from Verify_Code import chaojiying
import unittest
from PIL import Image
import ddt
from LogCommon import logger
logger = logger.mylog("log").getlog()
cjy = chaojiying.Chaojiying_Client('xhj123456', 'qazwsx123', '899485')


@ddt.ddt
class Logintest(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome(
            r"C:\Users\admin\AppData\Local\Programs\Python\Python36\Scripts\chromedriver.exe"
        )
        self.driver.get("http://192.168.2.200:8081/login")

    @ddt.file_data(
        r"E:\Users\Administrator\PycharmProjects\untitled\YGGH\TestCase\TestData\LoginData.json"
    )
    def test_case(self, value):
        filename = "image.png"
        self.driver.save_screenshot(filename)
        ele = self.driver.find_element_by_xpath(
            '''//*[@id="form"]/ul[3]/li[3]/img''')
        left = ele.location['x']
        top = ele.location['y']
        right = ele.location['x'] + ele.size['width']
        bottom = ele.location['y'] + ele.size['height']
예제 #2
0
from selenium import webdriver
from LogCommon import logger
from verify_code import VerfyCode
from PIL import Image
from selenium.common.exceptions import NoSuchElementException
import traceback
import ddt
import unittest
import time
logger = logger.mylog('CaseLog').getlog()
VerCode = VerfyCode.Chaojiying_Client('xhj123456', 'qazwsx123', '899485')


@ddt.ddt
class TrueLogin(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome(
            r"C:\Users\admin\AppData\Local\Programs\Python\Python36\Scripts\chromedriver.exe"
        )
        self.driver.get("http://192.168.2.200:8081/login")

    @ddt.file_data(r"G:\Myproject\TestCase\LoginModule\LoginData.json")
    def test_case(self, logindata):
        logger.info("正确账号进行登录用例")
        filename = "ScreemshotVerfycode.png"
        self.driver.save_screenshot(filename)
        ele = self.driver.find_element_by_xpath(
            '''//*[@id="form"]/ul[3]/li[3]/img''')
        left = ele.location["x"]
        top = ele.location["y"]
        print(ele.location)
예제 #3
0
import time
import unittest

import pymysql
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait

from LogCommon import logger
from LoginMode import Login

logger = logger.mylog("CaseLog").getlog()
db = pymysql.connect("192.168.2.200", "root", "hexinpass001", "welfare")
cursor = db.cursor()


class AddEmployeeCase(unittest.TestCase):
    driver = Login.EmployeeLogin().Login()

    def test_case(self):
        logger.info("用户导入用例")
        self.driver.implicitly_wait(10)
        try:
            self.driver.find_element_by_xpath(
                '''/html/body/div[2]/div[2]/ul/li/a''').click()
            self.driver.find_element_by_xpath(
                '''//*[@id="tab"]/li[3]/a''').click()
            self.driver.find_element_by_xpath(
                '''//*[@id="tab"]/li[3]/ul/li[2]/a''').click()
            self.driver.switch_to.frame("content")
예제 #4
0
from selenium import webdriver
import unittest, time
from LogCommon import logger
import traceback
import ddt
import HTMLTestRunner
import os
from selenium.common.exceptions import NoSuchElementException
logger = logger.mylog('test').getlog()


@ddt.ddt
class TestData(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome(
            r"C:\Users\admin\AppData\Local\Programs\Python\Python36\Scripts\chromedriver.exe"
        )
        self.driver.get("http://www.baidu.com")

    @ddt.file_data("test_dade_list.json")
    def test_case01(self, value):
        print(value)
        testdata, expectdata = tuple(value.strip().split("||"))
        self.driver.implicitly_wait(10)
        try:
            self.driver.find_element_by_id("kw").send_keys(testdata)
            self.driver.find_element_by_id("u").click()
            time.sleep(2)
            self.assertIn(expectdata, self.driver.page_source)

        except NoSuchElementException as e:
import ExcelUtill
from LogCommon import logger
from LoginCommon import LoginL
import traceback
import unittest
from selenium.common.exceptions import NoSuchElementException
import ddt
import time
Data = ExcelUtill.ParaExcel(r"G:\addemployee.xlsx", "Sheet1")
logger = logger.mylog("test").getlog()


@ddt.ddt
class AddemployyeExcel(unittest.TestCase):
    def setUp(self):
        self.driver = LoginL.LoginMode().LoginT()

    @ddt.data(*Data.getDataFromSheet())
    def test_case(self, data):
        name, jobnumber, phone = tuple(data)
        self.driver.implicitly_wait(10)
        try:
            self.driver.switch_to.frame("content")
            self.driver.find_element_by_xpath(
                '''//*[@id="TheSix"]/div[2]/img''').click()
            time.sleep(1)
            self.driver.find_element_by_xpath(
                '''//*[@id="list"]/div[1]/button[1]''').click()
            self.driver.find_element_by_xpath(
                '''//*[@id="username"]''').send_keys(name)
            self.driver.find_element_by_xpath(