python - 使用 Selenium Web 驱动程序为每个选项卡进行一个 session ?

标签 python python-3.x selenium selenium-webdriver browser

我想为我打开的每个选项卡创建一个新 session ,然后使用 Selenium python 单独控制 session 。这可能吗?

最佳答案

@reynoldsnp: Firefox has an official addon that does this, but I'm not sure if you can get selenium to interact with the addon. addons.mozilla.org/en-GB/firefox/addon/multi-account-containers If you figure out a way to do it, I would love to know how.


(由于我的声誉评分,我还不能发表评论,因此引用了评论)。
我不知道如何与扩展程序进行实际交互,但如果您有一组已知的站点,您想打开:
尝试这个:
  • 使用 selenium 制作一个 firefox 配置文件。 Multiple profiles

    Windows 8/8.1/10: Press Win + R on your keyboard. Type firefox --new-instance --ProfileManager


  • 通过在设置向导中选择新配置文件,在该配置文件中打开 Firefox。在该配置文件中安装扩展。

  • selecting profile top open firefox with
  • 在扩展中设置您想要的容器,默认情况下,打开特定站点。

  • BY default open up sites with a container
    default opening sites
    确保选中该复选框。
  • 使用该配置文件启动 selenium,如下所示:
  • from selenium import webdriver
    
    profile = webdriver.FirefoxProfile('path/to/your/profile') # on windows found here: %APPDATA%/Mozilla/Firefox/Profiles
    
    driver = webdriver.Firefox(firefox_profile=profile) 
    
  • 使用 selenuium 在选项卡、有效容器之间导航。
  • 关于python - 使用 Selenium Web 驱动程序为每个选项卡进行一个 session ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63207605/

    相关文章:

    java - 我收到错误 java.lang.ClassCastException :

    python - 尝试使用flask-security注册用户时出现"TypeError: hashpw() argument 1 must be str, not bytes"

    python - 在 ffmpeg 函数参数中传递字节而不是文件路径

    mysql - 在 Python 中使用 mysql.connector 执行 MySQL 触发器,该触发器计算值并将其插入到现有表中新创建的列中

    java - 如何使用以 Selenium 中的文本开头的类名查找元素

    java - 使用 Selenium 自动移动到 SlideShare 的下一张幻灯片

    python - 推特/通用分类训练语料库

    python - 尝试按对象将行附加到组中的每个组时出现奇怪的行为

    python - 在 ". ","! "或 "? "上拆分字符串,保留标点符号

    Python,嵌套循环打印在一行,多份