【发布时间】:2021-11-25 07:14:46
【问题描述】:
我正在为 selenium Python UI 自动化测试运行 git lab ci cd 管道。我的测试在我的本地测试通过。我已经使用下面的代码初始化了谷歌浏览器
driver = chromedriver_autoinstaller.install()
options = webdriver.ChromeOptions()
prefs = {'profile.default_content_setting_values.automatic_downloads': 1}
options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(options=options)
当我运行 GitLab 作业时,我的管道失败并出现以下错误
我还尝试使用远程驱动程序和无头模式- 在无头模式下,大多数测试都失败了。在远程模式下,它不实例化驱动程序。删除驱动代码如下
elif self.browser == 'remote':
driver = webdriver.Remote(options=webdriver.ChromeOptions(), command_executor='http://selenium__standalone-chrome:4444/wd/hub')
我不确定它是否由于 gitlab runner 而发生。或者我是否需要创建我的自定义 gitlab 运行器以在特定机器上运行。 我正在运行 selenium UI 测试,所以不确定在我的案例中使用的 runner 没有在 GUI 模式下运行的设施。
尝试了下面的代码,但仍然是同样的问题
options = Options()
options.binary_location = '/usr/bin/google-chrome'
driver = webdriver.Chrome(options=options,
executable_path='/usr/local/bin/chromedriver')
我正在使用带有图像 joyzoursky/python-chromedriver:3.8 的 -Docker 执行器旋转图像
【问题讨论】:
标签: python-3.x selenium-webdriver gitlab gitlab-ci-runner cicd