selenium的安装及配置

最全Python+Selenium环境搭建教程-你绝对想不到有这么简单! 在华为工作了10年的大佬出的Web自动化测试教程,华为现用技术教程!_哔哩哔哩_bilibili在华为工作了10年的大佬出的Web自动化测试教程,华为现用技术教程!共计16条视频,包括:1. 【web自动化】主流Web自动化测试技术对比、2. 【web自动化】Selenium自动化测试环境一键搭建、3. 【web自动化】Selenium八大定位策略详解等,UP主更多精彩视频,请关注UP账号。Selenium是目前最流行的web自动化测试工具,也常用于网络爬虫,已经更新到3以上的版本。 阅读详情
AI摘要

本文详细介绍了Selenium的安装、浏览器驱动的下载与设置,以及如何验证驱动是否可用。通过实例展示了如何用Python启动不同浏览器进行自动化操作,包括Firefox、Chrome、IE、Edge和Opera。此外,还提供了Selenium用于爬虫时解决反爬问题的能力。


1. selenium 简介

Selenium 是最广泛使用的开源 Web UI(用户界面)自动化测试套件之一。Selenium 支持的语言包括C#,Java,Perl,PHP,Python 和 Ruby。目前,Selenium Web 驱动程序最受 Python 和 C#欢迎。 Selenium 测试脚本可以使用任何支持的编程语言进行编码,并且可以直接在大多数现代 Web 浏览器中运行。在爬虫领域 selenium 同样是一把利器,能够解决大部分的网页的反爬问题。

2. selenium 安装

首先,在Windows 命令提示符(cmd)输入:

pip install selenium

如果提示“pip不是内部或外部命令”,需要把环境变量配置好。

如果你的 pip 命令可用,但是安装的时候很慢,可以使用国内镜像

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple selenium  # 使用清华大学镜像

3. selenium 浏览器驱动

3.1 selenium 驱动下载

当 selenium 升级到 3.0 之后,对不同的浏览器驱动进行了规范。如果想使用 selenium 驱动不同的浏览器,必须单独下载并设置不同的浏览器驱动。

以 Chrome浏览器驱动 为例:Chrome浏览器驱动

需要查看自己chrome 的浏览器版本去下载对应的驱动版本

路径: chrome - 设置 - 关于 chrome
在这里插入图片描述

3.2 selenium 驱动设置

创建一个存放浏览器驱动的目录,如: D:\driver , 将下载的浏览器驱动文件(例如:chromedrive)丢到该目录下。

我的电脑–>属性–>系统设置–>高级–>环境变量–>系统变量–>Path,将“D:\driver”目录添加到 Path 的值中。

变量名变量值
PATHD:\driver

4. 验证驱动是否可用

验证浏览器驱动是否正常使用。

from selenium import webdriver

driver = webdriver.Firefox()   # Firefox 浏览器

driver = webdriver.Chrome()    # Chrome 浏览器

driver = webdriver.Ie()        # Internet Explorer 浏览器

driver = webdriver.Edge()      # Edge 浏览器

driver = webdriver.Opera()     # Opera 浏览器

driver = webdriver.PhantomJS()   # PhantomJS 无头浏览器

5. selenium程序

from selenium import webdriver

driver = webdriver.Chrome()  # 使用 Chrome 驱动

driver.get('https://www.baidu.com')  # 操控浏览器打开百度主页

print(driver.title)

driver.quit()  # 退出浏览器
selenium安装配置及基本使用 使用部分超链接文本定位【By.PARTIAL_LINK_TEXT】使用class属性值定位【By.CLASS_NAME 】使用css选择器定位【By.CSS_SELECTOR】使用超链接文本定位【By.LINK_TEXT】使用标签名定位【By.TAG_NAME】使用name属性值定位【By.NAME】使用xpath定位【By.XPATH】使用id值定位【By.ID 】查找兄弟的下一个文本数据。获取页面html源码。 阅读详情

相关推荐

Python+Selenium安装及环境配置

转自:https://www.cnblogs.com/sandysun/p/7838113.html一、Python安装Window系统下,python的安装很简单。访问python.org/download,下载最新版本,安装过程与其他windows软件类似。记得下载后设置path环境变量,然后Windows命令行就可以调用了:二、Selenium安装Python3.x安装后就默认就会有pip(...

XXLoveSHT的博客 15万+

selenium基本配置

快速上手selenium自动化测试

qq_18596615的博客 629

FFTW多核优化避坑指南:从交叉编译到ELF2板载OpenMP部署全流程

本文详细介绍了在ELF2开发板(RK3588平台)上为FFTW库配置OpenMP多核并行的完整流程与避坑指南。内容涵盖从交叉编译、库依赖处理到板载部署的实战步骤,并深入分析了RK3588的big.LITTLE架构对线程调优的影响,帮助开发者在嵌入式环境中高效利用多核性能。

2a4s6d8f0g的博客 272

Selenium安装及环境配置

Selenium安装及环境配置

