• <tfoot id='yAR0L'></tfoot>
  • <legend id='yAR0L'><style id='yAR0L'><dir id='yAR0L'><q id='yAR0L'></q></dir></style></legend>
  • <i id='yAR0L'><tr id='yAR0L'><dt id='yAR0L'><q id='yAR0L'><span id='yAR0L'><b id='yAR0L'><form id='yAR0L'><ins id='yAR0L'></ins><ul id='yAR0L'></ul><sub id='yAR0L'></sub></form><legend id='yAR0L'></legend><bdo id='yAR0L'><pre id='yAR0L'><center id='yAR0L'></center></pre></bdo></b><th id='yAR0L'></th></span></q></dt></tr></i><div id='yAR0L'><tfoot id='yAR0L'></tfoot><dl id='yAR0L'><fieldset id='yAR0L'></fieldset></dl></div>
      <bdo id='yAR0L'></bdo><ul id='yAR0L'></ul>

    <small id='yAR0L'></small><noframes id='yAR0L'>

        在Brave浏览器中使用Selenium传递用Python编写的服务对象

        Use Selenium with Brave Browser pass service object written in python(在Brave浏览器中使用Selenium传递用Python编写的服务对象)

        <legend id='OBqux'><style id='OBqux'><dir id='OBqux'><q id='OBqux'></q></dir></style></legend>
      1. <small id='OBqux'></small><noframes id='OBqux'>

            <bdo id='OBqux'></bdo><ul id='OBqux'></ul>

              <i id='OBqux'><tr id='OBqux'><dt id='OBqux'><q id='OBqux'><span id='OBqux'><b id='OBqux'><form id='OBqux'><ins id='OBqux'></ins><ul id='OBqux'></ul><sub id='OBqux'></sub></form><legend id='OBqux'></legend><bdo id='OBqux'><pre id='OBqux'><center id='OBqux'></center></pre></bdo></b><th id='OBqux'></th></span></q></dt></tr></i><div id='OBqux'><tfoot id='OBqux'></tfoot><dl id='OBqux'><fieldset id='OBqux'></fieldset></dl></div>
                • <tfoot id='OBqux'></tfoot>
                    <tbody id='OBqux'></tbody>
                  本文介绍了在Brave浏览器中使用Selenium传递用Python编写的服务对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  #TLDR我想使用带有用python编写的Selenium的勇敢浏览器,但找不到任何当前可用的解决方案。

                  此代码正常工作

                  from selenium import webdriver
                  option = webdriver.ChromeOptions()
                  option.binary_location = r'C:Program FilesBraveSoftwareBrave- 
                  BrowserApplicationrave.exe'
                  driver = webdriver.Chrome(executable_path=r'C:WebDriverschromedriver.exe', 
                  options=option)
                  driver.get("https://www.google.com")
                  driver.quit()
                  

                  但EXECUTABLE_PATH已弃用:

                  C:UsersUSERPycharmProjectspythonProjectsol2.py:5: 
                  DeprecationWarning: executable_path has been deprecated, please pass in a Service object 
                  driver = webdriver.Chrome(executable_path=r'C:WebDriverschromedriver.exe', options=option)
                  

                  在YouTube上找到此内容:https://www.youtube.com/watch?v=VMzmVFA-Gps

                  # import statements
                  from selenium import webdriver
                  from selenium.webdriver.chrome.service import Service
                  
                  # Declare variables and setup services
                  driverService = Service('C:/webdrivers/chromedriver.exe')   
                  # 1. Passes the chromedriver path to the service object
                  # 2. stores the service object in the s variable
                  driver = webdriver.Chrome(service=driverService)            
                  # 1. Passes service object s into the webdriver.Chrome  
                  # 2. Stores object in driver variable 
                  
                  # Body (actually doing stuff)
                  driver.maximize_window()                # maximizes the browser window
                  driver.get("https://www.google.com")    # navigates to google.com
                  myPageTitle = driver.title              
                  # gets the title of the web page stores in myPageTitle
                  print(myPageTitle)                      # prints myPageTitle to Console
                  assert "Google" in myPageTitle          
                  # checks myPageTitle to ensure it contains Google
                  
                  # clean up
                  driver.quit()                           # closes the browser
                  

                  当我运行此代码时,我得到: selenium.common.exceptions.WebDriverException:消息:未知错误:找不到Chrome二进制文件

                  只要您允许将Google Chrome安装到您的PC上,此代码就可以运行。我不希望在我的电脑上使用Chrome。

                  问题是我想不出如何让Selenium使用Brave而不是Chrome。

                  在撰写本文时,我使用的是以下内容:
                  Windows 11主页
                  Selenium v4.0.0
                  Python V3.10
                  ChromeDriver 95.0.4638.69
                  Brave浏览器版本1.31.91 Chromium:95.0.4638.69(官方版本)(64位)

                  谁能解释一下如何在Brave Browser上使用当前(读取不建议使用的)代码来实现这一点吗?感谢您抽出时间。

                  推荐答案

                  要启动brave浏览上下文,您需要:

                  • 使用binary_location属性指向勇敢的二进制位置。
                  • 使用chromedriver可执行文件启动BRAGE浏览器。

                  挡路代码:

                  from selenium import webdriver
                  from selenium.webdriver.chrome.service import Service
                  
                  option = webdriver.ChromeOptions()
                  option.binary_location = r'C:Program Files (x86)BraveSoftwareBrave-BrowserApplicationrave.exe'
                  driverService = Service('C:/Users/.../chromedriver.exe')
                  driver = webdriver.Chrome(service=driverService, options=option)
                  driver.get("https://www.google.com")
                  

                  注意:DeprecationWarning: executable_path has been deprecated是无害的警告消息,不会影响您的测试执行,您仍然可以忽略它。


                  引用

                  您可以在以下位置找到几个相关的详细讨论:

                  • How to use Brave web browser with python, selenium and chromedriver?
                  • How to initiate Brave browser using Selenium and Python on Windows

                  这篇关于在Brave浏览器中使用Selenium传递用Python编写的服务对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  GUI Freezes while downloading PyQt5 and Pytube(GUI在下载PyQt5和Pytube时冻结)
                  How to solve memory issues while multiprocessing using Pool.map()?(如何解决使用Pool.map()进行多处理时的内存问题?)
                  Python - How to use FastAPI and uvicorn.run without blocking the thread?(Python-如何使用FastAPI和uvicorn.run而不阻塞线程?)
                  How to increment a shared counter from multiple processes?(如何从多个进程递增共享计数器?)
                  Using pika, how to connect to rabbitmq running in docker, started with docker-compose with external network?(使用pika,如何连接运行在docker中的rabbitmq,从docker开始-与外部网络连接?)
                  How to use .rolling() on each row of a Pandas dataframe?(如何对 pandas 数据帧的每一行使用.roll()?)

                  <i id='oWWZo'><tr id='oWWZo'><dt id='oWWZo'><q id='oWWZo'><span id='oWWZo'><b id='oWWZo'><form id='oWWZo'><ins id='oWWZo'></ins><ul id='oWWZo'></ul><sub id='oWWZo'></sub></form><legend id='oWWZo'></legend><bdo id='oWWZo'><pre id='oWWZo'><center id='oWWZo'></center></pre></bdo></b><th id='oWWZo'></th></span></q></dt></tr></i><div id='oWWZo'><tfoot id='oWWZo'></tfoot><dl id='oWWZo'><fieldset id='oWWZo'></fieldset></dl></div>
                • <legend id='oWWZo'><style id='oWWZo'><dir id='oWWZo'><q id='oWWZo'></q></dir></style></legend>
                • <small id='oWWZo'></small><noframes id='oWWZo'>

                      • <bdo id='oWWZo'></bdo><ul id='oWWZo'></ul>

                          1. <tfoot id='oWWZo'></tfoot>
                              <tbody id='oWWZo'></tbody>