python home automation

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

Use Python to capture the CSS template of the template home-Python tutorial

This article describes how to use Python to capture the CSS template of the template House and package the code into a zip file. it uses a single thread and is very simple and practical. here we will share it with you, for more information, see. The Python version is 2.7.9. if it is successfully tested on win8, it is a little slow to capture. if you want to use multiple threads, you have to wait. The url pa

An Internet background automation combination test Framework Rf+sikuli+python script

An Internet background automation combination test Framework Rf+sikuli+python scripthttp://www.jianshu.com/p/b3e204c8651awords 949 Read 323 comments 1 likes 0 First, * * Robotframework 1. * * Tool Description:Robotframework is used as a platform for organizing test cases and BDD keywords in tests, primarily managed using ride, which is not a tool, but just a framework that is developed using

Selenium2+python Automation 39-Questions about the interview "reprint"

ObjectiveRecently saw a group of small partners posted a set of interview questions, and recently job-hopping gold season, small series can not help but take a little time to summarize the next, the answer is not appropriate place to welcome you master Pat Brick pointing. How do I determine if an element exists in selenium? First of all, there is no such method in selenium, judging elements exist to write a method of their own. Elements exist in several forms, one is that the page has more than

Python writes the Read and write of an Automation INI file

consistent with the read interface, we use Key,value way to writeThe code is as follows:def writeconfig (Configpath, key, value): if Key.find (".") = =-1: return wsession = Key.split (".") [0] Woption = Key.split (".") [1] CF = Configparser.configparser () cf.read (Configpath) cf.set (wsession, woption, value) cf.write (open ( Configpath, "W"))This allows you to modify the INI file in python ~Reprint Please specify: Http:/

Python automation four--json module use, set operation, function

Content: JSON module Collection operations Function One, the JSON moduleJSON (JavaScript Object Notation) is a lightweight data interchange format. It is based on a subset of ECMAScript.The JSON module can be used to encode JSON data in Python3, which contains two functions: json.dump (): encodes the data. json.load (): decodes the data. JSON format Storage--small exampleimport jsonstu_info = { ‘laowang‘:{ ‘cars‘:[‘BMW‘,‘Ben-z‘] } }stu_str = json.dumps(s

Python writes automation to write a Windows service

) Logger.setlevel (loggin G.info) return logger def svcdorun (self): Import time Self.logger.error ("Svc do run ...") While Self.isAlive:self.logger.error ("I am alive.") Time.sleep (1) def svcstop (self): Self.logger.error ("Svc does stop ...") self. Reportservicestatus (Win32service. service_stop_pending) #设置事件 win32event. SetEvent (self.hwaitstop) self.isalive = falseif __name__ = = ' __main__ ': Win32serviceutil. Handlecommandline (Pythonservice)after the program is written

Python writes the MD5 value of a file for automation

Using Python to get the MD5 value of a file is a simple thing, Python provides the MD5 and hashlib two modules, you can get the MD5 value of the file.The code is as follows:#获取文件的MD5值, for small file def getFileMD5 (self,filepath): if Self.isfile (filepath): f = open (filepath, ' RB ') md5obj = hashlib.md5 () md5obj.update (F.read ()) hash = md5obj.hexdi

Selenium2+python Automation 2-element positioning

have an ID, name, class attribute, or hyperlink, do it? Or it's a lot of properties that are duplicated. It can be resolved by XPath at this time.2.xpath is a path language, unlike the above positioning principle, the first step is to learn to use the tool to view the XPath of an element.3. Follow the steps to copy the corresponding XPath address in the Friepath pluginElement positioning:find_element_by_css_selector ()1.css is another syntax, more concise than XPath, performance is better, but

Python+requests Interface Automation complete project design Source

(Message)elif level = = ' ERROR ':Self.logger.error (Message)# These two lines of code are designed to avoid duplicate log output problemsSelf.logger.removeHandler (CH)Self.logger.removeHandler (FH)# Close Open filesFh.close ()def debug (self, message):Self.__console (' Debug ', message)def info (self, message):Self.__console (' info ', message)Def warning (self, message):Self.__console (' warning ', message)def error (self, message):Self.__console (' ERROR ', message)if __name__ = = "__main__"

Appium+python Automation 29-toast

', ' DeviceName ': ' 127.0.0.1:62001 ', ' platformversion ': ' 4.4.2 ', ' apppackage ': ' Com.b Aidu.yuedu ', ' appactivity ': ' com.baidu.yuedu.splash.SplashActivity ', ' noreset ': ' true ', ' Automationname ': ' Uiautomator2 '}def is_toast_exist (driver,text,timeout=30,poll_frequency=0.5): "Is toast exist, return True or False:agrs:-Driver-driver-text-text content seen on page-timeout-Max Super Time, default 30s-poll_frequency-interval query time, default 0.5s query once:

Selenium+python Automation 96-Execution of the jquery report: $ is not defined

not a problem, directly on the browser to execute, but also to perform successfully. Results various attempts jquery Different click Method, finally cannot solve. Later changed to JS Grammar is done.Encounter problems1. When executing the jquery script, error: Selenium.common.exceptions.WebDriverException:Message:unknown Error: $ is not defined 2. Some of the following methods have been tried in the future without effect: Sleep time is a bit longer, so the page is loaded