m0_49879527的博客 1749

实战演练:基于Veristand Custom Device的硬件在环(HIL)数据流控制模块开发

本文详细介绍了基于Veristand Custom Device的硬件在环(HIL)数据流控制模块开发实战。通过LabVIEW环境配置、动态路由逻辑构建、实时处理核心开发及性能优化等关键步骤,帮助工程师快速掌握定制化HIL测试系统的开发技巧,提升测试效率与准确性。

weixin_29206669的博客 475

大厂嵌入式面试常考八股文及算法

1.指向已被释放或无效的内存地址的指针是野指针。互斥锁是一种用于线程同步的机制,用于确保同一时间只有一个线程访问共享资源。多态是面向对象编程中的一种特性,它允许以一种统一的方式处理不同类型的对象,通过相同的接口可以表现出不同的行为。大小端(Endian)指的是在计算机存储和处理多字节数据时,字节的存储顺序。大端序(Big Endian):高位字节存储在低地址,低位字节存储在高地址。类似于将数字的高位放在左边,低位放在右边的表示方式。例如整数值0x12345678在内存中按照大端序排列为。

谢谢大家的关注 6159

Scrapy-Selenium安装与配置指南

Scrapy-Selenium安装与配置指南 1. 项目基础介绍 Scrapy-Selenium 是一个开源项目,它作为一个Scrapy中间件,允许Scrapy框架处理JavaScript渲染的页面。这意味着Scrapy可以爬取那些需要JavaScript执行的页面,从而获取动态加载的内容。该项目主要使用Python编程语言。 2. 项目使用的关键技术和框架 Scrapy: Scrapy是一个强...

gitblog_00349的博客 803

基于FreeRTOS与MQTT的物联网技术应用系列——步进电机控制(三)SD卡驱动、FatFS等的移植和ini配置文件读取的实现

本文实现了基于STM32F107VC的金牛开发板的基于SPI模式的SD卡驱动和FatFS的移植,以及利用minini库对ini配置信息文件进行读取。

sqshining的专栏 2138

Selenium安装配置教程

Selenium安装配置教程 Selenium的介绍 Selenium支持web浏览器自动化,它主要有三个工具构成:Selenium WebDriver、Selenium IDE、Selenium Grid。 Selenium的官网:https://www.selenium.dev/ Selenium WebDriver是使用浏览器,提供API来控制浏览器,就像用户在操作浏览器。 Selenium IDE是浏览器的一个扩展插件,可以录制用户在浏览器上的一个操作。 Selenium Grid是用于Seleni

qq_33581509的博客 1207

ESP32 BLE Mesh Provisioner实战:手把手教你用ESP-IDF配网智能灯泡(附常见错误排查)

本文提供了一份基于ESP-IDF的ESP32 BLE Mesh Provisioner实战指南,详细解析了配网器的核心角色与工作流程。文章手把手教你从工程搭建、代码初始化到核心回调解析,并重点针对常见的‘Model not bound to AppKey’等错误提供了深度排查思路与解决方案,帮助你构建一个稳定可靠的智能照明网关。

desk3的博客 514

TMC5130/TMC5160步进电机驱动芯片深度解析与工程实践

步进电机驱动芯片是精密运动控制系统的物理执行核心,其性能直接决定定位精度、运行噪声与系统鲁棒性。基于电流闭环控制与电压前馈调制的混合驱动原理,现代智能驱动芯片如TMC51X0系列实现了微步插补、堵转检测和片上运动规划等关键技术突破。这类芯片通过SPI寄存器级配置实现StealthChop静音驱动与SpreadCycle高动态响应模式的无缝切换,在3D打印、CNC、机器人关节等场景中显著提升能效比与控制带宽。本文围绕TMC5130与TMC5160的硬件架构差异、寄存器操作时序、驱动模式物理机制及FreeRTO

weixin_35797963的博客 410

Selenium环境安装配置

根据自己的系统选择chromedriver,windows 只有32位的,因为Windows 64为也支持运行32为的。在下载 chromedriver 的时候需要注意的是chromedriver 和 chrome 浏览器版本的对应关系。根据浏览器的版本号去下载对应的 chromedriver。chromedriver 是chromedriver提供的浏览器驱动程序,他的作用是将代码的请求转发给浏览器。其他环境与chrome浏览器的区别就在于 driver 的配置, 所以下载对应浏览器的driver即可。

NHB66666666的博客 1032

PCB设计必看:铜皮厚度与载流能力对照表(附Excel计算工具)

本文深入解析了PCB设计中铜皮厚度与载流能力的核心关系,提供了基于IPC-2152标准的动态计算逻辑与实用Excel工具。文章不仅分享了载流对照表,更重点剖析了影响载流能力的关键因素(如铜厚、线宽、温升、布线层),并给出了高电流设计的实战技巧与测试验证方法,帮助工程师规避常见陷阱,实现从理论到实践的闭环设计。

weixin_29228781的博客 724

