@@ -497,6 +497,59 @@ All Gherkin steps that match the DSL expressions described here are readily exec
497
497
</div >
498
498
</details >
499
499
500
+ <details id = " name-is-defined-by-js-function-applied-to-element" >
501
+ <summary class = " dsl" >
502
+
503
+ ``` gherkin
504
+ <name> is defined by <javascriptRef> applied to <element>
505
+ ```
506
+ <p >Applies a JavaScript function to an element and binds the result to <code >< ; name> ; </code > in the global scope.</p >
507
+ </summary >
508
+ <p >Where</p >
509
+ <ul >
510
+ <li ><code >< ; name> ; </code > is the name to bind the function result to</li >
511
+ <li ><code >< ; javascriptRef> ; </code > is the name of the binding containing the javascript single argument function to apply</li >
512
+ <li ><code >< ; element> ; </code > is the name of the web element to apply the function to</li >
513
+ </ul >
514
+ <p >
515
+ Optionally accepts the <Link href = " /docs/eager-or-lazy" ><code >@Eager </code >, <code >@Lazy </code ></Link > or <code >@Masked </code > annotations.
516
+ <ul >
517
+ <li ><code >@Eager </code > immediately applies the function to the element and binds the result to <code >< ; name> ; </code ></li >
518
+ <li ><code >@Lazy </code > applies the function to the element and binds the result to <code >< ; name> ; </code > when it is first referenced</li >
519
+ <li >In the absence of either of the above annotations, the function is applied to the element every time <code >< ; name> ; </code > is referenced</li >
520
+ <li ><code >@Masked </code > masks the captured value to prevent it from being logged as clear text</li >
521
+ </ul >
522
+ </p >
523
+ <p >Examples</p >
524
+
525
+ ``` gherkin {3}
526
+ Given getHref is defined by js "(elem) => elem.getAttribute('href')"
527
+ And the todo link can be located by xpath "//a[contains(text(),'TodoMVC')]"
528
+ And href is defined by getHref applied to the todo link
529
+ When I navigate to "https://todomvc.com/examples/react/dist/"
530
+ Then href should be "http://todomvc.com"
531
+ ```
532
+
533
+ ``` gherkin {9}
534
+ Given getHref is defined by js
535
+ """
536
+ (elem) => {
537
+ return elem.getAttribute('href')
538
+ }
539
+ """
540
+ And the todo link can be located by xpath "//a[contains(text(),'TodoMVC')]"
541
+ When I navigate to "https://todomvc.com/examples/react/dist/"
542
+ And @Eager href is defined by getHref applied to the todo link
543
+ Then href should be "http://todomvc.com"
544
+ ```
545
+
546
+ <div class = " grid-3" >
547
+ <div ><Link to = " #name-is-defined-by-js-function-applied-to-element" >Link</Link ></div >
548
+ <div align = " center" ></div >
549
+ <div align = " right" >Since <Link to = " https://github.com/gwen-interpreter/gwen-web/releases/tag/v4.6.0" >v4.6.0</Link ></div >
550
+ </div >
551
+ </details >
552
+
500
553
#### System Processes bindings
501
554
502
555
<details id = " name-is-defined-by-system-process-expression" >
0 commit comments