【问题标题】:Unable to run Python Selenium Tests on Self Hosted Azure VM无法在自托管 Azure VM 上运行 Python Selenium 测试
【发布时间】:2021-03-17 07:46:08
【问题描述】:

我正在尝试通过 Azure 管道在我的自托管 VM 中执行 Selenium 测试。我收到以下错误消息。

##[错误]架构 x64 的版本规范 3.8 与 Agent.ToolsDirectory 中的任何版本都不匹配。

下面是我的 Yaml

trigger:
- main

pool: default strategy:   matrix:
    Python38:
      python.version: '3.8'
      addToPath: true

steps:
- task: UsePythonVersion@0   inputs:
    versionSpec: '$(python.version)'
    addToPath: true
    architecture: 'x64'   displayName: 'Use Python $(python.version)'

- script: |
    python -m pip install --upgrade pip
    pip install -r requirements.txt   displayName: 'Install dependencies'

- script: |
    pip install pytest-azurepipelines
    pytest tests\test_smoke\test_suite_SmokeTest.py -s -v --browser Chrome --html=report.html --reruns 2   displayName: 'pytest'

- task: DownloadPipelineArtifact@2   inputs:
    buildType: 'specific'
    project: '8801f21d-f4e9-4b65-b01e-68baf825747c'
    definition: '5'
    buildVersionToDownload: 'latest'
    targetPath: '$(Pipeline.Workspace)'

我已经在我的虚拟机中配置了代理。我还在 VM 中安装了 python 3.8.6 并为其配置了 python 路径。

【问题讨论】:

标签: python-3.x selenium-webdriver azure-devops azure-pipelines azure-virtual-machine


【解决方案1】:

无法在自托管 Azure VM 上运行 Python Selenium 测试

要在私有代理上使用此任务,我们需要将所需的 Python 版本添加到自托管代理上的工具缓存中,以便任务使用它。

工具缓存通常位于代理的_work/_tool目录下,或者您可以使用命令行任务回显变量$(Agent.ToolsDirectory)以获取路径。

然后,在该目录下,根据您的 Python 版本创建以下目录结构:

$AGENT_TOOLSDIRECTORY/
    Python/
        {version number}/
            {platform}/
                {tool files}
            {platform}.complete

版本号应遵循 1.2.3 的格式。该平台 应该是 x86 或 x64。工具文件应该是解压缩的 Python 版本文件。 {platform}.complete 应该是一个 0 字节的文件 看起来像 x86.complete 或 x64.complete 只是表示 工具已正确安装在缓存中。

我的测试目录结构:

$AGENT_TOOLSDIRECTORY/
    Python/
        3.9.0/
            x64/
                python-3.9.0-amd64.exe
            x64.complete

现在,它在我的自托管代理上运行良好:

您可以参考the FAQ in this document 了解更多详情。

【讨论】:

  • 谢谢利奥。根据您的屏幕截图配置后,我能够成功运行管道。
猜你喜欢
  • 2020-05-16
  • 2016-07-22
  • 1970-01-01
  • 1970-01-01
  • 2018-07-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多