Selenium环境安装配置,webdriver配置

将 selenium-idx.crx 文件添加到扩展程序中,Chrome浏览器 → 设置 → 扩展程序,将文件拖入扩展程序中进行安装。复制chrome浏览器的安装地址,找到chrome浏览器图标->右键->属性,复制“起始位置”的地址。在文件中添加:export PATH=$PATH:[chromedriver所在路径]配置文件中添加:export PATH=$PATH:[chrome所在路径]根据自己的chrome浏览器版本,查看版本:设置->关于Chrome。配置chromedriver。

lina0217的博客 1844

创龙 瑞芯微 RK3588 国产工业开发板—Qt交叉编译环境搭建与GPU图形渲染实战

本文详细介绍了在创龙RK3588国产工业开发板上搭建Qt交叉编译环境并利用GPU进行图形渲染的完整实战流程。文章从环境准备入手,讲解了交叉编译工具链的配置,并提供了命令行与Qt Creator两种编译方法。通过部署运行和自启动设置,确保程序在板卡上稳定运行。最后,通过OpenGL案例实战,展示了如何调用RK3588的GPU进行高效图形渲染,释放其图形处理潜力,适用于工业HMI、智能终端等高要求图形界面开发。

weixin_28278377的博客 450

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

python selenium环境安装及配置_selenium环境配置

一、安装步骤无网安装前提:机子已安装Firefox24.0版本,若没有安装,请先安装Firefox浏览器24.0版本1、python-2.7.6.msi安装程序包,双击运行安装即可,不用更改安装过程中的任何选项,既然你选择python,相信你是熟悉python的,我安装目录C:\Python272、setuptools-0.6c11.win32-py2.7的安装也非常简单,双击就可安装,不用更改安...

weixin_40008033的博客 169

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

pycharm安装selenium及配置chrome driver

pycharm安装selenium及配置chrome driver 安装过程中看了好多博客,发现都没写清楚,所以mark一下我自己的安装过程,保姆级教程,希望可以帮助到有需要的朋友。 打开cmd,输入pip install selenium,我已经安装过了所以这里显示已安装 查看自己chrome的版本号,下载合适的chrome driver。 2.1如何查看自己的chrome版本号呢?打开chrome浏览器,点击右上方三个点,选帮助,关于google chrome。然后得到版本号 2.2去chrom

RY_BAYMAX的博客 5348

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

selenium的安装配置

简介:主要包括selenium的安装,浏览器驱动的安装

xixi0924的博客 1003

Python+Selenium简单安装配置

selenium驱动和简单安装教程。

okcross0的博客 902

python环境selenium的安装和配置以及常见错误的解决方法

1. 安装方法 selenium包的安装有以下几个方式: 通过命令行安装,语法为pip install selenium[==版本号],其中版本号是选填的,比如安装版本号为2.48.0的selenium,则命令为pip install selenium==2.48.0,如果是要安装最新版本的则直接输入pip install selenium即可。 通过pycharm安装,具体步骤为:菜单File–>setting–>Project 当前工程名称–>Project Interpreter–

catch_dreamer的博客 3万+

python selenium环境安装及配置_Python Selenium安装及环境配置的实现

一、Python安装Window系统下,python的安装很简单。访问python.org/download,下载最新版本,安装过程与其他windows软件类似。记得下载后设置path环境变量,然后Windows命令行就可以调用了:二、Selenium安装Python3.x安装后就默认就会有pip(pip.exe默认在python的Scripts路径下),使用pip安装selenium:pip i...

weixin_39975055的博客 85

安装配置selenium

安装配置Selenium安装配置selenium 安装 cmd命令行输入 pip3 install selenium 配置selenium 下载对应的chromedriver版本 http://npm.taobao.org/mirrors/chromedriver/ 放到目录 C:\Users\yuandongliang\AppData\Local\Programs\Python\Python37...

叫我去学习 294

selenium安装以及chromedriver安装与环境配置

目录 一、selenium安装 二、Chromedriver安装 1、查看谷歌版本 2、下载chromedriver​ 三、环境配置 1、将chromedriver.exe位置到path环境变量实现 2、验证Chromedriver是否安装成功 一、selenium安装 打开pycharm 如果在安装selenium出现no such option:--build-dir问题可以看我另一篇博客。 Pycharm中pip:no such option: --buil..

qq_54715996的博客 3317

python搭建selenium_了解搭建selenium安装以及配置环境

之前带大家了解过很多关于python的安装程序,本期也不例外,现在就带大家了解selenium的安装教程以及配置内容。安装包:python开发工具:pyCharm开源版本Python安装过程:1、双击已下载的python安装包,进入第一步2、设置安装目录,这里默认即可3、设置要安装的可选包,全选是最佳的方式4、安装过程如下,坐等即可5、安装完成,单击“Finish”完成安装6、打开命令行,输入py...

weixin_39631263的博客 73
上一篇: Python基础22—Python项目开发规范(2022年)
下一篇: random和json
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值