selenium 第二个标签页
时间: 2023-09-11 20:08:27 浏览: 83
在使用Selenium时,可以使用以下代码在第二个标签页打开一个新的网页:
```python
drive=webdriver.Chrome()
drive.get("https://www.baidu.com")
time.sleep(2)
element=drive.find_element(By.Tag_name , "body").send_keys(Keys.CONTROL 't')
time.sleep(1)
windows = drive.window_handles #获取所有句柄
drive.switch_to.window(windows<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [selenium如何添加新标签页](https://blog.csdn.net/qq_48745252/article/details/126316653)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [基于python的selenium-打开关闭第二个页面](https://blog.csdn.net/wkl_venus/article/details/106728628)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文