Skip to content

Commit

Permalink
Renamed step function layer from lambda to action
Browse files Browse the repository at this point in the history
  • Loading branch information
bjuric committed Nov 9, 2024
1 parent 1608494 commit acf2c77
Show file tree
Hide file tree
Showing 60 changed files with 243 additions and 242 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Replace internal stack of data caches with a single data cache
- Manage settings internally without exposing them as system properties
- Manage implicits at lifecycle level and use scoped boundaries
- Renamed step function layer from lambda to action
- Update dependencies
- Update scala from v3.5.0 to v3.5.2
- Update selenium from v4.25.0 to v4.26.0
Expand Down
12 changes: 6 additions & 6 deletions src/main/scala/gwen/web/eval/WebEngine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ package gwen.web.eval
import gwen.core.ValueLiteral
import gwen.web.eval.binding._
import gwen.web.eval.driver.DriverManager
import gwen.web.eval.lambda.composite._
import gwen.web.eval.lambda.unit._
import gwen.web.eval.action.composite._
import gwen.web.eval.action.unit._

import gwen.core._
import gwen.core.behavior.BehaviorType
import gwen.core.eval.ComparisonOperator
import gwen.core.eval.EvalEngine
import gwen.core.eval.lambda.CompositeStep
import gwen.core.eval.lambda.UnitStep
import gwen.core.eval.action.CompositeStepAction
import gwen.core.eval.action.UnitStepAction
import gwen.core.node.gherkin.Step
import gwen.core.state.EnvState

