Python Selenium Into the UI Automatic testing will encounter file upload and download operations , Here's how to download files
Here's how to use FireFox Browser for file download operation .
1、 Set the default file download address
Here's the picture ,firefox Can pass Enter in the address field ：about:config or about:aupport To view or modify configuration information .
2、 Set up automatic download operation
There are two solutions
2.1、 Set auto save download
Check... As shown in the figure below ： In the future, the same action will be automatically used to process such files
So the next time you download a file of this type, you won't be reminded like this .
2.2、 You can modify the settings in Browser options
Here's the picture
3、 Download the file
When this is done , But the browser opened when the program started did not open according to this configuration .
Comparing with the figure below, we can find that , adopt webdriver The browser opened is different from the browser opened by hand , This is because webdriver The open browser is not opened according to the configuration file set by the browser . If you want to open as a profile , Get the configuration file information before opening it .
There are two solutions , as follows
3.1、 Add the code as follows ：
profile = webdriver.FirefoxProfile(r"C:\Users\Skyyj\AppData\Roaming\Mozilla\Firefox\Profiles\1rzh6139.default") self.driver = webdriver.Firefox(profile)
3.2、 Add configuration information to the code
adopt %APPDATA%\Mozilla\Firefox\Profiles\ Find the default configuration
find mimeTypes.rdf Catalog , Open it in another way , Find the type of file you just saved
mimeTypes.rdf It's up there profile In the configuration path of
C:\Users\Skyyj\AppData\Roaming\Mozilla\Firefox\Profiles\1rzh6139.default lookup fileExtensions="xlsx" NC:value="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
From the files we can know what kind of files we need Insert the code as follows ：
#profile = webdriver.FirefoxProfile(r"C:\Users\Skyyj\AppData\Roaming\Mozilla\Firefox\Profiles\1rzh6139.default")
profile = webdriver.FirefoxProfile() ## Set to 0 Represents the default download path to the browser ; Set to 2 Can be saved to the specified directory
# Whether it is set here or not does not affect , No effect was found .
# I don't find any influence whether it is set or not
self.driver = webdriver.Firefox(profile)
The second is recommended , So you don't need to set up a browser , Good portability .
- Python+Selenium+webdriver Environment building （windows） And related resources download link
Today, let's record the test rookie alter A little bit about... At the beginning of testing python+Selenium+webdriver Environment building experience and resource sharing . Welcome to exchange and study , To criticize and correct . One .Python Download and install of 1.pytho ...
- Python Selenium File upload SendKeys
It was written yesterday Web File download ui automation , After downloading , I'm going to write today web The function of file upload has been improved . Of course, it took two hours to upload . Now write down the steps of your own operation First of all, there are many ways to say it online Such as input The best thing to do with labels is , straight ...
- python+selenium Browser problems
Previously used selenium call firefox It doesn't need to be driven , Recently installed python3.52+ Abreast of the times firefox I found that I couldn't tune it up After searching, we found that Firefox 47+ We need to have a firefox The driver gecko ...
- A complete automated login test - be based on python+selenium Conduct cnblog Automated login testing for
Web The login test is a very common test ! Manual testing is very familiar , So how to do automated login testing ! The author of this paper uses python+selenium combination unittest Unit testing framework for a simple but relatively complete cnblog Automatically ...
- Python + Selenium To realize the login Office 365
Recently, I picked up what I used before Python + Selenium Achieve the login needed in the work Office 365 function .( Make complaints : Domestic network is really a card , Sign in Office 365 It's not easy . in addition Selenium All these websites need walls , Incomprehensible ...
preparation : 1. download python2.7 http://python.org/getit/ 2. Download... Download setuptools [python Basic package tools ] Can help us easily download , structure , install , upgrade , discharge ...
- python+selenium Operation error reporting UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
Use python+selenium When running automation scripts , Print a paragraph of text appears UnicodeEncodeError: 'ascii' codec can't encode characters in posi ...
- Functional testing - python, selenium and django
Functional testing - python selenium django - Source Code : from selenium import webdriverfrom sele ...
- python selenium automation （ Two ） Automated registration process
demand : Use python selenium To automatically test a website registration process . Suppose the registration process of this website is divided into three steps , A lot of information needs to be provided : In this process , The user needs to fill in the information . Select from the drop-down menu . Select radio radio ...
source :http://www.php100.com/html/webkaifa/DIV_CSS/2008/1014/2326.html Html Code section : 1. Have a belt id Style sheet links for , We have to operate ...
- Data Being Added Conflicts with Existing Data
While developing a page with multiple scrolls levels, and especially when using a grid, you may get ...
- wifidog Source code analysis - Initialization phase
Wifidog It's a linux Open source authentication gateway software , It is mainly used to cooperate with the authentication server to realize the authentication and release function of the wireless router . wifidog It's a backstage service program , Can pass wdctrl Command to wifidog The main program controls . ...
- Poj 1328 / OpenJudge 1328 Radar Installation
1.Link: http://poj.org/problem?id=1328 http://bailian.openjudge.cn/practice/1328/ 2.Content: Radar I ...
- Photoshop CS4 Start pop up license agreement
win7: Delete 1.C:\Users\All Users\FLEXnet\adobe_00080000_tsf.data WinXP:(c:/Documents and Settings/All Us ...
- Chapter 18 js Advanced knowledge --- Scope chain
Always have the idea to write js Aspect stuff , I personally like js This language , Like his freedom and strength , Although there are many limitations as a scripting language , But it's also a good language , Especially in H5 After appearance . Let's start with js Things about the world , Due to their ...
- uva 1121 Subsequence
https://vjudge.net/problem/UVA-1121 The question : Give a sequence of positive integers a, It is required to find the shortest continuous sequence so that the sum of all the numbers in the sequence is greater than or equal to S. Ideas : The first is because the sequences are all positive integers ...
- Mac appium apk The problem of overlay installation
- File download background error IllegalStateException: getOutputStream() has already been called
java.lang.IllegalStateException: getOutputStream() has already been called <%@page language=" ...
- tomcat Cancel project name access path
stay server.xml in ,<host>...</host> Add... Between tags <Context path="" docBase="projec ...