You are viewing a plain text version of this content. The canonical link for it is here.
Posted to geb-notifications@groovy.apache.org by "jonnybot0 (via GitHub)" <gi...@apache.org> on 2025/06/24 17:08:46 UTC

Re: [PR] Support Navigator as JS execution argument [groovy-geb]

jonnybot0 commented on code in PR #274:
URL: https://github.com/apache/groovy-geb/pull/274#discussion_r2164513621


##########
module/geb-core/src/main/groovy/geb/js/JavascriptInterface.groovy:
##########
@@ -67,7 +68,21 @@ class JavascriptInterface {
             throw new GebException("driver '$driver' can not execute javascript")
         }
 

Review Comment:
   Hrm. I reckon this works, but it seemed a little hacky.
   
   What about having a method with an explicit type signature?
   ```
       def exec(Navigator navigator, String script) {
           def element = navigator.size() == 1 ? navigator.singleElement() : navigator.allElements()
           def args = [element].toArray()
           execjs(script, args)
       }
   ```
   
   I guess the problem there is that you couldn't pass in arbitrary arguments in any order, and order matters for interpolation. 🤔 
   
   Can't think of a better way, given the underlying API, though filtering arguments by type after the fact feels dodgy. :) 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: geb-notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org