[英]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.