我的代码:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
option = webdriver.ChromeOptions()
driver = webdriver.Chrome(executable_path='./chromedriver.exe', options=option)
driver.get('https://www.google.com/')
Run Code Online (Sandbox Code Playgroud)
输出:
WebDriver.__init__() got an unexpected keyword argument 'executable_path'
Run Code Online (Sandbox Code Playgroud)
我正在尝试创建一个脚本来登录网站。当我尝试运行此脚本时,它给出了以下错误:
WebDriver.__init__() got an unexpected keyword argument 'executable_path'
错误是:
TypeError: WebDriver.__init__() got multiple values for argument 'options'
Run Code Online (Sandbox Code Playgroud)
`
代码是:
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
browser = webdriver.Chrome(r'/usr/bin/chromedriver', options=chrome_options)
Run Code Online (Sandbox Code Playgroud)
这是错误:
TypeError Traceback (most recent call last)
<ipython-input-5-9a7e59e392ae> in <cell line: 6>()
4 chrome_options.add_argument('--headless')
5
----> 6 browser = webdriver.Chrome(r'/usr/bin/chromedriver', options=chrome_options)
TypeError: WebDriver.__init__() got multiple values for argument 'options'
Run Code Online (Sandbox Code Playgroud) python webdriver python-3.x selenium-chromedriver selenium-webdriver
我想运行pytest然后存储结果并根据需要将它们呈现给用户(例如将 pytest 结果存储到数据库,然后通过 Web 服务公开它们)。
我可以pytest从命令行运行,并选择将结果报告保存到文件中,然后查找并解析该文件,但将结果保存在(pytest)python 应用程序中,然后将它们存储到文件中,然后立即执行,这感觉很愚蠢查找该文件,并将其解析回 python 代码以进行进一步处理。
我知道我可以pytest通过编程方式运行pytest.main(args),但是,它只返回一些退出代码,而不返回有关测试结果的详细信息。使用时如何检索结果pytest.main()?
我正在寻找类似的东西:
args = ARGUMENTS
ret_code = pytest.main(args=args) # pytest.main() as is only returns trivial return code
my_own_method_to_process(pytest.results) # how to retrieve any kind of pytest.results object that would contain test execution results data (list of executed tests, pass fail info, etc as pytest is displaying into console or saves into file reports)
Run Code Online (Sandbox Code Playgroud)
有几个类似的问题,但总是有一些对我不起作用的偏差。我只是想从我的代码中运行pytest,并且 - 无论输出是什么格式 - 直接抓取它并进一步处理它。
注意:我处于企业环境中,安装新软件包(即 …
undetected_chromedriver我在使用版本时遇到一些问题Chromium: 116.0.5845.96。这个问题今天才开始,我几乎尝试了我能想到的所有方法,从重新安装模块,到重新安装浏览器,甚至使用version_main=116应该修复它的参数进行测试,但似乎version_main只适用于114.
这是我的代码。
import undetected_chromedriver as uc
driver = uc.Chrome()
driver.get('https://www.example.com')
Run Code Online (Sandbox Code Playgroud)
这是在 Chrome 版本 : 上启动的Version 116.0.5845.97 (Official Build) (64-bit),在控制台中返回此错误。from session not created: This version of ChromeDriver only supports Chrome version 114 Current browser version is 116.0.5845.97
当我运行 Python Selenium 脚本打开网页时出现错误。我尝试卸载并重新安装 selenium、chromeautoinstaller 和未检测到的 chromedriver。我也尝试添加option.add_argument('--headless'). 这些都没有成功,错误仍然存在。
这是我的代码:
def driverInit():
option = uc.ChromeOptions()
option.add_argument("--log-level=3")
prefs = {"credentials_enable_service": False,
"profile.password_manager_enabled": False,
"profile.default_content_setting_values.notifications": 2
}
option.add_experimental_option("prefs", prefs)
driverr = uc.Chrome(options=option)
return driverr
def driverInitBuffMarket():
option = uc.ChromeOptions()
option.add_argument(
rf'--user-data-dir=C:\Users\{os.getlogin()}\AppData\Local\Google\ChromeBuff\User Data') # e.g. C:\Users\You\AppData\Local\Google\Chrome\User Data
option.add_argument(r'--profile-directory=Default')
driverr = uc.Chrome(options=option)
return driver
Run Code Online (Sandbox Code Playgroud)
错误发生在倒数第二行,driverr = uc.Chrome(options=option)
这是错误:
Traceback (most recent call last):
File "C:\Users\kumpd\OneDrive\Desktop\All Market Bots\BuffMarket Purchase Bot Testing\main.py", line 266, in <module>
start_buy_monitoring()
File "C:\Users\kumpd\OneDrive\Desktop\All Market Bots\BuffMarket Purchase Bot Testing\main.py", …Run Code Online (Sandbox Code Playgroud) python google-chrome selenium-chromedriver selenium-webdriver undetected-chromedriver
一起使用这些选项不会按预期工作:
options.add_argument('--disable-javascript')
options.add_argument('--headless')
Run Code Online (Sandbox Code Playgroud)
python google-chrome selenium-chromedriver selenium-webdriver google-chrome-headless