Today the next Python writes the interface test case with request, makes a rough approximate execution, and needs to find time to optimize. This takes an object, configuration, and common function as a class, and executes the test case for another class.The test case is written roughly as follows (and needs to be beautified):1. Write Test CasesHere, you use Pyunit to read the test cases in Excel and execute# Coding=utf-8From OPENPYXL import Load_workb
, reference code:# Coding:utf-8From selenium import WebdriverDriver = Webdriver. Firefox ()Driver.get ("file:///C:/Users/Gloria/Desktop/checkbox.html")# to determine the status of the option box before clicking the actions = driver.find_element_by_id ("Boy"). is_selected ()Print SDRIVER.FIND_ELEMENT_BY_ID ("Boy"). Click ()# Click to determine if the element is selectedr = driver.find_element_by_id ("Boy"). is_selected ()Print R# check box single selectionDRIVER.FIND_ELEMENT_BY_ID ("C1"). Click (
= Self.is_login_sucess ()Self.asserttrue (Result)def test_02 (self):U "Login Case Reference: Account number, password set"Self.login (U "Shanghai-Yo", U "xxxx") # Invoke Login method# judgment Result # QQ Group: 232607095result = Self.is_login_sucess ()Self.asserttrue (Result)# def test_01 (self):# u "Login Case reference: Account, password Set" "# self.login (u "Shanghai-Yo", U "xxxx") # Call the login method# # Get the account name after login# text = self.driver.find_element_by_id ("Lnk_curr
Problems occurred1. Launch browser with Selenium ' chrome is under control of automatic software '2. If you do not want to see this annoying hint, start the browser by adding a configuration on the lineDisable-infobars1. In the browser configuration add a parameter, ignore this warning prompt
option = Webdriver. Chromeoptions ()Option.add_argument (' Disable-infobars ')
Reference Code# coding:utf-8from selenium import webdriver# 加启动配置option = webdriver.ChromeOptions()option.add_argument(
page will display the corresponding location:We see the IFRAME, then put the mouse over the IFRAME and right-click the copy XPath:This allows us to navigate to the location of the IFRAME.Positioning to the next, we want to transfer to the IFRAME, Pycharm hint method is Switch_to_frame (), but this method is outdated, if you use this method, Pycharm will underline you, the latest method is Switch_to.frame ( ), the pass parameter is the location of the IFRAME is the code in the black sentence:dri
fileOpen () opens the file. Windows system defaults to GBK encoding, and if you do not specify a character encoding, the file is opened using the system's default character encoding. For example, Python will use GBK encoding to read the Utf-8 file, after the operation will be error or read garbled.Our approach now is to use the UTF-8 encoding format for all files. When open, do not omit this parameter, directly specify the character encoding of Utf-8
, this data in the WebForms inside the view3. You can see that this parameter is displayed in the body section, the name on the left is the key value, and the value on the right is the corresponding value value, like this parameter conversion from the Python dictionary format is OK4. This type of post when the data parameter can be transmitted, the format is as follows:s = requests.session ()r = S.post (URL, headers=headers, Data=d) # Here's D is the
()) # This position prints the global variable print (globals ()) # printed or global variableMap (), which maps the specified object according to the provided functionA = map (lambda x:x**2,[1,2,3,4,5]) # Each element in the list is computed with a lambda method for print (list (a))Max () and Min (), returns the maximum and minimum valuesPrint (max) # can be several variable print (min ([+)]) # or it can be a listMemoryview () that returns the memory view object for the given object (Momory vi
be imported first: from Selenium.webdriver.common.keys import keys3. Analog ENTER key, can be used Send_keys (Keys.enter)4. Other common keyboard operations:Keyboard F1 to F12:send_keys (KEYS.F1) to change the F1 to corresponding shortcut keysCopy Ctrl+c:send_keys (Keys.control, ' C ')Paste Ctrl+v:send_keys (Keys.control, ' V ')Select All Ctrl+a:send_keys (Keys.control, ' A ')Cut Ctrl+x:send_keys (Keys.control, ' X ')TAB key Tab:send_keys (Keys.tab)Here is just a list of some common, of course,
, in the browser's address bar type: http://localhost:8080/. then enter. Enter the following screen. This means that Tomcat is installed correctlyIv. Environment of JeninsThe 1.Jenkins package is divided into two types:One is the Setup.exe client package (this double-click with QQ, do not say)One is a war package2.war bag put under WebApps3. Start JenkinsRestart Tomcat:startup.bat First, then enter http://localhost:8080/jenkins/in the browserV. Configuring Jenkins1. Create a new job2. Enter the
; );Using the SQLAlchemy operationThe Union only needs to import additional modules and UniqueConstraint then use a variable __table_args__ to hold the union unique that you want to declare. In addition, if you want to declare the index, it is in this variable. The type of the variable is ganso.from sqlalchemy import create_enginefrom sqlalchemy.ext.declarative import declarative_basefrom sqlalchemy import Column, Integer, String, CHARfrom sqlalchemy.dialects.mysql import INTEGER, TINYINTfrom sq
First article: Basics of getting started with PythonArticle two: Python data typesChapter Three: Functional ProgrammingFourth: Generators, iterators, adornersFifth article: Common modulesSixth article: Face objectseventh: The face object into the levelEighth article: Socket network programmingnineth article: Process and ThreadTenth article: Asynchronous IO, Message Queuing11th article: Message Queuing, caching12th article: Database Operations13th arti
Interface 3: Adding student informationBrief description: Add student information, enter parameter is JSON typeRequest Url:http://api.nnzhp.cn/api/user/add_stuRequest mode: Post, parameter is JSON type
Name of parameter
Must-Choose
Type
Description
Name
Y
String
Student Name
Grade
Y
String
Class
Phone
Y
Int
Phone
Sex
N
String
Sex, do not pass the
Interface 2: LoginRequest Method: PostRequest URL:http://api.nnzhp.cn/api/user/login1. Open JMeter, right click on test Plan, select Add-threads-thread Group2, click on Thread Group, right-add sampler-http request3,http Request page, server name or IP field input: api.nnzhp.cn; mode selection Psot; path input:/api/user/loginClick Parameters, click the Add button, name Input: Username value input: xxx;passwd value input: XXX4, click on Thread Group, right-add listener-View results tree, click the
Interface 3: Adding student informationBrief description: Practice passing JSON type parametersRequest URL:http://api.nnzhp.cn/api/user/add_stuRequest Method: Post1. Open JMeter, right click on test Plan, select Add-threads-thread Group2, click on Thread Group, right-add sampler-http request3,http Request page, server name or IP field input: api.nnzhp.cn; method select Post; path input:/api/user/add_stuClick Body Data to enter the JSON parameter{"Name": "Aodi","Grade": "Tianxie","Phone": "188111
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.