Hi, I am experiencing an error when I click a button using Wallaby.Browser.click which takes the user to a new page. I can see when using require IEx
& IEx.pry()
(to run through the code step by step) that the button is clicked I am directed to a new page, however the step fails with the error below. Also I believe the issue is around navigating to a new page, the click seems to still be searching for the button after the action.
** (Wallaby.StaleReferenceError) The element you are trying to reference is stale or no longer attached to the
DOM. The most likely reason is that it has been removed with JavaScript.
You can typically solve this problem by using `find` to block until the DOM is in a
stable state.
(wallaby 0.29.1) lib/wallaby/element.ex:92: Wallaby.Element.click/2
(wallaby 0.29.1) lib/wallaby/browser.ex:941: Wallaby.Browser.find/3
(acceptance 1.10.0) lib/acceptance.ex:1631: Acceptance.step_login_in_the_client_with_password_and_username/2
(acceptance 1.10.0) lib/cucumber.ex:90: Acceptance.Cucumber.apply_step/5
(elixir 1.13.3) lib/enum.ex:4475: Enumerable.List.reduce/3
(elixir 1.13.3) lib/enum.ex:2442: Enum.reduce_while/3
(acceptance 1.10.0) lib/cucumber.ex:224: Acceptance.Cucumber.run_step/3
(elixir 1.13.3) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
My code is below:
defstep "login in the client with <password> and <username>" do
url = "http://localhost:8000"
setup_wallaby_for_admin!()
session =
Wallaby.start_session()
|> then(fn {:ok, session} -> session end)
|> Wallaby.Browser.visit(url)
welcome=
session
|> Wallaby.Browser.fill_in(Wallaby.Query.css("#session_login"), with: "uname")
|> Wallaby.Browser.fill_in(Wallaby.Query.css("#session_password"), with: "pass")
|> Wallaby.Browser.click(Wallaby.Query.button("Sign In"))
welcome
|> Wallaby.Browser.take_screenshot(name: "test1")
|> Wallaby.Browser.find(Wallaby.Query.css(".body-container"))
:ok = Wallaby.end_session(session)
end