简体   繁体   English

从同一 chrome 选项卡 (chromedriver) 打开新链接 - Python

[英]Open new link from the same chrome tab (chromedriver) - Python

I open a second tab with the command indicated below.我使用下面指示的命令打开第二个选项卡。 With which command do I open a new link using the same tab?使用哪个命令可以使用同一选项卡打开新链接?

driver.execute_script("window.open('www.example');")

Open a new tab as here and then verify than the correct link is opened How to open a new tab using Selenium WebDriver or here Open web in new tab Selenium + Python Open a new tab as here and then verify than the correct link is opened How to open a new tab using Selenium WebDriver or here Open web in new tab Selenium + Python

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://stackoverflow.com/")

body = driver.find_element_by_tag_name("body")
body.send_keys(Keys.CONTROL + 't')

driver.close()

For asserting use:对于断言使用:

assert driver.title == "Expected page title"

暂无
暂无

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

相关问题 如何使用 Python 中的 Selenium-chromeDriver 在 Chrome 中打开新标签页 - How to open new tab in Chrome with Selenium-chromeDriver in Python 如何使用 Python selenium ChromeDriver 在新标签页中打开链接 - How to open a link in a new tab with Python selenium ChromeDriver Python - 使用 Selenium WebDriver 在新的 Chrome 选项卡中打开链接? - Python - Open a link in new Chrome tab with Selenium WebDriver? 我想在 Webbrowser Python 的同一选项卡中打开新链接 - i want to open new Link in the same tab in Webbrowser Python Selenium Chromedriver启动Chrome,但未打开网站(新的Chromedriver,相同的旧问题) - Selenium Chromedriver launches Chrome, but doesn't open website (new Chromedriver, same old issue) 如何使用python和selenium在新选项卡中打开链接 - How to open a link in a new tab with python and selenium python selenium 在新标签页中打开链接并继续 session 在新标签页中 - python selenium open link in new tab and continue session in new tab Selenium不会在新标签页(Python和Chrome)中打开新的URL - Selenium won't open a new URL in a new tab (Python & Chrome) Chromedriver 不会打开新的 session,它会在现有的 session 中打开一个新选项卡 - Chromedriver do not open a new session, it opens a new tab in a existing session Selenium webdriver在python中的chrome编码中打开一个新选项卡 - Selenium webdriver open a new tab in chrome coding in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM