Front-end file download implementation solution, Blob object enables you to download any file

Article directory Preface 1. What is Blob? 2. Generate Blob object 3. Request processing 1. Request encapsulation 2. According to the backend interface configuration 4. Tool functions 5. Actual use in projects 6. Optimize downloads Foreword This article mainly introduces how to use Blob object to implement the file download function on the front end. […]

uniapp uses uview components to realize three-level linkage between provinces and municipalities (any three-level linkage)

<template> <view class=”invite”> <u-cell title=”Click to select” isLink :value=”value” @click=”change()”></u-cell> <u-picker :show=”show” ref=”uPicker” :columns=”columns” @confirm=”confirm” @cancel=”show=false” @change=”changeHandler” ></u-picker> </view> </template> <script> // import {<!– –> address } from ‘@/static/address.js’; export default {<!– –> data() {<!– –> return {<!– –> show: false, columns: [], origiData: [{<!– –> “code”: “110000”, “value”: “Beijing City”, “children”: [{<!– –> “code”: […]

[Sliding Window] How many fruits can be put in the basket?

Problem: 904. Fruit in basket Article directory Question analysis Algorithm principle analysis Brute force enumeration + hash table Sliding window optimization Array optimized again the complexity Code Question analysis First, let’s analyze the idea of this question First, let’s understand the meaning through the description of the question. The question gives us a fruit array, […]

: too many indices for tensor of dimension 3

Table of Contents Solve the problem that tensor with dimension 3 has too many indexes introduction wrong reason Solution 1. Check the number of indexes 2. Make sure the tensor dimensions are correct 3. Check data type 4. Try to reconstruct the tensor 5. Review documentation and reference materials in conclusion scene description Sample code […]

When git uploads a project, it keeps reporting a file without adding any content (git pulls up other people’s projects and uploads them to their own warehouse/error: failed to push some refs to https://gitee.com/)

Blog homepage: Breaking the waves and moving forward Series of columns: Vue, React, PHP Thank you everyone for likingfavorites?comments Table of Contents Two methods: 1: Forced upload can be used 2: Delete other people’s .git files, because someone else has configured the remote address of git, and if you pull it locally together, he does […]

Explore Streams in Java 8: Many ways to build streams

People, you have to know how to avoid suspicion… Introduction at the beginning Java 8 introduces Stream as a new feature, which is a functional programming method for processing collection data. Stream provides a more concise, efficient and easy-to-understand method to operate collection data, while also enabling parallel processing to improve performance. The following are […]

Application skills: Four types of multi-threaded applications in Python programming, how many do you know?

In Python, multithreading is a way to achieve concurrency. Multithreading allows a program to perform multiple tasks at the same time, thereby improving the efficiency and execution speed of the program. This article will introduce all the ways of multithreading in Python, including using the threading module, using the concurrent.futures module, using the multiprocessing module, […]

Selenium – Automate anything you want with this framework!

IntroductiontoChromeDevTools ChromeDevToolsisasetoftoolsbuiltdirectlyintoChromium-basedbrowserssuchasChrome,Opera,andMicrosoftEdgetohelpdevelopersdebugandstudywebsites. WithChromeDevTools,developerscangaindeeperaccesstowebsitesandbeableto: InspectelementsintheDOM EditelementsandCSSonthefly Checkandmonitorwebsiteperformance Simulatetheuser’sgeographiclocation Simulatefaster/slowernetworkspeeds ExecuteanddebugJavaScript Viewconsolelog etc. Selenium4ChromeDevToolsAPI Seleniumisacomprehensivesetoftoolsandlibrariesthatsupportwebbrowserautomation.Selenium4addsnativesupportfortheChromeDevToolsAPI.WiththesenewAPIs,ourtestscannow: Captureandmonitornetworktrafficandperformance Simulatedgeolocationforlocation-awaretesting,localizationandinternationalizationtesting Changedevicemodesandtestyourapp’sresponsiveness Thisisjustthetipoftheiceberg! Selenium4introducesthenewChromiumDriverclass,whichincludestwomethodsforaccessingChromeDevTools:getDevTools()andexecuteCdpCommand(). ThegetDevTools()methodreturnsanewDevToolsobjectthatallowsyoutosendbuilt-inSeleniumcommandsforCDPusingthesend()method.ThesecommandsarewrappermethodsthatmakecallingCDPfunctionsclearerandeasier. TheexecuteCdpCommand()methodalsoallowsyoutoexecuteCDPmethods,butismoreprimitive.InsteadofusingawrappedAPI,itallowsyoutodirectlypassinaChromeDevToolscommandandtheargumentstothatcommand.IfthereisnoSeleniumwrapperAPIforaCDPcommand,oryouwanttocallitdifferentlythantheSeleniumAPI,youcanuseexecuteCdpCommand(). Chromium-baseddriverslikeChromeDriverandEdgeDrivernowinheritfromChromiumDriver,soyoucanaccesstheSeleniumCDPAPIfromthesedriversaswell. Let’sexplorehowyoucanleveragethesenewSelenium4APIstosolvevarioususecases. Emulateddevicemode Mostoftheappswebuildtodayareresponsivetomeettheneedsofendusersfromavarietyofplatforms,devices(e.g.mobile,tablet,wearables,desktop)andscreenorientations. Astesters,wemaywanttoplaceourappsindifferentsizestotriggerresponsivenessintheapp. HowcanweachievethisusingSelenium’snewCDPfunctionality? TheCDPcommandformodifyingdevicemetricsisEmulation.setDeviceMetricsOverride,andthiscommandrequiresinputofwidth,height,mobiledeviceflag,anddevicescalingfactor.Thesefourkeysarerequiredinthisscenario,buttherearesomeoptionalkeys. InourSeleniumtests,wecanusetheDevTools::send()methodandusethebuilt-insetDeviceMetricsOverride()command,butthisSeleniumAPIaccepts12parameters-inadditiontothe4requiredparameters,thereare8optionalonesparameter.Foranyofthese8optionalparametersthatwedon’tneedtosend,wecanpassOptional.empty(). However,tosimplifythisprocessandonlypasstherequiredparameters,IwillusetheoriginalexecuteCdpCommand()methodinthecodebelow. packagecom.devtools; importorg.openqa.selenium.chrome.ChromeDriver; importorg.openqa.selenium.devtools.DevTools; importjava.util.HashMap; importjava.util.Map; publicclassSetDeviceMode{ finalstaticStringPROJECT_PATH=System.getProperty(“user.dir”); publicstaticvoidmain(String[]args){ System.setProperty(“webdriver.chrome.driver”,PROJECT_PATH+”/src/main/resources/chromedriver”); ChromeDriverdriver; driver=newChromeDriver(); DevToolsdevTools=driver.getDevTools(); devTools.createSession(); MapdeviceMetrics=newHashMap() {<!—->{ put(“width”,600); put(“height”,1000); put(“mobile”,true); put(“deviceScaleFactor”,50); }}; driver.executeCdpCommand(“Emulation.setDeviceMetricsOverride”,deviceMetrics); driver.get(“https://www.google.com”); } } Online19,Icreateamapcontainingthekeysrequiredforthiscommand. Thenonline26,IcalltheexecuteCdpCommand()method,passingtwoparameters:thecommandname”Emulation.setDeviceMetricsOverride”,andthedevicemetricsmapcontainingtheparameters. […]