为什么在Azure Pipelines中,驱动程序路径不正确,并且像Linux一样执行而不是Win
我想在Azure管道中执行自动测试,但我收到以下错误:
selenium.common.exceptions.webdriverexception:消息:消息:未知错误:c chrome biary at C:\ program files \ google \ chrome \ chrome \ chrome \ chrome \ chrome \ chrome
bu bu bu bu bu bu bu bu bu bu bu bu bu bu bu bu Chrome.exe位于此路径上,不应该有任何问题。因此,根据我的初步调查,问题与以下事实有关:在Azure管道中,它试图通过以下路径获得Chromedriver:
WDM:logger.py:16 Current google-chrome version is 102.0.5005
INFO WDM:logger.py:16 Get LATEST chromedriver version for 102.0.5005 google-chrome
INFO WDM:logger.py:16 Driver [/home/vsts/.wdm/drivers/chromedriver/linux64/102.0.5005.61/chromedriver] found in cache
如您所见,有指示的Linux64,但请从我本地的计算机上查找以下日志。
在本地,如果我试图运行相同的测试用例,我会看到不同的路径,并且一切都在运行和正确传递。由于有Win32,而不是Linux64。
[WDM] - Current google-chrome version is 102.0.5005
[WDM] - Get LATEST chromedriver version for 102.0.5005 google-chrome
[WDM] - Driver [C:\Users\AYTAN\.wdm\drivers\chromedriver\win32\102.0.5005.61\chromedriver.exe] found in cache
因此,我不明白为什么在本地机器上,Chromedriver的路径是正确的,但是在Azur管道中,这是不正确的。我如何解决?也许我可以在代码中直接指示它?我的Python代码如下:
@pytest.fixture
def get_chrome_options():
options = chrome_options()
options.add_argument('chrome')
options.binary_location = r"C:\Program Files\Google\Chrome\Application\chrome.exe"
options.chrome_driver_binary = r"C:\Users\USER\.wdm\drivers\chromedriver\win32\102.0.5005.61\chromedriver.exe"
options.add_argument("--start-maximized")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
return options
@pytest.fixture
def get_webdriver(get_chrome_options):
options = get_chrome_options
driver = webdriver.Chrome(options=options, service=Service(ChromeDriverManager().install()))
return driver
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
例如:
更改它成为
build.sourcesDirectory
。是在这个目录下载源代码的位置。
例如:
参考:
azure devops中的目录
for eg:
changes it becomes
Build.SourcesDirectory
. It is at this directorywhere the source code is downloaded.
for eg:
Reference:
Directories in azure devops