ijdickinson

ijdickinson

Link following in Wallaby

I’m trying to write a really basic Wallaby test to check that an anchor link navigates the user to the right page. My link:

<a href="/cases/new-case" class="button button__primary ">
  Add a new case
</a>

My test:

session =
  session
  |> visit(~p"/cases")
  |> assert_has(Query.link("Add a new case", count: 1))
  |> click(Query.link("Add a new case"))
  |> assert_has(..predicates to test new page ...)

The problem is that although the assert_has succeeds, and I can see that the link is visible in the browser, the navigation to the new page does not happen - even if I insert a sleep.

This seems like a pretty basic test automation, so I’m really not sure why the link follow is not working. I know I can just visit() the URL of the destination page, but in this test I want to text the UX of clicking on the link. But I have no hypotheses left to explore as to why the link is not being visited, and would welcome any suggestions.

I’m on Ubuntu, using chromedriver-120.0.6099.109 and an identical version of Google Chrome

Most Liked

ijdickinson

ijdickinson

@sodapopcan The additional context, I think, is to do with authentication. The route I’m testing requires user log-in. I’m following this pattern to set a browser cookie as though the user had logged in. From what I can tell, this is allowing me to successfully visit the initial page (/cases/, but not navigate to the second route /cases/new-case), even though both are normally navigable in one session.

I’m only trying the cookie-injection method because I’ve been seeing some non-deterministic failures when I create the same test but replicate the user logging-in at the start of the session. It’s all been a bit frustrating, tbh!

Where Next?

Popular in Questions Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43657 311
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39523 209
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36432 110
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New

We're in Beta

About us Mission Statement