0

I am writing some automation test for a test setup on different Android and IOS devices, and i wanted to make a method on my ADT that returns a locator, that fits the specific platform.

final case object HomeMenu extends MenuPoint {
    override def locator(implicit platform: Platform): String = platform match {
      case Base.Android => "AndroidWidget"
      case Base.Apple => "Apple ID"
      case browser: Base.Browser => ""
    }
  }

i am building the adt with two parameters, the given TestDevice, and the Brand of the app i am testing.

The Brand is where the adt is built, and every clickable element in the adt have the method locator.

so what i want is that i can give the TestDevice in as a parameter, and then it handles the implicit for me so i dont have to give the Platform as parameter to the locator method.

println(MainAppAdt(AndroidSmartPhone("Galaxy S9+"), WebTv).brand.menu.head.locator)
println(MainAppAdt(AppleSmartPhone("iPhone X"),WebTv).brand.menu.head.locator)

I have tried to make a companion object for the AndroidSmartPhone and AppleSmartPhone with the implicit stored there. but it looks like it just takes one of them

  • I think i found a solution, i am creating a new method, that takes the TestDevice, and Brand as parameters, then i have a implicit val in the method that hold the platform, and i handle the MainAppAdt inside the method `def runTest(testDevice: TestDevice,brand: Brand): String = { implicit val platform: Platform = testDevice.platform() MainAppAdt(testDevice,brand).brand.menu.head.locator }` – Jens Holdgaard Pedersen Sep 15 '20 at 10:47
  • Sorry about my bad formating issues, i dont know if this is the most optimal solution – Jens Holdgaard Pedersen Sep 15 '20 at 10:50
  • [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – Dmytro Mitin Sep 17 '20 at 03:10

0 Answers0