web自動化css
--html頁面的編寫與介紹html
--web元素的定位ios
--自動化腳本web
一.一個簡單的登陸頁面chrome
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>主機後臺管理</title> <link rel="stylesheet" type="text/css" href="/static/style.css" /> <link href='http://fonts.googleapis.com/css?family=Belgrano' rel='stylesheet' type='text/css'> </head> <body> <div id="loginpanelwrap"> <div class="loginheader"> <div class="logintitle"><a href="#">歡迎登錄</a></div> </div> <form action="/host_app/login/" method="post"> <div class="loginform"> <div class="loginform_row"> <label>帳號:</label> <input type="text" class="loginform_input" name="username" /> </div> <div class="loginform_row"> <label>密碼:</label> <input type="text" class="loginform_input" name="password" /> </div> <div class="loginform_row"> <span style="color: red " >{{ error }}</span> <input type="submit" class="loginform_submit" value="登陸" /> </div> <div class="clear"></div> </div> </form> </div> </body> </html>
主要的頁面操做都寫<body>標籤中,因此先關注body標籤中的元素。(css/script)api
二.自動化腳本知識點:瀏覽器
1.關於chrome瀏覽器的解除限制:app
options = webdriver.ChromeOptions()
options.add_argument('disable-infobars')
browser = webdriver.Chrome('/Users/bernie/Documents/chromedriver',chrome_options=options)
2.瀏覽器最大化;
(mac下chrome)
options.add_argument('--kiosk')
其餘
For MAC or Linux: ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments("--kiosk"); driver = new ChromeDriver(chromeOptions); For Windows: ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments("--start-maximized"); driver = new ChromeDriver(chromeOptions); ChromeOptions options = new ChromeOptions(); options.addArguments("--start-fullscreen");
3.關於alert彈窗的關閉post
import selenium.webdriver.common.alert
webdriver.common.alert.Alert(browser).accept()
4.關於excel處理
import xlrd,xlwt
workbook = xlwt.Workbook(encoding='ascii')
worksheet = workbook.add_sheet('My Worksheet')
testCaseFile = os.path.join(os.getcwd(), testCaseFile) if not os.path.exists(testCaseFile): logging.error('ceshiyongliwenjianbucunzai') sys.exit() testCase = xlrd.open_workbook(testCaseFile) table = testCase.sheet_by_index(0) for i in range(1, table.nrows): if table.cell(i, 7).value.replace('\n', '').replace('\r', '') == 'Yes': continue a1 = table.cell(i, 0).value.replace('\n', '').replace('\r', '') # 逐行獲取手機號信息推薦博客:https://www.cnblogs.com/fnng/p/4540731.html