简体   繁体   English

Selenium - 在新选项卡而不是新窗口中打开 Firefox 链接? Python

[英]Selenium - Open firefox links in new tabs not new window? Python

Is there any way I can change selenium firefox settings, so whenever i click a button on website that links to another website for example, that link opens in new tab, not new window?有什么方法可以更改 selenium firefox 设置,因此每当我单击网站上链接到另一个网站的按钮时,该链接将在新选项卡中打开,而不是在新窗口中打开?

I tried making custom profile, but it never worked for me.. always loads with anonymous one.我尝试制作自定义配置文件,但它从来没有为我工作过..总是加载匿名的。

Any help is well appreciated.任何帮助都非常感谢。

You will have to send it via Browser action chaining only as selenium opens an anonymous session everytime.您必须通过浏览器操作链发送它,因为 selenium 每次都会打开一个匿名会话。 So, send click command like this.所以,像这样发送点击命令。

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

ActionChains(driver).send_keys(Keys.COMMAND, "t").perform()

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM