当前位置: 首页 > news >正文

Electron自动化测试技术选型调研

Electron简介

Electron是一个开源的框架,用于构建跨平台的桌面应用程序。它由GitHub开发并于2013年首次发布。Electron允许开发人员使用Web技术(如HTML、CSS和JavaScript)来构建桌面应用程序,同时可以在Windows、macOS和Linux等操作系统上运行。

以下是一些关键特点和优势:

  1. 跨平台:Electron可以在多个操作系统上运行,包括Windows、macOS和Linux。这意味着开发人员可以使用相同的代码库构建应用程序,并在不同的平台上进行部署。

  2. 基于Web技术:Electron使用Web技术作为应用程序的构建基础。开发人员可以使用HTML、CSS和JavaScript来构建用户界面和应用逻辑,这使得开发过程更加熟悉和容易上手。

  3. 强大的生态系统:Electron拥有庞大的开发者社区和丰富的第三方库和插件。开发人员可以利用这些资源来加速开发过程、解决问题和扩展应用程序功能。

  4. 自定义能力:Electron提供了丰富的API,可以访问底层操作系统的功能。开发人员可以利用这些API来实现与操作系统交互、访问文件系统、创建系统托盘应用等功能。

  5. 调试和工具支持:Electron集成了开发者工具,包括Chrome开发者工具,可以帮助开发人员进行调试和性能优化。此外,还有许多第三方工具和库可以用于构建、测试和部署Electron应用程序。

  6. 应用程序分发:Electron提供了打包和分发应用程序的工具。开发人员可以将应用程序打包为可执行文件或安装程序,并将其发布到应用商店或通过其他方式分发给用户。

Electron已经被广泛应用于各种领域,包括代码编辑器、聊天应用程序、桌面客户端等。许多知名的应用程序,如Visual Studio Code、Slack和GitHub Desktop,都是使用Electron构建的。

总之,Electron提供了一种简化和加速桌面应用程序开发的方式,使开发人员能够利用熟悉的Web技术构建跨平台的应用程序。

是当前酷家乐桌面客户端的底层技术

框架简介

在官方文档中介绍了3种(使用 WebDriver 接口,使用 Playwright,使用自定义测试驱动)进行自动化测试的方式:

https://www.electronjs.org/zh/docs/latest/tutorial/automated-testing

根据实际操作后发现,官网的操作的省略了很多关键步骤,而且无法直接跑通我们自己项目,需要一定的调研

查阅puppeteer-electron相关仓库:

https://github.com/peterdanis/electron-puppeteer-demo

https://github.com/nondanee/puppeteer-electron