Aspen Plus Automation in Python

Aspen Plus Automation Code in Python.ap=Aspenplus () ap.open_case (R'pfdtut.bkp') ap.visible=1Print (Ap.print_streams ())print(ap.print_blocks ())# ap.run () Print("done")Test Code#type ' pip install Pypiwin32 ' to install if missingImportwin32com.clientclassAspenplus (object):" "Author:bshaoo" " def __init__(self,version=None):" "Constructor" " if notbool (version): Self.__ihapp= Win32com.client.Dispatch ('apwn.document') Else:

Python write automation http file download

file download, you need to add some action during the file download processdef downloadfilebyproxy (URL, Savepath, host, port, user, PWD): try: url = url.strip () Savepath = Savepat H.strip () Initpath (savepath) #如果代理需要验证 proxy_info = {' Host ': Host, ' Port ': Int (port), ' user ': User, ' pass ': pwd } proxy_support = Urllib2. Proxyhandler ({"http": "http://% (user)

Selenium2+python Automation-Processing Browser popup (reprint)

property, you can set how the element is displayed,The detailed explanation can refer to http://www.w3school.com.cn/jsref/prop_style_display.asp. Setting the display value to none will remove the pop-up window:js = ‘document.getElementById("doyoo_monitor").style.display="none";‘The complete code is as follows:# encoding:utf-8from selenium import webdriverimport timedriver = webdriver.Firefox()driver.get("http://sh.xsjedu.org/")time.sleep(1)js = ‘document.getElementById("doyoo_monitor").style.di

Selenium2+python Automation 57-catch Exception (nosuchelementexception)

are an XPathexpression and it is either syntactically invalid (i.e. it's not aXPath expression) or the expression does not select WebElements(e.g. "Count (//input)")."""PassClass Imenotavailableexception (webdriverexception):"""Thrown when the IME is not available. This exception are thrown for every ime-relatedMethod call if IME support is not available on the machine."""PassClass Imeactivationfailedexception (webdriverexception):"""Thrown when activating a IME engine has failed."""PassThe stu

Python Automation fifth session

()#product_dic = json.loads (res) #把json串, the data type that becomes Python#Print (Json.load (f)) #传一个文件对象 It will help you read the fileD = { 'Zll':{ 'Addr':'Beijing', ' Age': 28 }, 'LJJ':{ 'Addr':'Beijing', ' Age': 38}}FW= Open ('User_info.json','W', encoding='Utf-8')#Dic_json = json.dumps (d,ensure_ascii=false,indent=4) #字典转成json, the dictionary turns into a string#fw.write (Dic_json)Json.dump (d,fw,ensure_as

Selenium2+python Automation 71-switching between multiple browsers "reprint"

(browser= ' Firefox '):‘‘‘Open Browser "Firefox", "Chrome", "ie", "PHANTOMJS"UsageDriver = Broswer ("Chrome")‘‘‘Tryif browser = = "Firefox":Driver = Webdriver. Firefox ()Return driverelif Browser = = "Chrome":Driver = Webdriver. Chrome ()Return driverelif Browser = = "ie":Driver = Webdriver. Ie ()Return driverelif Browser = = "Phantomjs":Driver = Webdriver. PHANTOMJS ()Return driverElsePrint ("Not found browser! You can enter ' Firefox ', ' Chrome ', ' ie ' or ' phantomjs ')Except Exception as

Selenium2+python Automation 13-Multiple windows, handles (handle)

required calibration in the list queue R2.for loop Traversal performs each button's Click action3. The result of the decision corresponds to each result in the listVii. Final Script1. After finishing the final script as follows, the result# Coding:utf-8From selenium import WebdriverImport timeDriver = Webdriver. Firefox ()Driver.get ("http://news.baidu.com/")Driver.implicitly_wait (10)# Gets the current window handleH = Driver.current_window_handle# Locate Web pages, paste bars and other linkss

Python interface Automation 4-Bypass Verification code login (cookie)

. Then add the login cookie and fill in the first step fiddler the captured content.c = Requests.cookies.RequestsCookieJar () c.set ('. Cnblogscookie ', ' xxx ') c.set ('. Cnblogs.AspNetCore.Cookies ', ' xxx ') s.cookies.update (c) print (s.cookies)Iv. Reference Code1. Since the login time is more than 2 cookies, we can first use the Get method to open the login home page, to obtain some cookies2. Add the cookie that you want to log in to the session3

Python interface Automation 4-Bypass Verification code login (cookie) "Reprint"

From the blog: Shanghai-leisurelyOriginal address: http://www.cnblogs.com/yoyoketang/tag/python%E6%8E%A5%E5%8F%A3%E8%87%AA%E5%8A%A8%E5%8C%96/ObjectiveSome login interface will have verification code: SMS Verification Code, graphics verification Code, and so on, this kind of login verification code parameters can be obtained from the background (or check the database most directly).It doesn't matter if you get it, you can bypass the captcha by adding a

Total Pages: 15 1 .... 7 8 9 10 11 .... 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.