python home automation

Learn about python home automation, we have the largest and most updated python home automation information on alibabacloud.com

Python writes the SVN update for automation

) Self.client.set_default_password (Util.decrypt_des (s Elf.password)) def update (self): try:self.init () revision = None Try: Revision = Self.client.update (Self.localpath) except:log.exception (Traceback.format_exc ( )) revision = None if not os.path.exists (Os.path.join (Self.localpath, ". SVN")): R Evision = None If revision is none or Revision[0].number = = -1:log.exception ("Into rename") Bakname = Os.path.basename (Self.localpath) + "_" + Util.format_time ()

Python+request+excel do interface Automation test (ii)

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

"Python Interface Automation" Httputils

#Coding=utf8ImportRequests fromCommon.loggerImportLoggerImportLoggingclassHttputils:logger= Logger (".. /logs/http.log", Logging.info,logging.info)defGet (self,url,params={},headers={}): Res= Requests.get (url,data=params,headers=headers) Self.logger.info ("Request Path:"+res.request.url) Headerstr="" forHeaderkeyinchres.request.headers:headerStr= Headerstr +"\ n"+ Headerkey +":"+Res.request.headers[headerkey] Self.logger.info ("Request header information:"+headerstr) Self.logger.info ("

Selenium2+python Automation 19-Radio box and check box (Radiobox, CheckBox) "Reprint"

, 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 (

Selenium2+python Automation 48-Login method (parametric) "Reprint"

= 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

Selenium+python Automation 86-chrome is being controlled by automated software

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(

"Selenium2 Python Automation Test" (8)--positioning IFRAME

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

Python Automation Development Learning 2-2

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

Selenium2+python Automation 46-js Solve the click Failure problem

# Coding:utf-8From selenium import WebdriverFrom Selenium.webdriver.common.action_chains import ActionchainsFrom Selenium.webdriver.support.select Import SelectImport timeDriver = Webdriver. Firefox ()url = "Https://www.baidu.com"Driver.get (URL)Time.sleep (3)Mouse = driver.find_element ("link text", "Settings")Actionchains (Driver). Move_to_element (mouse). Perform ()Time.sleep (3)Driver.find_element ("link text", "Search Settings"). Click ()Time.sleep (3)s = driver.find_element ("id", "NR")Sel

Python interface Automation 13-data and JSON parameters silly confused "reprint"

, 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

Python Automation Development Learning 3-2-anonymous functions, built-in functions

()) # 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

Selenium2+python Automation 12-Operating elements (keyboard and mouse events) "Reprint"

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,

Selenium2+python Automation 46-js Solve click Failure Issue "reprint"

ActionchainsFrom Selenium.webdriver.support.select Import SelectImport timeDriver = Webdriver. Firefox ()url = "Https://www.baidu.com"Driver.get (URL)Time.sleep (3)Mouse = driver.find_element ("link text", "Settings")Actionchains (Driver). Move_to_element (mouse). Perform ()Time.sleep (3)Driver.find_element ("link text", "Search Settings"). Click ()Time.sleep (3)s = driver.find_element ("id", "NR")Select (s). Select_by_visible_text ("Show 50 per page")# method One: First point the parent elemen

Selenium+python Automation 82-the figure "reprint" of only one element is truncated

seleniumImport WebdriverFrom PILImport Imagedriver= Webdriver. Chrome () Driver.get (' http://www.baidu.com/') driver.save_screenshot (' Button.png ') element= driver.find_element_by_id ("Su")Print (element.location)# print Element coordinatesPrint (element.size)# print element size left = element.location[= element.location[ Y ']right = element.location[ ' x '] + Element.size[ ' width ']bottom = Element.location[ ' y '] + element.size[ ' height ']im = image. Open ( ' button.png ') im = im.cro

Selenium2+python Automation 62-jenkins Continuous Integration Environment Construction "reprint"

, 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

Python Automation Development Learning 12-federated unique

; );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

Python Automation development

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

20171211-python Automation-Interface Test-postman-psot-JSON parameters

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

20171213-python Automation-Interface test-jmeter-post-login

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

20171213-python Automation-Interface test-jmeter-post-add-stu

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

Total Pages: 15 1 .... 11 12 13 14 15 Go to: Go

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.