【问题标题】:HOW TO OPEN A NEW TAB USING : Selenium? [duplicate]如何使用 Selenium 打开新标签页? [复制]
【发布时间】:2019-10-29 12:22:49
【问题描述】:

使用 MAC OS 即时尝试使用 selenium firefox webdriver 打开一个新选项卡

url = "https://google.com" 

mail = wd.Firefox()  

mail.get(url)

 time.sleep(1)

 actions = ActionChains(mail) mail.find_element_by_xpath("/html/body/div[2]/div[2]/div[1]/h2/span[2]/span[1]").click() 

time.sleep(1) 

ActionChains(mail).key_down(Keys.COMMAND).send_keys('t').key_up(Keys.COMMAND).perform()  

mail.close()

 mail.quit()

【问题讨论】:

标签: python macos selenium firefox selenium-webdriver


【解决方案1】:

如果你使用的是 chrome/firefox,你可以运行这个 javascript。

window.open("https://google.com","_blank")

Python:

driver.execute_script("window.open('https://google.com','_blank')")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-10
    • 2015-04-10
    • 2020-06-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多