Testing clojure with kerodon

94 views Asked by At

I'm testing a clojure luminus/selmer application with kerodon. I'm getting a java.lang.IllegalArgumentException: field could not be found with selector "[:#name]" when trying to access an input field with id=name as follows:

(deftest home
  (-> (session app)
      (visit "/")
      (fill-in [:#name] "Peter")
      (fill-in [:#age] "25")
      (press "Sign up!")
      (within [:h1]
              (has (text? "Hello Peter 25")))))
1

There are 1 answers

2
Taha Husain On

Try using text value of label for input field, fill-in accepts text value of label as well as id of elem you need to fill. Refer to the kerodon source, there are tests for both label value and selector.

For example:-

<label for="name">Name</label>
<input type="text" id="name"\>

You can write

(deftest home 
   (-> (session app) 
       (visit "/") 
       (fill-in "Name" "Peter")
        ...))