当前位置:网站首页>Selnium checks three conditions when it cannot locate an element
Selnium checks three conditions when it cannot locate an element
2022-07-24 09:53:00 【Salted fish also have dreams】
When the element cannot be located , Generally, 99% of the problems can be solved by checking three situations :
1. Check whether the parent of the positioned element exists frame, If there is , First swith_to.frame() cut-in .
( Check the method : Search directly in the element frame keyword )
2. Check the writing correctness of the positioning , If you use ID、NAME When unable to locate , Please use XPATH Positioning method of positioning elements .
(XPATH Sometimes a single label cannot be located , Please use double positioning , example ://*[@id="Province"]/a/span[@id="searchBtn"])
3. Suppose that neither of the above two methods solves the positioning problem , Please add a forced wait before positioning time.sleep(3)
( After trying the above methods, the problem has not been solved , Please return to 1、2 review )
Be careful : If using js Written , Please use js Location method to locate
js = 'document.getElementByID("su").click();'
driver.excute_script(js)Here is a summary of 5 Kind of js Positioning method
except id It's located in a single element Element object , Everything else is elements The return is list object
1. adopt id obtain
document.getElementById(“id”)2. adopt name obtain
document.getElementsByName(“Name”)The return is list
3. Select elements by tag name
document.getElementsByTagName(“tag”)4. adopt CLASS Class selection element
document.getElementsByClassName(“class”)Compatibility :IE8 Browsers below are not implemented getElementsByClassName Method
5. adopt CSS Selectors select elements
document.querySelectorAll(“css selector")
边栏推荐
- JS string method
- How to solve command 'xxx GCC' not found, but can be installed with:??
- 获取所有股票历史行情数据
- PHP Basics - PHP super global variables
- Raspberry Pie: /bin/sh: 1: bison: not found
- Implementation principle of acid in MySQL
- Es search summary
- [don't bother to strengthen learning] video notes (IV) 2. Dqn realizes maze walking
- PHP log base - monolog knowledge collation
- This article takes you to understand the dynamic memory allocation of C language
猜你喜欢

note: expected ‘void * (***)(void ***)’ but argument is of type ‘void (*)(void *)’
![Calculate CPU utilization [Prometheus]](/img/00/d9f297e3013cabbf3d41be58105fc7.png)
Calculate CPU utilization [Prometheus]
![[note] what is kernel / user space? Let's start with how the CPU runs the program](/img/b5/0ab4f2841faf3573b4502d2cd09069.png)
[note] what is kernel / user space? Let's start with how the CPU runs the program

Spark Learning: build SQL to meet the specified optimization rules
![[STM32 learning] (15) STM32 realizes DHT11 temperature and humidity acquisition and display](/img/f2/6fcd4b2e747b4ceb52a52eda0c1af4.png)
[STM32 learning] (15) STM32 realizes DHT11 temperature and humidity acquisition and display

An article takes you to understand the operation of C language files in simple terms

The heads of the five major international institutions called for urgent action to deal with the global food security crisis
![[STM32 learning] (11) STM32 Mifare_ Use of one (S50) m1s50 (read, write, key modification, control bit interpretation)](/img/fd/4290525914b5146fe0eb653517fef9.png)
[STM32 learning] (11) STM32 Mifare_ Use of one (S50) m1s50 (read, write, key modification, control bit interpretation)

What's the difference between testing / developing programmers' professionalism and salted fish? They don't want to be excellent coders?

Spark Learning: how to choose different association forms and mechanisms?
随机推荐
[STM32 learning] (8) stm32f1 general timer configuration
Detailed LinkedList
Spark Learning: build SQL to meet the specified optimization rules
Spark Learning: Spark implementation of distcp
C#/VB. Net: convert word or EXCEL documents to text
Can the "self-help master" who has survived the economic crisis twice continue to laugh this time?
[STM32 learning] (13) STM32 realizes ultrasonic ranging (hc-sr04)
Why add where exists() to the update select statement? And update with a with statement
Redis configuration serialization
The most complete solution for distributed transactions
Mysql8.0 authorized remote login
Ask you to build a small program server
详解LinkedList
[STM32 learning] (9) stm32f1 general timer realizes simple breathing lamp
What are the 6% annualized products?
MySQL Basics (I) -- SQL Basics
[STM32 learning] (10) stm32f1 general timer realizes pulse counter
Android Version Description security privacy 13
Raspberry Pie: serial port login does not display print information
MySQL query database capacity size