python home automation

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

Appium+python Automation 24-Slide method package (swipe) "reprint"

=500N=1):' Swipe up on the screen ' L= Driver.get_window_size () x1= l[' Width ']*0.5# x-coordinate Y1= l[' Height ']*0.75# start y-coordinate y2= l[' Height ']*0.25# end point Y coordinateFor IInchRange (N): Driver.swipe (x1, y1, x1, y2, t)Def Swipedown(Driver, T=500N=1):"' swipe down on the screen ' L= Driver.get_window_size () x1= l[' Width ']*0.5# x-coordinate Y1= l[' Height ']*0.25# start y-coordinate y2= l[' Height ']*0.75# end point Y coordinateFor IInchRange (N): Driver.swipe (x1, y1, x1

Appium+python Automation 27-waiting for activity to appear (Android-specific wait_activity)

webdriverfrom time import sleepdesired_caps = { 'platformName': 'Android', 'deviceName': '127.0.0.1:62001', 'platformVersion': '4.4.2', 'appPackage': 'com.baidu.yuedu', 'appActivity': 'com.baidu.yuedu.splash.SplashActivity' }driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)# sleep(10) # 不用sleep# 获取当前界面activityac = driver.current_activityprint(ac)# 等主页面activity出现,30秒内driver.wait_activ

Appium+python Automation 41-switching WebView when Chromedriver version issue is reported

Chrome browser: chrome://inspect/#devicesThen open the public number page, refresh the browser page, will appear webview version number 57.0chromedrive Download1. Find WebView's Chrome version number, then download the corresponding Chromedriver driver package, 57 of the webview corresponding to the 2.28 driver: Chromedriver version downloadWhere should I put it after 2.chromedriver download? First find out where the chromedriver=2.30.477700 version of the error is from, replace it. Find path:

Appium+python Automation 45-nox Problem Solving

ANDROID-SDK, cmd open input adb, "Android Debug Bridge version 1.0.39" shows that the current ADB version is 1.0.39, which is referred to as version 39 adb 2. Check the ADB version number of the Night God Simulator (NOx) to find the installation path: \nox\bin, there is a nox_adb.exe, in fact, is adb.exe, in order to avoid conflict in the NOx change a name. Enter CMD in the upper-left corner of the address bar3. Then in the CMD reference input nox_adb, you can see the NOx inside t

Python Interface Automation Test (vi)-unittest-single use case management

The first five sections mainly introduce the environment construction and the use of the requests library, which can be used to send the interface request. But how to manage the interface case? Returns how the results are automatically verified? This is not possible with the above five sections, so from this section we have introduced the Python Unit Test framework unittest, which handles batch use case management, verifying return results, initializa

Appium+python Mobile Automation Test (iii)--demo

Write in front: Appium environment is set up, Genymotion Simulator is also configured OK, then began to write the first demo First, get the APK package name Open cmd, enter the instruction AAPT dump badging D:\test\xxx.apk (full name of the APK, such as magic Diffuse camera apk). If the package name is obtained through Appium, it may not be accurate. Package Name: com.manboker.headportrait Ii. acquisition of Launcheractivity Take the previous step, and th

Python Automation Development-[19th day]-pagination, cookie,session

', ' Port ', ' bs__name ') #正向查找bs的名字 for row in objs:row[0]row[1] Model operation-CREATE TABLE: User table (ID, user,pwd,email,mm) line of business (ID, name) # User table _set Host table (ID host port BS) user line of Business relationship table (ID UID Bid) ****** 1 1 2 11-obj = modes.userinfo.objects.filter (user= ' Japanese elder brother '). First () Obj.mm.add (1) obj.mm.add (11) # Japanese brother responsible for the Line of business (line of Business objects), line of business object,

Selenium Python Automation note modify the link and open it based on the response property of the XPath find location

# Coding=utf-8Import timeImport UnitTestFrom Framework.browser_engine import BrowserengineFrom Pageobjects.bird_homepage Import homepageClass Baidusearch (UnitTest. TestCase):@classmethoddef setupclass (CLS): Browse = Browserengine (CLS)Cls.driver = Browse.open_browser (CLS)@classmethoddef teardownclass (CLS): Cls.driver.quit ()def test_baidu_search (self): Homepage = homepage (self.driver)Homepage.type_search (' xx ', ' xxx ')# HOMEPAGE.SEND_SUBMIT_BTN ()Self.driver.find_

Python interface Automation Test 23: File Upload

(Os.path.dirname (Os.path.realpath (__file__))) # Locate the current folderJpgpath = Os.path.join (Parpath, ' testdata ', ' 1.jpg ') # "TestData": the folder name where the file is stored, "1.jpg": File nameClass Testsendfile (UnitTest. TestCase):@classmethoddef setupclass (CLS):CLS.S = Requests.session ()# Instantiate the called ClassCls.login = Loginzentao (CLS.S) # Instantiate class Loginzentao as ObjectCls.send = SendFile (CLS.S) # Instantiate the Class SendFile () as an objectdef test_01 (

Python interface Automation Test 12: A simple operation on the returned JSON

# 1, requests inside with parser to dictionaryPrint(r.json())Print(type(R.json()))# Remove the ' result_sk_temp ' field from the JSON# {"ResultCode": "$", "Reason": "Query succeeded", "result": {"SK": {"temp": "" "," Wind_direction ":" Southeast Wind "," wind_strength ":" Level 2 "R.json()["Result"] [' SK '] [' temp ']Print(result)# 2, JSON module to dictionaryJsonPrint(json.loads(r.text# JSON-formatted STR turn dictPrint(type(json.loads(r.text)))# View What is returned, is the dictionary format

