python之selenium中的窗口切换

前提:触发一个事件打开一个新的窗口

1,先获取所有的句柄:

复制代码
handles = driver.window+handlers

2,获取当前窗口

复制代码
cururl = driver.current_url

3,循环遍历所有句柄

复制代码
for handle in handles:
	driver.switch_to.window(handle)
	if cururl  == '目标窗口'
	break

方式二:

1,获取当前句柄

driver.current_window.handle

2,获取所有句柄

windows = driver.window_handles

3,切换句柄

driver.switch_to.window(windows[-1])

相关推荐
gc_22993 小时前
学习Python中Selenium模块的基本用法(1:简介)
python·selenium
软件测试-阿涛18 小时前
【性能测试】Jmeter+Grafana+InfluxDB+Prometheus Windows安装部署教程
测试工具·jmeter·性能优化·压力测试·grafana·prometheus
小马哥编程19 小时前
如何解决 undetected_chromedriver 启动慢问题
chrome·selenium·ui
惜.己1 天前
pytest中使用skip跳过某个函数
开发语言·python·测试工具·pytest
慧都小项2 天前
自动化UI测试工具TestComplete的AI双引擎:即时数据集 + 自愈测试
自动化测试·测试工具·llm·数据驱动测试·hipaa标准
alien爱吃蛋挞2 天前
Postman
测试工具·postman
程序员小远2 天前
Pytest+Selenium UI自动化测试实战实例
自动化测试·软件测试·python·selenium·测试工具·ui·pytest
Feng.Lee3 天前
接口测试Postman工具高级使用技巧
功能测试·测试工具·lua·postman·可用性测试