方式框架star数量GPT给出的优点GPT给出的缺点
使用 WebDriver 接口WebdriverIO8.2kWebdriverIO是一个成熟的Web自动化测试框架,支持多种浏览器和平台。它提供了丰富的API和插件,使得测试编写更加方便和灵活。具有强大的等待机制,可确保元素可见性和页面加载完成。支持并行测试执行,提高测试效率。社区活跃,文档丰富,易于学习和使用。由于WebdriverIO是基于WebDriver协议的,因此执行速度可能相对较慢。在处理某些特殊情况下,如处理模态对话框和桌面应用程序时,可能会遇到一些困难。
Selenium/
27.2kSelenium是最广泛使用的Web自动化测试框架,支持多种编程语言和浏览器。具有强大的定位元素的能力,能够灵活地与页面交互。支持并行执行测试,提高了测试效率。社区庞大,可以获得广泛的支持和资源。Selenium不是为桌面应用程序设计的,因此在测试Electron应用程序时可能会遇到一些限制和问题。对于某些高级功能,如处理模态对话框和文件上传,可能需要编写自定义逻辑。
使用 Playwrightplaywright53.6kPlaywright是一个新兴的跨浏览器自动化测试框架,支持多个浏览器和平台。它提供了一个简洁的API,可以轻松地与页面交互和操作元素。具有强大的等待机制,可以等待元素出现和页面加载完成。支持截图、录屏等高级功能。相对于Selenium和WebdriverIO,Playwright的社区规模较小,可能会找到较少的资源和支持。在某些特殊情况下,如处理桌面应用程序和模态对话框时,可能会遇到一些限制。
使用自定义测试驱动node96.9k//
远程debugPuppeteer84.1k强大的浏览器自动化:Puppeteer提供了一套简洁而强大的API,可以用于模拟用户在浏览器中进行各种操作,如点击、填写表单、截图等。完全控制浏览器环境:Puppeteer可以控制底层的Chromium浏览器实例,从而能够修改和监控浏览器的各个方面,例如网络请求、用户代理、存储等,使得测试更加灵活和可靠。支持调试和错误排查:Puppeteer具有调试工具,可以帮助开发人员定位和修复测试中的问题,包括视觉回归问题、性能问题等。多平台支持:Puppeteer可以运行在多个平台上,包括Windows、Mac和Linux,适用于跨平台的Electron应用程序的自动化测试。学习曲线陡峭:Puppeteer的API相对复杂,需要一定的学习成本,特别是对于没有过多浏览器自动化经验的人来说。执行速度相对较慢:由于需要通过启动浏览器、模拟用户交互等步骤,使用Puppeteer进行自动化测试可能会比其他测试框架的执行速度慢一些。测试环境配置:使用Puppeteer进行Electron自动化测试需要配置好相关环境,包括安装正确版本的Chromium浏览器和Puppeteer库,这可能会带来一些麻烦。

前置准备

使用navigator.appVersion查看当前客户端使用的chromedriver版本

> navigator.appVersion
< '104.0.5112.124 qunheclient/1.0.0 kujialesoft/12.3.9 kujialeclient/12.3.9 utm_industry=kujiale/12.3.9 utm_campaign=autoUpdate'

使用process.versions.electron查看当前客户端electron版本

> process.versions.electron
< '20.3.8'

设置国内ELECTRON源

npm config set ELECTRON_MIRROR https://npm.taobao.org/mirrors/electron/

框架试用Demo

WebdriverIO

相关文档:https://webdriver.io/docs/desktop-testing/electron/

需要node版本为16+

使用脚手架安装:

yarn create wdio .

选择:


1a56a9b47c1e1fde76fd0c830dbf3735.png