Python interface automation 11-post data parameter case

"user-agent":"mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) gecko/20100101 firefox/44.0"8}#Get method Add a ser-agent to it.9D = {" from":"",Ten "J_password":"f7bcd85ebab14e2fbb6d76cc99bc5c6a", One "J_username":"Admin", A "Jenkins-crumb":"e677c237181756818cbbccd4296d44f1", - "JSON": {"J_username":"Admin", - "J_password":"f7bcd85ebab14e2fbb6d76cc99bc5c6a", the "Remember_me": True, - " from":"", - "Jenkins-cru

Cloud computing Python Automation: Operators and expressions

output result 2%: Modulo-Returns the remainder of the division.Example: b% A output result 0* *: Power-Returns the Y power of X.For example: A**b is 10 of the 20-time side, the output result 100000000000000000000: Take division-Returns the integer part of the quotientFor example: 9//2 output result 4, 9.0//2.0 output 4.0Attention: >> 5/2//No decimal place when the division operation gets an integer 2 >> 5.0/2 2.5Compare (relational) operators:The following assumes th

Selenium+python Automation 88-sending mail when a use case does not pass

": - Wuyi Print("QQ Exchange Group: 226296743") the - Print(Is_result_pass ()) Wu -```Operation Result:```The test process has not passed the use case: Pass 2 Failure 1 Error 1False```2. Add a judgment before the last email```1 if notIs_result_pass ():2 3 #determine if the HTML report has an error4 5 6 7 #execute the Send mail function, write your own e-mail function8 9 #send_mail (sender, PSW, receiver, Smtp_server, Report_file)Ten One A -

Selenium2+python Automation 63-two times package (Click/send_kesy)

fromSelenium.webdriver.support.uiImportwebdriverwaitclassYoyo (object):"""Two packages were made based on the native selenium framework.""" def __init__(self):"""Start browser parameterization and start Firefox by default."""Self.driver=Webdriver. Firefox ()defget (self, url):" "To open a URL by using get" "self.driver.get (URL)defFind_element (self, locator, timeout=10): " "positioning element Method encapsulation" "element= webdriverwait (Self.driver, timeout, 1). Until (ec.presence

Selenium2+python Automation 15-select drop-down box

import ActionchainsFrom Selenium.webdriver.support.select Import SelectDriver = Webdriver. Firefox ()url = "Https://www.baidu.com"Driver.get (URL)Driver.implicitly_wait (20)# Mouse moves to "settings" buttonMouse = Driver.find_element_by_link_text ("Settings")Actionchains (Driver). Move_to_element (mouse). Perform ()Driver.find_element_by_link_text ("Search Settings"). Click ()# through Text:select_by_visible_text ()s = driver.find_element_by_id ("NR")Select (s). Select_by_visible_text ("Show 5

Selenium2+python Automation 10-Login Case

()Driver.quit ()Four, login function1. Although the code above can be logged in, the entire code is no more readable than the journal. If I want to change account login, this time also have to find the login account and password location, relatively time-consuming.2. We can write two functions for login and exit, so it looks more comfortable.3. parameterize the login account and password# Coding:utf-8From selenium import WebdriverImport timedef login (driver, user, password):"Login to GitHub"#

Selenium2+python Automation 36-Judging the existence of elements

exceptions1. If no element is found, throw an exception, return false2. Return Ture If the element is found3. However, this method has a disadvantage, if there are more than one element on the page, it will also return ture (that is, as long as there are elements on the page to return ture, no matter how many)Iv. Reference Code# Coding:utf-8From selenium import WebdriverDriver = Webdriver. Firefox ()Driver.implicitly_wait (10)Driver.get ("http://www.baidu.com")def is_element_exist (CSS):s = Dri

Selenium2+python Automation 44-element positioning parameterization (find_element)

"By_link_text = "link text"By_partial_text = "Partial link text"By_name = "Name"By_tag_name = "tag name"By_class_name = "Class name"By_css_selector = "CSS selector"V. Reference code# Coding:utf-8From selenium import WebdriverFrom selenium.webdriver.common.by Import byDriver = Webdriver. Firefox ()Driver.get ("https://www.baidu.com/")Driver.find_element ("id", "kw"). Send_keys ("Yoyoketang")Driver.find_element (' CSS selector ', ' #su '). Click ()# Other positioning Reference QQ Group: 232607095#

Python Automation Development Learning-restful API

the httprespon, which directly allows the dictionary to be serialized and returned to the front end.>>> from django.http import JsonResponse>>> response = JsonResponse({‘foo‘: ‘bar‘})>>> response.content‘{"foo": "bar"}‘The default is to pass in only one dictionary, and the data that the API returns should be a dictionary. However, if you must serialize a different type, such as a list, you can set the safe parameter:>>> response = JsonResponse([1, 2, 3], safe=False)If you want to customize the

Python Interface Automation test (vi) Using UNITTEST batch use case management

, Automatically searches CAs in the specified directory, constructs the test set, executes the order of names: Executes the Test_add first, then executes test_sub discover = Unittest.defaultTestLoader.discover (test_ Dir, pattern= ' test_*.py ') # instantiates Texttestrunner class runner = UnitTest. Texttestrunner () # Run the test suite with the Run () method (that is, run all the use cases in the test suite) Runner.run (Discover)The above only solves the problem of how to manage

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.