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 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
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
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:/
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
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
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
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
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
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
()#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
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
. 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
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
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.