当前位置:网站首页>框架跳转导致定位失败的解决方法
框架跳转导致定位失败的解决方法
2022-06-26 08:30:00 【冯大少】
相信大多数的Selenium初学者都会遇到莫名其妙的定位的element找不到的报错,其实除了人为的粗心写错语法、属性值、又或者还没有等待所需要定位的element在页面加载完成外,主要原因是框架跳转和超链接跳转的问题。
关于超链接跳转的多窗转换,这里就不再重复介绍,详细可用看我之前博客的测试文章。如下图,在登录后,例如“企业网站”的 “去管理”这个超链接的 label,是在 iframe这框架里,所以在定位前,必须先跳转到这个框架里。由于该网站对所有超链接都是用 js 去隐藏达到反爬目的,因此在我们定位点击后,就会自动打开新的标签页,然后通过窗口转换,就可以爬取相对应的 URL 。
在自动化测试中,除了要熟练掌握定位之外,还需要掌握前端的通过 js 对 各种 element attribution value 的 增、删、改方法。相关的方法可以参考我之前的博客。
browser.switch_to_frame('mainFrame')
link = browser.find_element_by_link_text('去管理>')

边栏推荐
- Monitor iPad Keyboard Display and hide events
- XXL job configuration alarm email notification
- Whale conference provides digital upgrade scheme for the event site
- How to use leetcode
- Jupyter的安装
- Detailed explanation of self attention & transformer
- static const与static constexpr的类内数据成员初始化
- First character that appears only once
- SQL learning experience (II): question brushing record
- WBC learning notes (I): manually push WBC formula
猜你喜欢

Apple motherboard decoding chip, lightning Apple motherboard decoding I.C

Design of reverse five times voltage amplifier circuit

Implementation of ffmpeg audio and video player

Discrete device ~ resistance capacitance

Relationship extraction --tplinker

Comparison between Apple Wireless charging scheme and 5W wireless charging scheme

Playing card image segmentation

Structure diagram of target detection network

And are two numbers of S

51 MCU project design: Based on 51 MCU clock perpetual calendar
随机推荐
STM32 project design: smart home system design based on stm32
Deploy wiki system Wiki in kubesphere JS and enable Chinese full-text retrieval
ZLMediaKit推流拉流测试
FFmpeg音视频播放器实现
keras_ Callback function summary
Using transformers of hugging face to realize multi label text classification
WBC learning notes (II): practical application of WBC control
【Unity Mirror】NetworkTeam的使用
73b2d wireless charging and receiving chip scheme
VS2005 compiles libcurl to normaliz Solution of Lib missing
Tensorboard
(5) Matrix key
SQL learning experience (II): question brushing record
Embedded Software Engineer (6-15k) written examination interview experience sharing (fresh graduates)
2020-10-20
Detailed explanation of traditional image segmentation methods
Installation of jupyter
Whale conference one-stop intelligent conference system helps organizers realize digital conference management
Opencv learning notes 3
Nebula diagram_ Object detection and measurement_ nanyangjx