Rails Github Action 无法填写操作文本

问题描述 投票:0回答:2

使用 Rails 6.1.4,以下内容可在本地工作以在系统测试中填写富文本(操作文本):

find("trix-editor").set("Something")

但是,在 GitHub 操作上运行时,我收到:

Capybara::ElementNotFound: Unable to find visible css "trix-editor"

将代码更改为:

find("trix-editor", visible: false).set("Something")

也可以在本地运行,但在 GitHub CI 上再次失败:

Selenium::WebDriver::Error::ElementNotInteractableError: element not interactable

我还尝试过以下方法:

find("#unique_element_id").set("Something")
find(:css, ".trix-content").click.set("Something")

我在本地和 GitHub CI 映像上运行 Ubuntu 20.04。我该如何解决这个问题?

编辑:

我发现有一些未合并的 Rails 代码应该可以做到这一点。然而,在我的

test_helper
中实现它也可以在本地工作,但在 CI 上失败。也许我只需要尝试另一个 CI 提供商

ruby-on-rails capybara github-actions
2个回答
0
投票

您可以尝试等到元素显示为:

element = wait.until { driver.find_element(:class => "trix-editor") }
element.click


0
投票

我也遇到了类似的问题,测试在本地通过,但在 GitHub 上使用 Capybara::ElementNotFound 失败。就我而言,测试实际上被破坏了,但在本地,我有一些旧的编译资产残留在周围,无论如何它都通过了。我可以通过删除 public/assets 和 public/packs-test 来解决这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.