appium-espresso-driver 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -195,7 +195,7 @@ to mix Espresso and Compose elements.
195
195
  In order to change between subdrivers use the [driver](#settings-api) setting. Setting its value to `compose` modifies driver behavior in the way it interacts with Compose elements rather that with classic Android views. It is possible to switch between `espresso` and `compose` modes at any point of time. When `compose` mode is active the the following webdriver commands behave differently (as of driver version *1.50.0*):
196
196
  - findElement(s): Element finding commands only support Compose-based locators. Read [Compose Elements Location](#compose-elements-location) for more details.
197
197
  - getPageSource: The returned page source is retrieved from Compose and all elements there contain [Compose-specific](#compose-element-attributes) attributes.
198
- - click, isDisplayed, isEnabled, clear, getText, sendKeys, getElementRect, getValue: These commands should properly support compose elements.
198
+ - click, isDisplayed, isEnabled, clear, getText, sendKeys, getElementRect, getValue, isSelected: These commands should properly support compose elements.
199
199
  - getAttribute: Accepts and returns Compose-specific element attributes. See [Compose Element Attributes](#compose-element-attributes) for the full list of supported Compose element attributes.
200
200
 
201
201
  Calling other driver element-specific APIs not listed above would most likely throw an exception as Compose and Espresso elements are being stored in completely separated internal caches and must not be mixed.
@@ -16,15 +16,17 @@
16
16
 
17
17
  package io.appium.espressoserver.lib.handlers
18
18
 
19
- import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
19
+ import io.appium.espressoserver.lib.helpers.getSemanticsNode
20
20
  import io.appium.espressoserver.lib.model.AppiumParams
21
- import io.appium.espressoserver.lib.model.EspressoElement
22
-
23
21
  import io.appium.espressoserver.lib.model.ViewElement
22
+ import io.appium.espressoserver.lib.model.EspressoElement
23
+ import io.appium.espressoserver.lib.model.ComposeNodeElement
24
24
 
25
25
  class GetEnabled : RequestHandler<AppiumParams, Boolean> {
26
26
 
27
- @Throws(AppiumException::class)
28
- override fun handleInternal(params: AppiumParams): Boolean =
29
- ViewElement(EspressoElement.getViewById(params.elementId)).isEnabled
27
+ override fun handleEspresso(params: AppiumParams): Boolean =
28
+ ViewElement(EspressoElement.getViewById(params.elementId)).isEnabled
29
+
30
+ override fun handleCompose(params: AppiumParams): Boolean =
31
+ ComposeNodeElement(getSemanticsNode(params.elementId!!)).isEnabled
30
32
  }
@@ -16,17 +16,22 @@
16
16
 
17
17
  package io.appium.espressoserver.lib.handlers
18
18
 
19
- import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
19
+ import io.appium.espressoserver.lib.helpers.getSemanticsNode
20
20
  import io.appium.espressoserver.lib.model.AppiumParams
21
- import io.appium.espressoserver.lib.model.EspressoElement
22
21
  import io.appium.espressoserver.lib.model.Location
23
22
  import io.appium.espressoserver.lib.model.ViewElement
23
+ import io.appium.espressoserver.lib.model.EspressoElement
24
+ import io.appium.espressoserver.lib.model.ComposeNodeElement
24
25
 
25
26
  class GetLocation : RequestHandler<AppiumParams, Location> {
26
27
 
27
- @Throws(AppiumException::class)
28
- override fun handleInternal(params: AppiumParams): Location {
28
+ override fun handleEspresso(params: AppiumParams): Location {
29
29
  val viewElement = ViewElement(EspressoElement.getViewById(params.elementId))
30
30
  return Location(viewElement.bounds.left, viewElement.bounds.top)
31
31
  }
32
+
33
+ override fun handleCompose(params: AppiumParams): Location {
34
+ val composeNodeElement = ComposeNodeElement(getSemanticsNode(params.elementId!!))
35
+ return Location(composeNodeElement.bounds.left, composeNodeElement.bounds.top)
36
+ }
32
37
  }
@@ -16,18 +16,15 @@
16
16
 
17
17
  package io.appium.espressoserver.lib.handlers
18
18
 
19
- import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
20
19
  import io.appium.espressoserver.lib.model.AppiumParams
21
- import io.appium.espressoserver.lib.model.EspressoElement
22
20
  import io.appium.espressoserver.lib.model.Location
21
+ import io.appium.espressoserver.lib.model.EspressoElement
23
22
  import io.appium.espressoserver.lib.model.ViewElement
24
23
 
25
24
  class GetLocationInView : RequestHandler<AppiumParams, Location> {
26
25
 
27
- @Throws(AppiumException::class)
28
- override fun handleInternal(params: AppiumParams): Location {
29
- val view = EspressoElement.getViewById(params.elementId)
30
- val viewElement = ViewElement(view)
26
+ override fun handleEspresso(params: AppiumParams): Location {
27
+ val viewElement = ViewElement(EspressoElement.getViewById(params.elementId))
31
28
  return Location(viewElement.relativeLeft, viewElement.relativeTop)
32
29
  }
33
30
  }
@@ -16,16 +16,21 @@
16
16
 
17
17
  package io.appium.espressoserver.lib.handlers
18
18
 
19
- import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
19
+ import io.appium.espressoserver.lib.helpers.getSemanticsNode
20
20
  import io.appium.espressoserver.lib.model.AppiumParams
21
- import io.appium.espressoserver.lib.model.EspressoElement
22
21
  import io.appium.espressoserver.lib.model.ViewElement
22
+ import io.appium.espressoserver.lib.model.EspressoElement
23
+ import io.appium.espressoserver.lib.model.ComposeNodeElement
23
24
 
24
25
  class GetName : RequestHandler<AppiumParams, String?> {
25
26
 
26
- @Throws(AppiumException::class)
27
- override fun handleInternal(params: AppiumParams): String? {
27
+ override fun handleEspresso(params: AppiumParams): String? {
28
28
  val view = EspressoElement.getViewById(params.elementId)
29
29
  return ViewElement(view).contentDescription?.toString()
30
30
  }
31
+
32
+ override fun handleCompose(params: AppiumParams): String? {
33
+ val composeNodeElement = ComposeNodeElement(getSemanticsNode(params.elementId!!))
34
+ return composeNodeElement.contentDescription?.toString()
35
+ }
31
36
  }
@@ -16,15 +16,18 @@
16
16
 
17
17
  package io.appium.espressoserver.lib.handlers
18
18
 
19
- import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
19
+ import io.appium.espressoserver.lib.helpers.getSemanticsNode
20
20
  import io.appium.espressoserver.lib.model.AppiumParams
21
+ import io.appium.espressoserver.lib.model.ComposeNodeElement
21
22
  import io.appium.espressoserver.lib.model.EspressoElement
22
23
 
23
24
  import io.appium.espressoserver.lib.model.ViewElement
24
25
 
25
26
  class GetSelected : RequestHandler<AppiumParams, Boolean> {
26
27
 
27
- @Throws(AppiumException::class)
28
- override fun handleInternal(params: AppiumParams): Boolean =
28
+ override fun handleEspresso(params: AppiumParams): Boolean =
29
29
  ViewElement(EspressoElement.getViewById(params.elementId)).isSelected
30
+
31
+ override fun handleCompose(params: AppiumParams): Boolean =
32
+ ComposeNodeElement(getSemanticsNode(params.elementId!!)).isSelected
30
33
  }
@@ -16,17 +16,22 @@
16
16
 
17
17
  package io.appium.espressoserver.lib.handlers
18
18
 
19
- import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
19
+ import io.appium.espressoserver.lib.helpers.getSemanticsNode
20
20
  import io.appium.espressoserver.lib.model.AppiumParams
21
- import io.appium.espressoserver.lib.model.EspressoElement
22
21
  import io.appium.espressoserver.lib.model.Size
23
22
  import io.appium.espressoserver.lib.model.ViewElement
23
+ import io.appium.espressoserver.lib.model.EspressoElement
24
+ import io.appium.espressoserver.lib.model.ComposeNodeElement
24
25
 
25
26
  class GetSize : RequestHandler<AppiumParams, Size> {
26
27
 
27
- @Throws(AppiumException::class)
28
- override fun handleInternal(params: AppiumParams): Size {
28
+ override fun handleEspresso(params: AppiumParams): Size {
29
29
  val bounds = ViewElement(EspressoElement.getViewById(params.elementId)).bounds
30
30
  return Size(bounds.width(), bounds.height())
31
31
  }
32
+
33
+ override fun handleCompose(params: AppiumParams): Size {
34
+ val bounds = ComposeNodeElement(getSemanticsNode(params.elementId!!)).bounds
35
+ return Size(bounds.width(), bounds.height())
36
+ }
32
37
  }
@@ -16,7 +16,6 @@
16
16
 
17
17
  package io.appium.espressoserver.lib.handlers
18
18
 
19
- import io.appium.espressoserver.lib.handlers.exceptions.InvalidElementStateException
20
19
  import io.appium.espressoserver.lib.helpers.getSemanticsNode
21
20
  import io.appium.espressoserver.lib.model.AppiumParams
22
21
  import io.appium.espressoserver.lib.model.ComposeNodeElement