Expand Down Expand Up @@ -72,7 +72,7 @@ class WebEngine extends EvalEngine[WebContext] {
/**
* Translates composite web engine steps.
*/
override def translateCompositeStep(step: Step): Option[CompositeStep[WebContext]] = {
override def translateCompositeStep(step: Step): Option[CompositeStepAction[WebContext]] = {
step.expression.match {
case r"""(.+)$doStep if(?:(?!\bif\b)) (.+?)$element is( not)?$negation (displayed|hidden|checked|ticked|unchecked|unticked|enabled|disabled)$state""" =>
Some(new IfElementCondition(doStep, element, ElementState.valueOf(state), Option(negation).nonEmpty, this))
Expand Down Expand Up @@ -102,7 +102,7 @@ class WebEngine extends EvalEngine[WebContext] {
* @param step the step to evaluate
* @param ctx the web evaluation context
*/
override def translateStep(step: Step): UnitStep[WebContext] = {
override def translateStep(step: Step): UnitStepAction[WebContext] = {
step.expression match {
case r"""I wait for (.+?)$element text""" =>
new WaitForText(element, None)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Branko Juric, Brady Wood
* Copyright 2021-2024 Branko Juric, Brady Wood
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package gwen.web.eval.lambda.composite
package gwen.web.eval.action.composite

import gwen.web.eval.WebContext
import gwen.web.eval.binding.LocatorBinding
Expand All @@ -23,7 +23,7 @@ import gwen.web.eval.binding.SelectorType

import gwen.core.eval.EvalEngine
import gwen.core.eval.binding.DryValueBinding
import gwen.core.eval.lambda.composite.ForEach
import gwen.core.eval.action.composite.ForEach
import gwen.core.node.GwenNode
import gwen.core.node.gherkin.Step

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Branko Juric, Brady Wood
* Copyright 2021-2024 Branko Juric, Brady Wood
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,13 +14,13 @@
* limitations under the License.
*/

package gwen.web.eval.lambda.composite
package gwen.web.eval.action.composite

import gwen.web.eval.WebContext

import gwen.core.eval.EvalEngine
import gwen.core.eval.binding.DryValueBinding
import gwen.core.eval.lambda.composite.ForEach
import gwen.core.eval.action.composite.ForEach
import gwen.core.node.GwenNode
import gwen.core.node.gherkin.Step

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
package gwen.web.eval.lambda.composite
/*
* Copyright 2022-2024 Branko Juric, Brady Wood
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package gwen.web.eval.action.composite

import gwen.core.Errors.UnboundAttributeException
import gwen.core.eval.EvalContext
import gwen.core.eval.EvalEngine
import gwen.core.eval.binding.LoadStrategyBinding
import gwen.core.eval.engine.StepDefEngine
import gwen.core.eval.lambda.CompositeStep
import gwen.core.eval.lambda.composite.IfCondition
import gwen.core.eval.action.CompositeStepAction
import gwen.core.eval.action.composite.IfCondition
import gwen.core.node.GwenNode
import gwen.core.node.gherkin.Annotations
import gwen.core.node.gherkin.Scenario
Expand All @@ -22,23 +38,7 @@ import scala.util.Try
import scala.util.Success
import scala.util.Failure

/*
* Copyright 2022 Branko Juric, Brady Wood
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

class IfElementCondition[T <: EvalContext](doStep: String, element: String, state: ElementState, negate: Boolean, engine: StepDefEngine[WebContext]) extends CompositeStep[WebContext](doStep) {
class IfElementCondition[T <: EvalContext](doStep: String, element: String, state: ElementState, negate: Boolean, engine: StepDefEngine[WebContext]) extends CompositeStepAction[WebContext](doStep) {
override def apply(parent: GwenNode, step: Step, ctx: WebContext): Step = {
val cond = s"$element is${if (negate) " not" else ""} $state"
val ifCondition = IfCondition(doStep, cond, false, 0, engine)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Branko Juric, Brady Wood
* Copyright 2023-2024 Branko Juric, Brady Wood
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,13 +14,13 @@
* limitations under the License.
*/

package gwen.web.eval.lambda.composite
package gwen.web.eval.action.composite

import gwen.web.eval.ElementState
import gwen.web.eval.WebContext
import gwen.web.eval.WebEngine

import gwen.core.eval.lambda.composite.Repeat
import gwen.core.eval.action.composite.Repeat

import scala.concurrent.duration.Duration

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Branko Juric, Brady Wood
* Copyright 2021-2024 Branko Juric, Brady Wood
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,21 +14,21 @@
* limitations under the License.
*/

package gwen.web.eval.lambda.unit
package gwen.web.eval.action.unit

import gwen.web.eval.WebContext
import gwen.web.eval.WebSettings

import gwen.core.behavior.BehaviorType
import gwen.core.eval.lambda.UnitStep
import gwen.core.eval.action.UnitStepAction
import gwen.core.node.GwenNode
import gwen.core.node.gherkin.Step

import scala.util.chaining._

import org.apache.commons.text.StringEscapeUtils

class AppendNewLineToElement(element: String) extends UnitStep[WebContext] {
class AppendNewLineToElement(element: String) extends UnitStepAction[WebContext] {

override def apply(parent: GwenNode, step: Step, ctx: WebContext): Step = {
step tap { _ =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Branko Juric, Brady Wood
* Copyright 2021-2024 Branko Juric, Brady Wood
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,19 +14,19 @@
* limitations under the License.
*/

package gwen.web.eval.lambda.unit
package gwen.web.eval.action.unit

import gwen.web.eval.WebContext
import gwen.web.eval.WebSettings

import gwen.core.behavior.BehaviorType
import gwen.core.eval.lambda.UnitStep
import gwen.core.eval.action.UnitStepAction
import gwen.core.node.GwenNode
import gwen.core.node.gherkin.Step

import scala.util.chaining._

class AppendTextToElement(element: String, value: String, bound: Boolean) extends UnitStep[WebContext] {
class AppendTextToElement(element: String, value: String, bound: Boolean) extends UnitStepAction[WebContext] {

override def apply(parent: GwenNode, step: Step, ctx: WebContext): Step = {
step tap { _ =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 Branko Juric, Brady Wood
* Copyright 2021-2024 Branko Juric, Brady Wood
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,20 +14,20 @@
* limitations under the License.
*/

package gwen.web.eval.lambda.unit
package gwen.web.eval.action.unit

import gwen.web.eval.WebContext

import gwen.core.behavior.BehaviorType
import gwen.core.eval.ComparisonOperator
import gwen.core.eval.lambda.UnitStep
import gwen.core.eval.action.UnitStepAction
import gwen.core.node.GwenNode
import gwen.core.node.gherkin.Step

import scala.concurrent.duration.Duration
import scala.util.chaining._

class AssertBrowserCount(expectedCount: Int, message: Option[String]) extends UnitStep[WebContext] {
class AssertBrowserCount(expectedCount: Int, message: Option[String]) extends UnitStepAction[WebContext] {

override def apply(parent: GwenNode, step: Step, ctx: WebContext): Step = {
step tap { _ =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 Branko Juric, Brady Wood
* Copyright 2021-2024 Branko Juric, Brady Wood
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,20 +14,20 @@
* limitations under the License.
*/

package gwen.web.eval.lambda.unit
package gwen.web.eval.action.unit

import gwen.web.eval.WebContext

import gwen.core.behavior.BehaviorType
import gwen.core.eval.ComparisonOperator
import gwen.core.eval.lambda.UnitStep
import gwen.core.eval.action.UnitStepAction
import gwen.core.node.GwenNode
import gwen.core.node.gherkin.Step

import scala.concurrent.duration.Duration
import scala.util.chaining._

class AssertBrowserWindowCount(expectedCount: Int, message: Option[String]) extends UnitStep[WebContext] {
class AssertBrowserWindowCount(expectedCount: Int, message: Option[String]) extends UnitStepAction[WebContext] {

override def apply(parent: GwenNode, step: Step, ctx: WebContext): Step = {
step tap { _ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
* limitations under the License.
*/

package gwen.web.eval.lambda.unit
package gwen.web.eval.action.unit

import gwen.web.eval.ElementEvent
import gwen.web.eval.WebContext

import gwen.core.behavior.BehaviorType
import gwen.core.eval.binding.JSBinding
import gwen.core.eval.lambda.UnitStep
import gwen.core.eval.action.UnitStepAction
import gwen.core.node.GwenNode
import gwen.core.node.gherkin.Step

import scala.util.chaining._

class BindActionHandler(element: String, event: ElementEvent, javascript: String) extends UnitStep[WebContext] {
class BindActionHandler(element: String, event: ElementEvent, javascript: String) extends UnitStepAction[WebContext] {

override def apply(parent: GwenNode, step: Step, ctx: WebContext): Step = {
step tap { _ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
* limitations under the License.
*/

package gwen.web.eval.lambda.unit
package gwen.web.eval.action.unit

import gwen.web.eval.WebContext
import gwen.web.eval.binding.RelativeSelectorType
import gwen.web.eval.binding.SelectorType
import gwen.web.eval.binding.LocatorKey

import gwen.core.behavior.BehaviorType
import gwen.core.eval.lambda.UnitStep
import gwen.core.eval.action.UnitStepAction
import gwen.core.node.GwenNode
import gwen.core.node.gherkin.Step

import scala.util.chaining._

class BindElementLocator(name: String, selectorType: SelectorType, expression: String, relative: Option[(RelativeSelectorType, String, Option[Int])], timeoutSecs: Option[Long], index: Option[Int]) extends UnitStep[WebContext] {
class BindElementLocator(name: String, selectorType: SelectorType, expression: String, relative: Option[(RelativeSelectorType, String, Option[Int])], timeoutSecs: Option[Long], index: Option[Int]) extends UnitStepAction[WebContext] {

override def apply(parent: GwenNode, step: Step, ctx: WebContext): Step = {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* limitations under the License.
*/

package gwen.web.eval.lambda.unit
package gwen.web.eval.action.unit

import gwen.web.eval.WebContext
import gwen.web.eval.binding.RelativeSelectorType
import gwen.web.eval.binding.SelectorType
import gwen.web.eval.binding.LocatorKey

import gwen.core.behavior.BehaviorType
import gwen.core.eval.lambda.UnitStep
import gwen.core.eval.action.UnitStepAction
import gwen.core.node.GwenNode
import gwen.core.node.gherkin.Step

Expand All @@ -31,7 +31,7 @@ import scala.util.Try
import scala.util.Failure
import scala.util.Success

class BindMultipleElementLocators(name: String, container: Option[String], timeoutSecs: Option[Long], index: Option[Int]) extends UnitStep[WebContext] {
class BindMultipleElementLocators(name: String, container: Option[String], timeoutSecs: Option[Long], index: Option[Int]) extends UnitStepAction[WebContext] {

override def apply(parent: GwenNode, step: Step, ctx: WebContext): Step = {
step tap { _ =>
Expand Down
Loading

0 comments on commit acf2c77

Please sign in to comment.