This article mainly introduces the Python+selenium+autoit implementation of File upload function, the need for friends can refer to the following
Problem
When doing web-side UI layer Automation will encounter file upload operation, often a friend asked, here to summarize
Solution Solutions
The first type: type=file upload file, similar to the following
You can do this with code like this:
Driver.find_ele
Only contact with the Mac, the following is the online search for information on my computer to install the successful process, as far as possible to attach the original address.1.selenium Installationhttps://www.zhihu.com/question/30496889Many tutorials on the web are similar to this, 1.1 download pip "Python installation package management tool"https://pypi.org
Study Address: http://blog.csdn.net/vinson0526/article/details/51850929seleniumwhen using, we may need to chrome do some special settings to complete the browser behavior we expect, such as 阻止图片加载 , and 阻止JavaScript执行 other actions. These need selenium ChromeOptions to help us completeWhat is Chromeoptionschromeoptionsis a convenient chrome class for controlling the properties at startup. Through selenium t
infobox value. At the same time, if there is a coding problem "' ASCII ' codec can ' t encode characters" you can set the compiler Utf-8 encoding by following the code as follows:# set the encoding utf-8 Import sys Reload (SYS) sys.setdefaultencoding ('utf-8')# Show current default encoding print sys.getdefaultencoding ()Corresponding source codeThe corresponding Baidu Encyclopedia infobox source code, such as the basic knowledge of the code can refer to my previous blog post or my
use case. It looks very big on the writing, but ... Running a class is hard to succeed, but we can refer to the structure it writes, which is the standard structure that we will write about later.Interested friends can look into this tool.(ii) Selenium BuilderIt is also a plugin for Firefox:Starting modeAfter the right mouse button is installedClick to open:UseLike the Selenium IDE, the browser is on the p
Here's the book.
Selenium is a set of tools for automating browsers
Selenium Ide:this is a Firefox add-in used to record and play back the Selenium scripts with Firefox.
Selenium Webdriver:this is a programming interface for developing advanced Selenium scripts using
#!/usr/bin/python#-*-Coding:utf-8-*-__author__ = ' Zuoanvip '#一般用到操作滚动条的两个场景#注册时的法律条文的阅读, determine whether the user is reading the finished standard is: Scroll bar is pulled to the bottom#要操作的页面元素不在视觉范围, you cannot operate, you need to drag the scroll bar#用于标识滚动条位置的代码##From selenium import WebdriverImport timeDriver = Webdriver. Firefox ()#访问百度Driver.get (' http://www.baidu.com ')#搜索
compatibility.2. First use Driver.name to get the browser name, and then use the IF statement to make a judgmentVII. Compatibility1. Compatible with Google and firefox/ie?
1
八、参考代码如下:#Coding:utf-8 fromSeleniumImportWebdriverdriver=Webdriver. Firefox () Driver.get ("https://www.baidu.com")PrintDriver.name#back to topdefscroll_top ():ifDriver.name = ="Chrome": JS="var q=document.body.scrolltop=0"Else: JS="var q=document.documentelement.scrolltop=0"returndriver.exe
Open the command line tool, and in Doc, enter:4567Then access http://localhost:4567/in the browser, and you should see all the modules in Python nowPress Ctrl+f, enter selenium, locate the link to the selenium document, and then click Enter to Http://localhost:4567/selenium.htmlThis is where the selenium document is lo
an element is still in the DOM, Incoming WebelEment object, you can determine whether the page is refreshed staleness_of
Above all 17 condition, with until, until_not combination can achieve a lot of judgments, if you can flexibly package, will greatly improve the stability of the script.
The above is a small set to introduce the Python selenium three kinds of waiting way to explain (will), I hope to
ObjectiveAbout non-input file upload, click the upload button, this pop-up windows control, has jumped out of the three boundaries, not part of the jurisdiction of selenium (selenium is not omnipotent, can only manipulate elements on the web). The AutoIt tool handles Windows with a control window that is professional, so this needs to be solved with the help of AutoIt.First, the Environment preparation1. Ca
First to tell you about the selenium environment, you can in the CMD first look at their own selenium version:Enter it and you can install it.I would like to tell you how to skip the verification code to log in, the results of a lot of friends and I asked my environment configuration problems, so I think it is detailed with you to explain, I also make a record. Y
beginner Python, recently in the Python+selenium automated book with the Worm master, also try to write a login function verification 2333Code###########################using Python selenium-webdriver#simulate the login process of the blog Park#Home--Login page--Jump back Pa
1.unittest Unit Test Framework file structureUnitTest is one of the Python unit test frameworks that unittest the main file structure of the test framework:File>report>all_case.py>test_case>__init__.py>test_case1 .....>public>__init__.py>login.py>loginout.pyTest_case folder primarily stores test cases, and test case naming begins with Test_The public folder is a subfolder of the Test_case folder, primarily for common modules, such as login exit module
Using PIL+PYTESSERACT+TESSERACT-OCRPython version: 3.6.3TESSERACT-OCR version: 3.02.02① Installation PillowCMD switch to Pip:pip install Pillow② installation PytesseractPip Install Pytesseract③ Manual Download Tesseract-ocr.exe installation④ Code ExecutionAdd:After step ②, go to the "python\lib\site-packages\pytesseract" directory and modify the address of "Tesse
The script that was written before could run through, and now there's a problem:You need to check if your browser is automatically updated, which makes the version incompatible. If it is an update, then we need to re-download the corresponding version of the browser, note that the installation should be installed by default to the C drive, or else will be error. After the default installation, some versions will need to install Webdriver, and then dow
Rice flapping agent, the global leader of the agent brand, focus on the agency industry for nearly a decade, to provide open, private, exclusive agent, and free trialThe agent of Rice Flutter official website: https://proxy.mimvp.comThis article is an example of a private, exclusive, open proxy, specially developed for the M-topology agent,support for HTTP, HTTPS, no password, white list IP, password authorization three typesThis blog to from the rice Flutter blog:
# coding = Utf-8%%%%%%%%%%%%%%%% prevent garbled (can be added without adding)The From selenium import Webdriver%%%%%%%%%%%%%% uses the Webdriver function in selenium, so the Webdriver is directed inBrowser = Webdriver. The Firefox ()%%%%%%%%%%%%%%%%browser name is arbitrarily defined and used to manipulate functions. To control Firefox, you can switch to a different browser.Browser.get ("http://www.baidu.c
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.