admin管理员组

文章数量:1529460

selenium开启chrome浏览器的debug模式

  • 环境变量配置(vim ~/.bash_profile)
# google-chrome
export PATH=$PATH:/Applications/Google\ Chrome.app/Contents/MacOS  
  • 终端命令
mac@mac-lee ~ % Google\ Chrome
正在现有的浏览器会话中打开。
mac@mac-lee ~ % Google\ Chrome -remote-debbugging-port=9222
正在现有的浏览器会话中打开
  • python中代码使用
    def setup_method(self, method):
        chrome_opts = webdriver.ChromeOptions()
        chrome_opts.debugger_address = "127.0.0.1:9222"
        self.driver = webdriver.Chrome(options=chrome_opts)

注意:
1.chrome浏览器终端中debugging的端口一定要和pycharm中的selenium端口对应
2.坑1:使用chrome浏览器的debug模式时,一定要把chrome所有的浏览器全部关闭。

ps:具体配置可参考https://wwwblogs/zhaikunkun/p/12610312.html

问题:
运行不起来,心塞塞:

本文标签: 浏览器模式seleniumchromeDebug