Skip to content

yanglong2/WebTestSeleniumPython

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebTestSelenium

For what

this is simple python test web use selenium framework

before using

words marking

word where use detail
test prefix Mark this is test use in file name or method
pd prefix Mark this is preconditions use in file name or method most use public
pub prefix Mark this is public use in file name or method most use public
bt prefix Mark this is backtracking use in file name or method most use public
utils suffix Mark this is tools use in file name or method
conf suffix Config and setting use in file name or method
NG log Use cases totally can not pass use in log, mark NG
NT log Use cases never even been run use in log, Maybe the preconditions are not run, or bt have a Bug, Mark NT
ND log Use cases failed to identify Bug use in log, usually mark Ok instead of Pass
Block log Use cases can not continue what executed a part of the bug use in log, usually mark Block
OK log Use cases are ok and have some bug use in log, usually mark Ok
Pass log Use cases without any bug use in log, usually mark Pass. Of course, this generally does not appear
rc log Mark this is runtime tracking use in log
anr log Mark this is application not responding use in log

Code structure

code name Except utils

must be use Three-tier structure

project name-------------------Module name      `prefix test`
    Module name----------------package name     `prefix test`
        Super use case---------code file name   `CamelCasing`
            Sub use case-------code method      `prefix test`

utils
    in Module name utils
utils file
    ordinary            `purpose_utils`
    system utils plus   `base_log` or `my_os`

How to use

install ChromeDriver

you must install driver just like ChromeDriver driver

create file

This is for team setting

You must create python file local_properties.py for conf web driver path

Contents

# coding:utf-8
__author__ = '"sinlov"'

from selenium import webdriver

path_chrome_driver_win = "C:\Users\sin-base\AppData\Local\Google\Chrome\Application\chromedriver.exe"
path_chrome_driver_osx = "/usr/bin/chromedriver"


def init_web_driver():
    return webdriver.Chrome(path_chrome_driver_win)

if use windows

You must assign your path_chrome_driver_win to your runtime path and install OS X chrome driver

path_chrome_driver_win = "your chrome driver path"

When you use other driver you can create like this

path_firefox_driver_win = "firefox path"


def init_web_driver():
    return webdriver.Firefox(path_firefox_driver_win)

if use OS X

install OS X chrome driver and change init_web_driver like this

def init_web_driver():
    return webdriver.Chrome(path_chrome_driver_osx)

config suggest

for team work init web driver just in local_properties

Use Log out with utils my_log

  • Auto put log at path {[code path]/build/out_log/}
from utils import my_log

my_log.init_log_out(True)
my_log.i('test_one', 'message')
my_log.v('test_one', 'message')
my_log.d('test_one', 'message')
my_log.w('test_one', 'message')
my_log.e('test_one', 'message')
  • You can debug like this do not write log
from utils import my_log

print my_log.i('test_one', 'message')
print my_log.v('test_one', 'message')
print my_log.d('test_one', 'message')
print my_log.w('test_one', 'message')
print my_log.e('test_one', 'message')

When Error

if Code error when import package, you can install selenium and dependencies

Mostly try to open this is page pypi. It can not be install python package which page is not open.

License

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

About

For Python Web NG Test

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%