zhongxin@zhongxindeMacBook-Pro demo2 % yarn create wdio .yarn create v1.22.19[1/4]   Resolving packages...[2/4]   Fetching packages...[3/4]   Linking dependencies...[4/4]   Building fresh packages...success Installed "create-wdio@8.2.5" with binaries:- create-wdio[#####################################################] 53/53-:...........................-:.+                              +`` +      `...`        `...`      + `./+/ +    .:://:::`    `::///::`  ` + ++/..+oo+ +    /:+ooo+-/    /-+ooo+-/ ./ + +oo+.-ooo+ +    /-+ooo+-/    /-+ooo+-/ .: + +ooo.-+o+ +    `::///:-`    `::///::`    + +o+-``. /.     `````        `````     .: .``.----------------------------.`-::::::::::::::::::::::::::::::::::::::::-`.+oooo/:------------------------------:/oooo+.`.--/oooo-                                  :oooo/--.`     .::-``:oooo`                                  .oooo-``-::../-`    -oooo`--.: :.--                         .oooo-    `-/.-/`    `-/oooooooo/.`    `/-`+`   `/+oooooooooooooooooooooooooooooooooooooooooooooooo+:`   .+`-/    +o/.:oooooooooooooooooooooooooooooooooooooooooooo:-/o/    +.-/   .o+  -oooosoooososssssooooo------------------:oooo- `oo`   +.-/   .o+  -oooodooohyyssosshoooo`                 .oooo-  oo.   +.-/   .o+  -oooodooysdooooooyyooo` `.--.``     .:::-oooo-  oo.   +.-/   .o+  -oooodoyyodsoooooyyooo.//-..-:/:.`.//.`./oooo-  oo.   +.-/   .o+  -oooohsyoooyysssysoooo+-`     `-:::.    .oooo-  oo.   +.-/   .o+  -ooooosooooooosooooooo+//oooo-  oo.   +.-/   .o+  -oooooooooooooooooooooooooooooooooooooooooooo-  oo.   +.-/   .o+  -oooooooooooooooooooooooooooooooooooooooooooo-  oo.   +.-+o+` -oooo---:///:----://::------------------:oooo- `oo+-+ooooooo/`-oooo``:-```.:`.:.`.+/-    .::::::::::` .oooo-`+ooooooo+ oooooooo+`-oooo`-- `/` .:+  -/-`/`   .::::::::::  .oooo-.+oooooooo+-/+://-/ -oooo-`:`.o-`:.:-````.:    .///:``````  -oooo-`/-//:+:-+: :..--:-:.+ooo+/://o+/-.-::-....-::::-....--/+ooo+.:.:--.-- /- /./`-:-` .:///+/ooooo/+///+++ooooo/+///:. .-:.`+./ ::-:/.           :`ooooo`/`              .:.ooooo :           ./---:`ooooo`/`              .:.ooooo ::`ooooo./`              .:-ooooo ::`ooooo./`              .:-ooooo :`...:-+++++:/.              ./:+++++-:...`:-.````````/../              /.-:````````.:--/::::::::://:/+             `+/:+::::::::::+.:oooooooooooo++/              +++oooooooooooo-                            Webdriver.IONext-gen browser and mobile automationtest framework for Node.jsInstalling @wdio/cli to initialize project...✔ Success!===============================  WDIO Configuration Wizard===============================? What type of testing would you like to do? Desktop Testing - of Electron Applications> https://webdriver.io/docs/desktop-testing/electron? What is the path to your compiled Electron app? ./dist? Which framework do you want to use? Jasmine (https://jasmine.github.io/)? Do you want to use a compiler? No!? Do you want WebdriverIO to autogenerate some test files? Yes? Where should these files be located? /Users/zhongxin/gitproject/desktopui/demo2/test/specs/**/*.js? Which reporter do you want to use? spec, allure? Do you want to add a plugin to your test setup?? Do you want to add a service to your test setup? electron? Do you want me to run `npm install` YesInstalling wdio packages:- @wdio/local-runner@latest- @wdio/jasmine-framework@latest- @wdio/spec-reporter@latest- @wdio/allure-reporter@latest- wdio-electron-serviceadded 78 packages, and changed 1 package in 11s97 packages are looking for fundingrun `npm fund` for details✔ Success! Creating a WebdriverIO config file...✔ Success! Autogenerating test files...✔ Success! Adding "wdio" script to package.json.✔ Success! Successfully setup project at /Users/zhongxin/gitproject/desktopui/demo2Join our Discord Community Server and instantly find answers to your issues or queries. Or just join and say hi !    https://discord.webdriver.ioVisit the project on GitHub to report bugs  or raise feature requests :    https://github.com/webdriverio/webdriverioTo run your tests, execute:$ cd /Users/zhongxin/gitproject/desktopui/demo2$ npm run wdioDone in 72.80s.

安装chromedriver

npm i -D chromedriver@104

修改wdio.conf.js文件

capabilities: [{browserName: 'chrome',        'goog:chromeOptions': {binary: 'chromedriver/bin/chromedriver', // Electron 二进制文件的路径args: [/* 命令行参数 */] // 可选, 比如 'app=' + /path/to/your/app/}}],services: [[        'electron',{appPath: '/Users/zhongxin/Downloads',appName: "酷家乐",appArgs: ['foo', 'bar=baz'],chromedriver: {port: 9519,logFileName: 'wdio-chromedriver.log',chromedriverCustomPath: 'chromedriver/bin/chromedriver' // resolves to chromedriver binary},electronVersion: '20.3.8',}]],

以mac m1电脑为例,从官网下载客户端后,打开dmg文件,将酷家乐.app放到/Users/zhongxin/Downloads/mac-arm64/酷家乐.app位置

修改一下测试脚本test.e2e.js,完成登录

import { browser } from '@wdio/globals'describe('Electron Testing', () => {it('should print application metadata', async () => {        console.log('听白测试')await browser.$('//*[text()="账号登录"]').click()await browser.$('//input[@placeholder="输入手机号/邮箱"]').setValue("xxxx@xxxx.com")await browser.$('//input[@placeholder="输入密码"]').setValue("xxxx")await browser.$('//button[text()="登录"]').click()await browser.pause(5000)await browser.saveScreenshot('./test.png')})
})

运行测试wdio run ./wdio.conf.js后会唤起客户端并完成登录操作,然后进行截图

Selenium

新建一个空文件夹,使用npm进行初始化

npm init
zhongxin@zhongxindeMacBook-Pro demo2 % npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.See `npm help init` for definitive documentation on these fields
and exactly what they do.Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.Press ^C at any time to quit.
package name: (demo2)version: (1.0.0)description:entry point: (index.js)test command:git repository:keywords:author:license: (ISC)About to write to /Users/zhongxin/gitproject/desktopui/demo2/package.json:{"name": "demo2","version": "1.0.0","description": "","main": "index.js","scripts": {"test": "echo \"Error: no test specified\" && exit 1"},"author": "","license": "ISC"
}Is this OK? (yes)

安装&运行chromedriver

npm install --save-dev electron-chromedriver@20.0.0./node_modules/.bin/chromedriver

安装selenium

npm install --save-dev selenium-webdriver

编写测试脚本

const webdriver = require('selenium-webdriver')const { Builder } = require('selenium-webdriver');(async function myTest() {    let driver = await new Builder().usingServer('http://localhost:9515').withCapabilities({            'goog:chromeOptions': {binary: '/Users/zhongxin/Downloads/mac-arm64/酷家乐.app/Contents/MacOS/酷家乐'}}).forBrowser('chrome') // 注意: 使用 .forBrowser('electron') for selenium-webdriver <= 3.6.0.build()    console.log('听白测试')await driver.sleep(5000)await driver.findElement(webdriver.By.xpath('//*[text()="账号登录"]')).click()await driver.findElement(webdriver.By.xpath('//input[@placeholder="输入手机号/邮箱"]')).sendKeys("xxxx@xxxx.com")await driver.findElement(webdriver.By.xpath('//input[@placeholder="输入密码"]')).sendKeys("xxxx")await driver.findElement(webdriver.By.xpath('//button[text()="登录"]')).click()await driver.sleep(5000)await driver.takeScreenshot().then(        function (image, err) {            require('fs').writeFile('test.png', image, 'base64', function (err) {                console.log(err)})})await driver.quit()
})();

playwright

官方文档:https://playwright.dev/docs/api/class-electron

安装

npm init playwright@latest

b778d36241035b6db0f079c7e4a26876.png

zhongxin@zhongxindeMacBook-Pro demo3 % npm init playwright@latest
Need to install the following packages:create-playwright@1.17.128Ok to proceed? (y)
Getting started with writing end-to-end tests with Playwright:
Initializing project in '.'
✔ Do you want to use TypeScript or JavaScript? · JavaScript
✔ Where to put your end-to-end tests? · tests
✔ Add a GitHub Actions workflow? (y/N) · false
✔ Install Playwright browsers (can be done manually via 'npx playwright install')? (Y/n) · true
Initializing NPM project (npm init -y)…
Wrote to /Users/zhongxin/gitproject/desktopui/demo3/package.json:{"name": "demo3","version": "1.0.0","description": "","main": "index.js","scripts": {"test": "echo \"Error: no test specified\" && exit 1"},"keywords": [],"author": "","license": "ISC"
}Installing Playwright Test (npm install --save-dev @playwright/test)…added 3 packages in 5s
Downloading browsers (npx playwright install)…
Writing playwright.config.js.
Writing tests/example.spec.js.
Writing tests-examples/demo-todo-app.spec.js.
Writing package.json.
✔ Success! Created a Playwright Test project at /Users/zhongxin/gitproject/desktopui/demo3Inside that directory, you can run several commands:npx playwright testRuns the end-to-end tests.npx playwright test --uiStarts the interactive UI mode.npx playwright test --project=chromiumRuns the tests only on Desktop Chrome.npx playwright test exampleRuns the tests in a specific file.npx playwright test --debugRuns the tests in debug mode.npx playwright codegenAuto generate tests with Codegen.We suggest that you begin by typing:npx playwright testAnd check out the following files:- ./tests/example.spec.js - Example end-to-end test- ./tests-examples/demo-todo-app.spec.js - Demo Todo App end-to-end tests- ./playwright.config.js - Playwright Test configurationVisit https://playwright.dev/docs/intro for more information. ✨Happy hacking!

安装electron

npm i electron@20.3.8

运行开发项目:

https://gitlab.qunhequnhe.com/fe/up/desktop

https://gitlab.qunhequnhe.com/desktop/base/main

生成入口文件:/Users/zhongxin/gitproject/main/app/dist/main.js

测试脚本:

const {_electron: electron} = require('@playwright/test');(async () => {    const electronApp = await electron.launch({cwd: '/Users/zhongxin/gitproject/main/app/dist',args: ['main.js']});    console.log('开始测试')    const window = await electronApp.firstWindow();await window.waitForTimeout(3000)    window.on('console', console.log);    console.log(await window.title());await window.screenshot({path: 'intro.png'});await window.click('text=账号登录');await window.fill('input[placeholder="输入手机号/邮箱"]', 'xxxx@xxxx.com')await window.fill('input[placeholder="输入密码"]', 'xxxx')await window.click('button[title="账密登录"]');await window.waitForTimeout(3000)await window.locator('text=登录').last().click();await window.waitForTimeout(3000)await window.screenshot({path: 'test.png'});await electronApp.close();
})();

这种方式非常的麻烦,比较适合在开发阶段进行测试

Puppeteer

新建一个空文件夹,使用npm进行初始化

npm init

安装相关包

npm i electron@20.3.8 puppeteer-core

运行本地electron并开启调试

const {spawn} = require("child_process");const port = 9200;spawn(    "/Users/zhongxin/Downloads/mac-arm64/酷家乐.app/Contents/MacOS/酷家乐",[`--remote-debugging-port=${port}`],{shell: true}
);

编写测试脚本

const puppeteer = require("puppeteer-core");const port = 9200;(async () => {    let app = await puppeteer.connect({browserURL: `http://localhost:${port}`,});    const pages = await app.pages();    const [page] = pages;await (await page.$x('//button[text()="账号登录"]'))[0].click();await (await page.$x('//input[@placeholder="输入手机号/邮箱"]'))[0].type('xxxx@xxxx.com')await (await page.$x('//input[@placeholder="输入密码"]'))[0].type('xxxx');await (await page.$x('//button[text()="登录"]'))[0].click();await page.screenshot({path: 'test.png'});setTimeout(async () => await app.close(), 5000)
})()

总结

框架环境准备支持情况
WebdriverIO简单:将下载到的安装包放到指定路径下即可支持较好
Selenium中等:将下载到的安装包放到指定路径+启动chromedriver支持一般
playwright困难:部署&运行代码实验性质
Puppeteer中等:将下载到的安装包放到指定路径+启动应用支持一般

由于Hades采用的是Puppeteer,优先考虑使用Puppeteer

后续封装一个启动electron的操作,将它加在beforeAll里,就可以复用之前旧的UI自动化测试代码了

相关文章:

Electron自动化测试技术选型调研

Electron简介 Electron是一个开源的框架&#xff0c;用于构建跨平台的桌面应用程序。它由GitHub开发并于2013年首次发布。Electron允许开发人员使用Web技术&#xff08;如HTML、CSS和JavaScript&#xff09;来构建桌面应用程序&#xff0c;同时可以在Windows、macOS和Linux等操…...

微服务学习(九):安装OpenOffice

微服务学习&#xff08;九&#xff09;&#xff1a;安装OpenOffice 一、下载OpenOffice 下载地址&#xff1a;OpenOffice 二、开始安装 上传资源到服务器 解压资源包 tar -zxvf Apache_OpenOffice_4.1.13_Linux_x86-64_install-rpm_zh-CN.tar.gz进入zh-CN/RPMS目录下安装…...

SAP Oracle表空间扩展技术手册

1、DBACOCKPIT下查看表空间 当表空间不足(达到99%)时,需要按以下步骤扩充表空间(每次扩充20000M,20G): (也可以通过DB13,DB02查看表空间) 新浪博客 Tablespace PSAPSR3 is 100% used | SAP Community Oracle是通过增加数据文件的方式来为表空间扩容。为指定表空间增…...

Linux系统编程——线程的学习

学习参考博文&#xff1a; Linux多线程编程初探 Linux系统编程学习相关博文 Linux系统编程——文件编程的学习Linux系统编程——进程的学习Linux系统编程——进程间通信的学习Linux系统编程——网络编程的学习 Linux系统编程——线程的学习 一、概述1. 进程与线程的区别2. 使…...

zemaxMIF曲线图

调制传递函数&#xff08; Modulation Transfer Function&#xff0c;MTF &#xff09;是用来形容光学系统成像质量的重要指标。 通过对光学系统像空间进行傅里叶变换&#xff0c;可以得到一张分析图表&#xff0c;来描述像面上对比度和空间频率之间的对应关系。 对比度&…...

【苹果】SpringBoot监听Iphone15邮件提醒,Selenium+Python自动化抢购脚本

前言 &#x1f34a;缘由 Iphone15来了&#xff0c;两年之约你还记得吗&#xff1f; 两年前&#xff0c;与特别的人有一个特别的约定。虽物是人非&#xff0c;但思念仍在。 遂整合之前iphone13及iphone14的相关抢购代码&#xff0c;完成一个SpringBoot监听Iphone15有货邮件提…...

什么是WhatsApp群发,WhatsApp协议,WhatsApp云控

那么WhatsApp群控云控可以做什么呢&#xff1f; 1、获客 自动化引流&#xff0c;强大的可控性&#xff0c;产品快速拓客 2、导流 一键式傻瓜化自动加好友&#xff0c;群发&#xff0c;朋友圈营销 3、群控 一键式拉群好友&#xff0c;建群&#xff0c;进群 …...

RealVNC viewer 窗口指定默认显示

RealVNC Viewer关于显示器(monitor)的参数有两个&#xff0c;一个是monitor&#xff0c;一个是useallmonitor。 monitor就是指定viewer窗体在哪个显示器上显示的&#xff0c;windows下的默认值是空白&#xff0c;改为\\.\DISPLAY2 就可以在打开远程窗口的时候默认在副屏上显…...

图论20(Leetcode1254.统计封闭岛屿的数目)

代码&#xff1a; class Solution {static int[][] dirs {{1,0},{-1,0},{0,1},{0,-1}};public int closedIsland(int[][] grid) {int num 0; for(int i0;i<grid.length;i){for(int j0;j<grid[0].length;j){if(grid[i][j]0){int[] start {i,j};if(getIsland(start,gri…...

Docker 的基本概念和优势,以及在应用程序开发中的实际应用

Docker是一种开源的容器化平台&#xff0c;它可以将应用程序打包成容器&#xff0c;并且可以在不同的环境中运行。Docker的基本概念包括&#xff1a; 镜像&#xff08;Image&#xff09;&#xff1a;Docker镜像是一个可执行的包&#xff0c;它包含了运行应用程序所需的所有文件…...

数据仓库整理

数仓 olap vs oltp OLTP主要用于支持日常的业务操作&#xff0c;如银行交易、电子商务等&#xff0c;强调数据的准确性、实时性和并发性。OLAP主要用于支持复杂的数据分析&#xff0c;如数据仓库、决策支持等&#xff0c;强调数据的维度、聚合和可视化。 将OLTP数据库的数据…...

《C++API设计》读书笔记(3):模式

本章内容 本章涵盖了一些与CAPI设计相关的设计模式和惯用法。 “设计模式(Design Pattern)”表示软件设计问题的一些通用解决方案。该术语来源于《设计模式&#xff1a;可复用面向对象软件的基础》&#xff08;Design Patterns: Elements of Reusable Object-Oriented Softwar…...

小程序搜索词优化:小陈运营的秘密武器

大家好&#xff0c;我是小陈&#xff0c;今天要和大家分享一下小程序搜索词优化的经验和技巧。在数字化时代&#xff0c;小程序已经成为许多企业的重要工具&#xff0c;但要让小程序在竞争激烈的市场中脱颖而出&#xff0c;搜索词优化是不可或缺的一环。在本文中&#xff0c;我…...

SpringSecurity 入门

文章目录 Spring Security概念快速入门案例环境准备Spring配置文件SpringMVC配置文件log4j配置文件web.xmlTomcat插件 整合SpringSecurity 认证操作自定义登录页面关闭CSRF拦截数据库认证加密认证状态记住我授权注解使用标签使用 Spring Security概念 Spring Security是Spring…...

【每日一题Day335】LC1993树上的操作 | dfs

树上的操作【LC1993】 给你一棵 n 个节点的树&#xff0c;编号从 0 到 n - 1 &#xff0c;以父节点数组 parent 的形式给出&#xff0c;其中 parent[i] 是第 i 个节点的父节点。树的根节点为 0 号节点&#xff0c;所以 parent[0] -1 &#xff0c;因为它没有父节点。你想要设计…...

FPGA:卷积编码及维特比译码仿真

FPGA&#xff1a;卷积编码及维特比译码仿真 本篇记录一下在FPGA中完成卷积编码和维特比译码的过程&#xff0c;通过代码解释编码的过程和译码的过程&#xff0c;便于理解&#xff0c;同时也方便移植到其他工程中。 1. 准备工作 卷积编译码IP核—convolutionIP核和viterbiIP核…...

MySQL学习笔记4

客户端工具的使用&#xff1a; MySQL&#xff1a; mysql命令行工具&#xff0c;一般用来连接访问mysql的数据。 案例&#xff1a;使用mysql客户端工具连接服务器端&#xff08;用户名&#xff1a;root&#xff1b;密码&#xff1a;123456&#xff09;. [rootmysql-server ~]#…...

JavaFX:窗体显示状态,模态非模态

程序窗体显示一般有3中模式。非模态和模态&#xff0c;其中模态又分为程序模态和窗体模态。 非模态可以理解为窗体之间没有任何限制&#xff0c;可以用鼠标、键盘等工具在窗体间切换。 程序模态是窗体打开后&#xff0c;该程序的所有窗体都被冻结&#xff0c;无法切换&#x…...

C++17中std::filesystem::path的使用

C17引入了std::filesystem库(文件系统库, filesystem library)。这里整理下std::filesystem::path的使用。 std::filesystem::path&#xff0c;文件系统路径&#xff0c;提供了对文件系统及其组件(例如路径、常规文件和目录)执行操作的工具。此path类主要用法包括&#x…...

命令模式简介

概念&#xff1a; 命令模式是一种行为设计模式&#xff0c;它将请求封装成一个对象&#xff0c;从而允许您将不同的请求参数化、队列化&#xff0c;并且能够在不同的时间点执行。通过引入命令对象&#xff08;Command&#xff09;来解耦发送者&#xff08;Invoker&#xff09;…...

Boost序列化指针

Boost.Serialization 还能序列化指针和引用。 由于指针存储对象的地址&#xff0c;序列化对象的地址没有什么意义&#xff0c;而是在序列化指针和引用时&#xff0c;对象的引用被自动地序列化。 代码 #include <boost/archive/text_oarchive.hpp> #include <boost/…...

NIO简单介绍

一、什么是NIO 1、Java NIO全称java non-blocking IO&#xff0c; 是指JDK提供的新API。从JDK1.4开始&#xff0c;Java提供了一系列改进的输入/输出的新特性&#xff0c;被统称为NIO(即New IO)&#xff0c;是同步非阻塞的 2、NIO有三大核心部分: Channel(通道)&#xff0c; Buf…...

linux进程杀不死

项目场景&#xff1a; 虚拟机 问题描述 linux进程杀不死 无反应 原因分析&#xff1a; 进程僵死zombie 解决方案&#xff1a; 进proc或者find命令找到进程所在地址 cat status查看进程杀死子进程...

5分钟带你搞懂RPA到底是什么?RPA能做什么?

一、RPA的定义 RPA&#xff0c;全称Robotic Process Automation&#xff0c;即机器人流程自动化&#xff0c;是一种软件解决方案&#xff0c;能够模拟人类在计算机上执行的操作&#xff0c;以实现重复性、繁琐任务的自动化。它与传统的计算机自动化有所不同&#xff0c;因为它…...

毫米波雷达 TI IWR1443 在 ROS 中进行 octomap 建图

个人实验记录 /mmwave_ti_ros/ros_driver/src/ti_mmwave_rospkg/launch/1443_multi_3d_0.launch <launch><!-- Input arguments --><arg name"device" value"1443" doc"TI mmWave sensor device type [1443, 1642]"/><arg…...

113双周赛

题目列表 2855. 使数组成为递增数组的最少右移次数 2856. 删除数对后的最小数组长度 2857. 统计距离为 k 的点对 2858. 可以到达每一个节点的最少边反转次数 一、使数组成为递增数组的最少右移次数 这题可以直接暴力求解&#xff0c;枚举出每种右移后的数组&#xff0c;将…...

React 全栈体系(九)

第五章 React 路由 一、相关理解 1. SPA 的理解 单页 Web 应用&#xff08;single page web application&#xff0c;SPA&#xff09;。整个应用只有一个完整的页面。点击页面中的链接不会刷新页面&#xff0c;只会做页面的局部更新。数据都需要通过 ajax 请求获取, 并在前端…...

阈值化分割,对灰度级图像进行二值化处理(数字图像处理大题复习 P8)

文章目录 画出表格求出灰度直方图 & 山谷画出结果图 画出表格 有几个0就写几&#xff0c;有几个1就写几&#xff0c;如图 求出灰度直方图 & 山谷 跟前面求灰度直方图的方法一样&#xff0c;找出谷底&#xff0c;发现结果为 4 画出结果图 最终的结果就是&#xf…...

vue3中withDefaults是什么

问: const props withDefaults(defineProps<{// 数据列表lotteryList: { pic: string; name?: string }[];// 中奖idwinId: number;// 抽奖初始转动速度initSpeed: number;// 抽奖最快转动速度fastSpeed: number;// 抽奖最慢转动速度slowSpeed: number;// 基本圈数baseCi…...

Android进阶之路 - 盈利、亏损金额格式化

在金融类型的app中&#xff0c;关于金额、数字都相对敏感和常见一些&#xff0c;在此仅记录我在金融行业期间学到的皮毛&#xff0c;如后续遇到新的场景也会加入该篇 该篇大多采用 Kotlin 扩展函数的方式进行记录&#xff0c;尽可能熟悉 Kotlin 基础知识 兄弟 Blog StringUti…...