diff --git a/maestro-android/src/androidTest/java/dev/mobile/maestro/MaestroDriverService.kt b/maestro-android/src/androidTest/java/dev/mobile/maestro/MaestroDriverService.kt index 585bb1dd7c..083238f866 100644 --- a/maestro-android/src/androidTest/java/dev/mobile/maestro/MaestroDriverService.kt +++ b/maestro-android/src/androidTest/java/dev/mobile/maestro/MaestroDriverService.kt @@ -378,7 +378,7 @@ class Service( return@post } - newLocation.setTime(System.currentTimeMillis()) + newLocation.time = System.currentTimeMillis() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { newLocation.elapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos() } diff --git a/maestro-cli/src/main/java/maestro/cli/device/DeviceService.kt b/maestro-cli/src/main/java/maestro/cli/device/DeviceService.kt index c4dd3e5935..a62f36c23f 100644 --- a/maestro-cli/src/main/java/maestro/cli/device/DeviceService.kt +++ b/maestro-cli/src/main/java/maestro/cli/device/DeviceService.kt @@ -115,7 +115,7 @@ object DeviceService { fun listConnectedDevices(): List { return listDevices() - .filterIsInstance(Device.Connected::class.java) + .filterIsInstance() } fun List.withPlatform(platform: Platform?) = @@ -123,7 +123,7 @@ object DeviceService { fun listAvailableForLaunchDevices(): List { return listDevices() - .filterIsInstance(Device.AvailableForLaunch::class.java) + .filterIsInstance() } private fun listDevices(): List { @@ -249,11 +249,11 @@ object DeviceService { fun isDeviceAvailableToLaunch(deviceName: String, platform: Platform): Device.AvailableForLaunch? { return if (platform == Platform.IOS) { listIOSDevices() - .filterIsInstance(Device.AvailableForLaunch::class.java) + .filterIsInstance() .find { it.description.contains(deviceName, ignoreCase = true) } } else { listAndroidDevices() - .filterIsInstance(Device.AvailableForLaunch::class.java) + .filterIsInstance() .find { it.description.contains(deviceName, ignoreCase = true) } } } diff --git a/maestro-cli/src/main/java/maestro/cli/device/PickDeviceView.kt b/maestro-cli/src/main/java/maestro/cli/device/PickDeviceView.kt index f46488773a..adb67181e0 100644 --- a/maestro-cli/src/main/java/maestro/cli/device/PickDeviceView.kt +++ b/maestro-cli/src/main/java/maestro/cli/device/PickDeviceView.kt @@ -70,7 +70,7 @@ object PickDeviceView { private fun pickIndex(data: List): T { println() while (!Thread.interrupted()) { - val index = readLine()?.toIntOrNull() ?: 0 + val index = readlnOrNull()?.toIntOrNull() ?: 0 if (index < 1 || index > data.size) { printEnterNumberPrompt() diff --git a/maestro-client/src/main/java/maestro/drivers/AndroidDriver.kt b/maestro-client/src/main/java/maestro/drivers/AndroidDriver.kt index e66a7a87b8..cd23477a80 100644 --- a/maestro-client/src/main/java/maestro/drivers/AndroidDriver.kt +++ b/maestro-client/src/main/java/maestro/drivers/AndroidDriver.kt @@ -658,7 +658,7 @@ class AndroidDriver( return false } - override fun waitForAppToSettle(initialHierarchy: ViewHierarchy?, appId: String?, timeoutMs: Int?): ViewHierarchy? { + override fun waitForAppToSettle(initialHierarchy: ViewHierarchy?, appId: String?, timeoutMs: Int?): ViewHierarchy { return if (appId != null) { waitForWindowToSettle(appId, initialHierarchy, timeoutMs) } else { diff --git a/maestro-client/src/main/java/maestro/drivers/WebDriver.kt b/maestro-client/src/main/java/maestro/drivers/WebDriver.kt index d994cb6c8d..e0b02dde7d 100644 --- a/maestro-client/src/main/java/maestro/drivers/WebDriver.kt +++ b/maestro-client/src/main/java/maestro/drivers/WebDriver.kt @@ -53,10 +53,10 @@ class WebDriver(val isStudio: Boolean) : Driver { } override fun open() { - System.setProperty("webdriver.chrome.silentOutput", "true"); - System.setProperty(ChromeDriverService.CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true"); - Logger.getLogger("org.openqa.selenium").level = Level.OFF; - Logger.getLogger("org.openqa.selenium.devtools.CdpVersionFinder").level = Level.OFF; + System.setProperty("webdriver.chrome.silentOutput", "true") + System.setProperty(ChromeDriverService.CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true") + Logger.getLogger("org.openqa.selenium").level = Level.OFF + Logger.getLogger("org.openqa.selenium.devtools.CdpVersionFinder").level = Level.OFF val driverService = ChromeDriverService.Builder() .withLogLevel(ChromiumDriverLogLevel.OFF) @@ -373,7 +373,7 @@ class WebDriver(val isStudio: Boolean) : Driver { return true } - override fun waitForAppToSettle(initialHierarchy: ViewHierarchy?, appId: String?, timeoutMs: Int?): ViewHierarchy? { + override fun waitForAppToSettle(initialHierarchy: ViewHierarchy?, appId: String?, timeoutMs: Int?): ViewHierarchy { return ScreenshotUtils.waitForAppToSettle(initialHierarchy, this) } diff --git a/maestro-client/src/main/java/maestro/mockserver/MockInteractor.kt b/maestro-client/src/main/java/maestro/mockserver/MockInteractor.kt index bf2ea3c92f..a70134d9ee 100644 --- a/maestro-client/src/main/java/maestro/mockserver/MockInteractor.kt +++ b/maestro-client/src/main/java/maestro/mockserver/MockInteractor.kt @@ -38,8 +38,7 @@ data class GetEventsResponse( val events: List ) -class MockInteractor( -) { +class MockInteractor { private val client = OkHttpClient.Builder() .readTimeout(5, TimeUnit.MINUTES) .writeTimeout(5, TimeUnit.MINUTES) @@ -133,4 +132,4 @@ class MockInteractor( fun main() { MockInteractor().getMockEvents() -} \ No newline at end of file +} diff --git a/maestro-client/src/main/resources/maestro-web.js b/maestro-client/src/main/resources/maestro-web.js index 77944b5068..29b76a04a2 100644 --- a/maestro-client/src/main/resources/maestro-web.js +++ b/maestro-client/src/main/resources/maestro-web.js @@ -62,7 +62,7 @@ for (var n=0;n < allNodes.length;n++) { if (allNodes[n].hasAttribute('id') && allNodes[n].id == domElement.id) uniqueIdCount++; if (uniqueIdCount > 1) break; - }; + } if ( uniqueIdCount == 1) { segs.unshift('id("' + domElement.getAttribute('id') + '")'); return segs.join('/'); @@ -73,10 +73,10 @@ segs.unshift(domElement.localName.toLowerCase() + '[@class="' + domElement.getAttribute('class') + '"]'); } else { for (i = 1, sib = domElement.previousSibling; sib; sib = sib.previousSibling) { - if (sib.localName == domElement.localName) i++; }; + if (sib.localName == domElement.localName) i++; } segs.unshift(domElement.localName.toLowerCase() + '[' + i + ']'); - }; - }; + } + } return segs.length ? '/' + segs.join('/') : null; } }( window.maestro = window.maestro || {} )); diff --git a/maestro-ios-driver/src/main/kotlin/hierarchy/AccessibilityNode.kt b/maestro-ios-driver/src/main/kotlin/hierarchy/AccessibilityNode.kt deleted file mode 100644 index e672c670d0..0000000000 --- a/maestro-ios-driver/src/main/kotlin/hierarchy/AccessibilityNode.kt +++ /dev/null @@ -1,29 +0,0 @@ -package hierarchy - -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize - -@JsonDeserialize(`as` = AccessibilityNode::class) -data class AccessibilityNode( - @JsonProperty("AXFrame") val axFrame: String, - @JsonProperty("AXUniqueId") val axUniqueId: String?, - @JsonProperty("role_description") val roleDescription: String?, - @JsonProperty("AXLabel") val axLabel: String?, - @JsonProperty("content_required") val contentRequired: Boolean?, - @JsonProperty("type") val type: String?, - @JsonProperty("title") val title: String?, - @JsonProperty("custom_actions") val customAction: ArrayList, - @JsonProperty("AXValue") val axValue: String?, - @JsonProperty("role") val role: String?, - @JsonProperty("help") val help: String?, - @JsonProperty("subrole") val subRole: String?, - @JsonProperty("enabled") val enabled: Boolean, - @JsonProperty("frame") val frame: Frame -) { - data class Frame( - val x: Float, - val y: Float, - val width: Float, - val height: Float - ) -} \ No newline at end of file diff --git a/maestro-ios-driver/src/main/kotlin/hierarchy/Frame.kt b/maestro-ios-driver/src/main/kotlin/hierarchy/Frame.kt deleted file mode 100644 index 3e04501e37..0000000000 --- a/maestro-ios-driver/src/main/kotlin/hierarchy/Frame.kt +++ /dev/null @@ -1,10 +0,0 @@ -package hierarchy - -import com.fasterxml.jackson.annotation.JsonProperty - -data class Frame( - @JsonProperty("Width") val width: Float, - @JsonProperty("Height") val height: Float, - @JsonProperty("Y") val y: Float, - @JsonProperty("X") val x: Float -) \ No newline at end of file diff --git a/maestro-orchestra/src/main/java/maestro/orchestra/Orchestra.kt b/maestro-orchestra/src/main/java/maestro/orchestra/Orchestra.kt index 63659f5e8d..ec7d0fcdd2 100644 --- a/maestro-orchestra/src/main/java/maestro/orchestra/Orchestra.kt +++ b/maestro-orchestra/src/main/java/maestro/orchestra/Orchestra.kt @@ -960,7 +960,7 @@ class Orchestra( if (selector == null) { return maestro.viewHierarchy() } - val parentViewHierarchy = findElementViewHierarchy(selector.childOf, timeout); + val parentViewHierarchy = findElementViewHierarchy(selector.childOf, timeout) val (description, filterFunc) = buildFilter(selector = selector) return maestro.findElementWithTimeout( timeout, diff --git a/maestro-test/src/main/kotlin/maestro/test/drivers/FakeDriver.kt b/maestro-test/src/main/kotlin/maestro/test/drivers/FakeDriver.kt index 8bb50e17e3..b6bb66a2bf 100644 --- a/maestro-test/src/main/kotlin/maestro/test/drivers/FakeDriver.kt +++ b/maestro-test/src/main/kotlin/maestro/test/drivers/FakeDriver.kt @@ -165,10 +165,7 @@ class FakeDriver : Driver { override fun isKeyboardVisible(): Boolean { ensureOpen() - if (events.contains(Event.HideKeyboard)) { - return false - } - return true + return !events.contains(Event.HideKeyboard) } override fun swipe(start: Point, end: Point, durationMs: Long) { @@ -360,7 +357,7 @@ class FakeDriver : Driver { } } - override fun waitForAppToSettle(initialHierarchy: ViewHierarchy?, appId: String?, timeoutMs: Int?): ViewHierarchy? { + override fun waitForAppToSettle(initialHierarchy: ViewHierarchy?, appId: String?, timeoutMs: Int?): ViewHierarchy { return ScreenshotUtils.waitForAppToSettle(initialHierarchy, this, timeoutMs) } diff --git a/maestro-test/src/test/kotlin/maestro/test/JsEngineTest.kt b/maestro-test/src/test/kotlin/maestro/test/JsEngineTest.kt index 599608cdec..6f2827d03e 100644 --- a/maestro-test/src/test/kotlin/maestro/test/JsEngineTest.kt +++ b/maestro-test/src/test/kotlin/maestro/test/JsEngineTest.kt @@ -185,10 +185,10 @@ abstract class JsEngineTest { .withHeader(HttpHeaders.CONTENT_TYPE, "application/json") .withHeader(testHeader, "first") .withHeader(testHeader, "second") - .withBody(body); + .withBody(body) - WireMock.stubFor( - WireMock.get("/json").willReturn(response) + stubFor( + get("/json").willReturn(response) ) val script = """ @@ -253,4 +253,4 @@ abstract class JsEngineTest { // Then assertThat(result.toString()).isEqualTo("POST endpoint") } -} \ No newline at end of file +}