Elements availibility and handling in dowhile loop

Hi all,

i stuck in this issue from few days and need your expertise: on webpage, sometime link is present and sometime not. if i useed .heck to capture some details of that link like href, i observed errors similar to this during test execution run.
Error: > css((#linkid,Some(href))).find.exists, found nothing

Can someone please help me how to hndle this:

  1. when href value is there, capture it and save in variable using .check
  2. when its not there, then dont throw error
  3. and how to check if that variable hve some value so that i can use in dowhile loop{i tried .exists method and it work in doif but not working in dowhile even i am trying to capturing in dowhile .post request.

Thanks in advance,

1 & 2: use optional https://gatling.io/docs/current/http/http_check/#validating

3: doIf("${foo.exists()}") https://gatling.io/docs/current/session/expression_el/