当前位置:网站首页>Solved (the latest version of selenium framework element positioning error) NameError: name 'By' is not defined
Solved (the latest version of selenium framework element positioning error) NameError: name 'By' is not defined
2022-07-31 04:12:00 【no envy】
Resolved (the latest version of selenium framework element positioning error) NameError: name 'By' is not defined
Article table of contents
Error code
A question raised by a small partner of a fan group, an error is reported when operating selenium positioning elements:
Error code:
Error message: NameError: name 'By' is not defined
Error translation
Translation of error content:
Name error: Undefined name "By"
Reason for error
Reason for the error: The latest syntax for element positioning of the selenium framework needs to import the By module, and the code that he does not copy is not imported
Workaround
Import the By module at the beginning:
from selenium.webdriver.common.by import By
Complete code:
from selenium.webdriver.common.by import By# get the first elementbrowser.find_element(by=By.CLASS_NAME, value="element")# Get multiple elementsbrowser.find_elements(by=By.CLASS_NAME, value="element")
边栏推荐
- Why don't you programmers make a living off your own projects?And have to work for someone else?
- Exsl file preview, word file preview web page method
- Safety 20220709
- Basic knowledge of mysql (2)
- (六)枚举、注解
- (4) Recursion, variable parameters, access modifiers, understanding main method, code block
- Component pass value provide/inject
- errno error code and meaning (Chinese)
- The application and practice of mid-to-platform brand advertising platform
- C# 实现PLC的定时器
猜你喜欢
Understanding and Using Unity2D Custom Scriptable Tiles (4) - Start to build a custom tile based on the Tile class (below)
pom文件成橘红色未加载的解决方案
What is a system?
endian mode
浅识Flutter 基本组件之CheckboxListTile组件
No qualifying bean of type question
Knowledge Distillation 7: Detailed Explanation of Knowledge Distillation Code
(8) Math class, Arrays class, System class, Biglnteger and BigDecimal classes, date class
从滴滴罚款后数据治理思考
BP神经网络
随机推荐
[Swift] Customize the shortcut that pops up by clicking the APP icon
SIP Protocol Standard and Implementation Mechanism
A brief introduction to the CheckboxListTile component of the basic components of Flutter
Why SocialFi achievement Web3 decentralized social in the future
C language from entry to such as soil, the data store
log level and print log note
[Paper reading] Mastering the game of Go with deep neural networks and tree search
Safety 20220722
Reinforcement learning: from entry to pit to shit
Redis 统计用户新增和留存
MySQL数据库增删改查(基础操作命令详解)
BUG destroyer!!Practical debugging skills are super comprehensive
No qualifying bean of type 问题
安全20220715
LocalDate加减操作及比较大小
扫雷游戏(c语言写)
type_traits元编程库学习
Pytest e-commerce project combat (on)
[C language] General method of base conversion
Mysql 45 study notes (twenty-four) MYSQL master-slave consistency