当前位置:网站首页>Selenium basic knowledge automatic search
Selenium basic knowledge automatic search
2022-07-24 07:36:00 【everyone_ yi】
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
driver=webdriver.Edge()
driver.get("https://www.baidu.com")
inputTag=driver.find_element(By.ID,'kw')
time.sleep(2)
inputTag.send_keys('python')
submit=driver.find_element(By.ID,'su')
submit.click()
Automatic login Baidu network disk card in the button step Just try a simple button first This is feasible But this is also used id Positioning instead of class
Change to use class After positioning You can enter keywords But you can't click the button
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
driver=webdriver.Edge()
driver.get("https://www.baidu.com")
inputTag=driver.find_element(By.CLASS_NAME,'s_ipt')
time.sleep(2)
inputTag.send_keys('python')
submit=driver.find_element(By.CLASS_NAME,'bg s_btn')
submit.click()
An error is as follows , Can't locate :


Three changes
submit=driver.find_element(By.CLASS_NAME,'s_btn')
submit.click()
Change it to this way because classname There are spaces in So only take part
But I don't quite understand why I didn't locate the previous element
Reference resources :selenium+python automation ——class location :class Property has spaces
边栏推荐
- Buddy: core function entry
- Advanced part of C language IV. detailed explanation of user-defined types
- Reptile learning - Overview
- Bookkeeping app: xiaoha bookkeeping 2 - production of registration page
- Oauth2==sso three protocols. Oauth2 four modes
- oracle中有A,B连个表,这两个表需要第三个表C关联,那怎么将A表中的字段MJ1更新为B表中MJ2的值
- 学习笔记-分布式事务理论
- C language to achieve mine sweeping game
- C language advanced part III. string functions and memory operation functions
- File upload and download demo
猜你喜欢

Mitre att & CK ultra detailed learning notes-02 (a large number of cases)

Unable to auto assemble, bean of type "redistemplate" not found

【sklearn】tree.DecisionTreeClassifier

requests-爬虫多页爬取肯德基餐厅位置

Deep learning two or three things - review those classical convolutional neural networks

系统集成项目管理工程师(软考中级)重点知识、背诵版

Using bidirectional linked list to realize stack (c)

sqli-labs简单安装

Single Gmv has increased 100 times. What is the "general rule" behind the rise of popular brands?

二维平面多段线Y轴最短距离
随机推荐
Learning notes - distributed transaction theory
【sklearn】PCA
Source code analysis of Nacos configuration center
【云原生】MySql索引分析及查询优化
System integration project management engineer (soft test intermediate) key knowledge, recitation version
【FreeRTOS】11 软件定时器
C language to achieve mine sweeping game
requests-爬虫多页爬取肯德基餐厅位置
MITRE ATT&CK超详细学习笔记-01(背景,术语,案例)
Sense dimension design responsive layout
[steering wheel] the super favorite idea efficiency artifact save actions is uninstalled
Introduction to C language v First understanding pointer VI. first understanding structure
FlinkSQL-UDF自定义数据源
Customization or GM, what is the future development trend of SaaS in China?
Introduction to C language
XSS vulnerability learning
C language file operation
Advanced part of Nacos
Notes on the basics of using parameters in libsvm (1)
cloud的版本升级