简体   繁体   English

如何在不打开新标签(python)的情况下更改Selenium中的URL?

[英]How to change URL in Selenium without opening new tab (python)?

I saw some .navigate() functions to do that in java but it's not in python.我在 java 中看到一些.navigate()函数可以做到这一点,但它不在 python 中。

So, how can I just change the URL of currently opened window without opening a new tab?那么,如何在不打开新标签的情况下,只更改当前打开的 window 的 URL 呢?

Just call driver.get('yourURL') again.只需再次调用driver.get('yourURL') Example:例子:

driver = webdriver.Chrome()
driver.get('https://google.com')
print(driver.current_url)
driver.get('https://gmail.com/')
print(driver.current_url)

Output: Output:

https://www.google.com/
https://www.google.com/intl/id/gmail/about/#

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python - Selenium:提交表单而不打开新选项卡或新窗口 - Python - Selenium : Submit form without opening new tab or new window Selenium + Python,如何添加带有 url 的新选项卡 - Selenium + Python, How to add new tab with url 如何在Python的Selenium Webdriver的新选项卡中禁用打开页面? - How to disable opening the page in a new tab in Selenium Webdriver in Python? 使用Selenium python(3)打开新选项卡并对其执行功能 - Opening new tab with selenium python(3) and performing functions on it 如何使用 python selenium 在新选项卡中打开链接而不知道其 URL - How to open a link without knowing its URL in new tab using python selenium 在没有焦点的新选项卡中打开 URL - Opening URL in new tab without focus 如何阻止 Selenium Firefox 在新的 Z05B8C74CBD96FBF2DEZ4C13A 中打开 URL? (而不是标签) - How can I stop Selenium Firefox from opening a URL in a new window? (instead of a tab) Python + Selenium WebDriver:在新标签页中打开URL - Python + Selenium WebDriver: open URL in new tab Python和Selenium,无法使用URL打开新标签页吗? - Python and selenium, is not possible to open a new tab with a URL? Selenium Python,通过网站解析,打开一个新标签,并抓取 - Selenium Python, parsing through website, opening a new tab, and scraping
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM