Skip to content
This repository was archived by the owner on Feb 11, 2022. It is now read-only.

Appium server abort after find element by ai: search #5

Open
cuhavp opened this issue Oct 22, 2018 · 9 comments
Open

Appium server abort after find element by ai: search #5

cuhavp opened this issue Oct 22, 2018 · 9 comments

Comments

@cuhavp
Copy link

cuhavp commented Oct 22, 2018

  • Appium

Log
[HTTP] {"using":"-custom","value":"ai:search"}
[debug] [W3C (064ec6c5)] Calling AppiumDriver.findElement() with args: ["-custom","ai:search","064ec6c5-762b-4a34-a690-67e65723dbaa"]
[debug] [XCUITest] Executing command 'findElement'
[debug] [BaseDriver] Find plugin 'ai' requested; will attempt to use it from 'test-ai-classifier'
2018-10-22 14:04:32.445983: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.2 AVX AVX2 FMA
[debug] [BaseDriver] Waiting up to 0 ms for condition
[ai] Retrieving current settings to check element response attributes
(node:7264) Warning: N-API is an experimental feature and could change at any time.
[ai] We will need to update settings to include element response attributes
[debug] [JSONWP Proxy] Matched '/appium/settings' to command name 'updateSettings'
[debug] [JSONWP Proxy] Proxying [POST /appium/settings] to [POST http://localhost:8100/session/F7F716B2-E1BC-4C5E-81E2-B680BEB1E917/appium/settings] with body: {"settings":{"elementResponseAttributes":"rect"}}
[debug] [JSONWP Proxy] Got response with status 200: {"value":{"elementResponseAttributes":"rect","shouldUseCompactResponses":false},"sessionId":"F7F716B2-E1BC-4C5E-81E2-B680BEB1E917","status":0}
[ai] Setting confidence threshold to default value of 0.2
[ai] Retrieving data for all leaf-node elements on screen
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
[debug] [BaseDriver] Waiting up to 0 ms for condition
[debug] [JSONWP Proxy] Matched '/elements' to command name 'findElements'
[debug] [JSONWP Proxy] Proxying [POST /elements] to [POST http://localhost:8100/session/F7F716B2-E1BC-4C5E-81E2-B680BEB1E917/elements] with body: {"using":"xpath","value":"//[not(child::)]"}
[debug] [JSONWP Proxy] Got response with status 200: {"value":[{"ELEMENT":"03000000-0000-0000-2B1D-000000000000","rect":{"y":20,"x":0,"width":44,"height":44}},{"ELEMENT":"19000000-0000-0000-2B1D-000000000000","rect":{"y":30,"x":159,"width":57,"height":24}},{"ELEMENT":"1A000000-0000-0000-2B1D-000000000000","rect":{"y":20,"x":310,"width":57,"height":44}},{"ELEMENT":"1E000000-0000-0000-2B1D-000000000000","rect":{"y":33,"x":0,"width":93,"height":94}},{"ELEMENT":"27000000-0000-0000-2B1D-000000000000","rect":{"y":72,"x":16,"width":319,"height":24}},{"ELEMENT":"28000000-0000-0000-2B1D-000000000000","rect":{"y":95,"x":118,"width":104,"height":20}},{"ELEMENT":"29000000-0000-0000-2B1D-000000000000","rect":{"y":95,"x":16,"width":82,"height":20}},{"ELEMENT":"2A000000-0000-0000-2B1D-000000000000","rect":{"y":144,"x":16,"width":319,"height":24}},{"ELEMENT":"2B000000-0000-0000-2B1D-000000000000","rect":{"y":167,"x":118,"width":84,"height":20}},{"ELEMENT":"2C000000-0000-0000-2B1D-000000000000","rect":{"y":167,"x":16,"width":82,"height":20}},{"ELEMENT":"21000000-0000-0000-2B...
[ai] Getting window size in case we need to scale screenshot
[ai] Getting screenshot to use for classifier
[debug] [XCUITest] Taking screenshot with WDA
[debug] [JSONWP Proxy] Matched '/screenshot' to command name 'getScreenshot'
[debug] [JSONWP Proxy] Proxying [GET /screenshot] to [GET http://localhost:8100/session/F7F716B2-E1BC-4C5E-81E2-B680BEB1E917/screenshot] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{\n "value" : "iVBORw0KGgoAAAANSUhEUgAAAu4AAAU2CAIAAABFtaRRAAAAAXNSR0IArs4c6QAA\r\nABxpRE9UAAAAAgAAAAAAAAKbAAAAKAAAApsAAAKbAAOCmQOFTr0AAEAASURBVHgB\r\n7J0HnCRFucCXnHPQJ6CCiooBfWJ6ZkTCkQQFJR\/HwZEPuMwdIPBUeChwOcIhIAIC\r\nIuEkSOZId3BwcfNO3pnZvLOTQ71\/9bfb19czPTtzt4vc0fWrX23111VfVdd2Vf\/7\r\nq6qemniVLpFIlfTxeNLBV1dAompXuj4lK2kI+wtIDriU4QaO7H8TyXRVPplMV+Wl\r\n9MrDZCozrN6sSdp1bgu4LeC2gNsCm3MLZFLZdDoby+Z7c9rHM\/lcKq0SSdUXV319\r\nKtGnkvF0Jp7KpBPaZ4lU5TsL2Z58lryZVDqfTOIzaVGoQ+K5FGEyneappYsYPldT\r\nHWjE406I4MAx8E11rmqScUArp3qa+q3MwvPbemiNV8UxJK6KY0hsokOFkWHlGJSb\r\n1Ri+e87V7LaA2wJuC7gt8CG0QC6pUSaRyUMzeCLAjUqkVTyufSKeT8WFM1LpLDRS\r\nbZXgmFhOAxCElE9qmhkAF\/2kIq59SmvVhJSmMsPlNhuUESAyQcQS2VSrjBVciuMu\r\nygzXrefqdVvAbQG3BdwWGM4WyCezmmZSGmIS6QIhcSSCHblUP2eAO8jTqQKnqvIG\r\nnegsFKQSWm0\/uGgw0l5r7leuix6+a60aZZytL8M7wWTadiwQI1EXZYZyysm1ygxf\r\nZ3M1uy3gtoDbAh9mCxjIktXTTKk8dhNQhnCAMMyKmLShUUbop8JQ9JNYPNkBF\/Rr\r\ncjK8tvRoSMIapL1Z5JBHavocnIkORREnZHGSFynYZMGGNLORKCNKis0wNolrlRny\r\ne85V6La...
[ai] Turning screenshot into HTML image for use with canvas
dyld: lazy symbol binding failed: Symbol not found: __ZN2v87Isolate19CheckMemoryPressureEv
Referenced from: /usr/local/lib/node_modules/test-ai-classifier/node_modules/canvas/build/Release/canvas.node
Expected in: flat namespace

dyld: Symbol not found: __ZN2v87Isolate19CheckMemoryPressureEv
Referenced from: /usr/local/lib/node_modules/test-ai-classifier/node_modules/canvas/build/Release/canvas.node
Expected in: flat namespace

  • Code

    @BeforeTest
    public void setUp() throws IOException {
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("platformName", "iOS");
    caps.setCapability("platformVersion", "12.0");
    caps.setCapability("deviceName", "iPhone 6");
    caps.setCapability("bundleId", BUNDLE_ID);

      HashMap<String, String> customFindModules = new HashMap<>();
      customFindModules.put("ai", "test-ai-classifier");
    
      caps.setCapability("customFindModules", customFindModules);
      caps.setCapability("shouldUseCompactResponses", false);
    
      driver = new IOSDriver<MobileElement>(new URL("http://localhost:4723/wd/hub"), caps);
      wait = new WebDriverWait(driver, 10);
    

    }

    @AfterTest
    public void tearDown() {
    try {
    driver.quit();
    } catch (Exception ign) {
    }
    }

    @test
    public void testFindElementUsingAI() {
    // find and click on the search button using the classifier
    driver.findElement(search).click();

      // prove that the click was successful by locating the 'cancel' button
      wait.until(ExpectedConditions.presenceOfElementLocated(cancel));
    

    }

@NozomiIto
Copy link
Contributor

It seems the node-canvas problem Automattic/node-canvas#1252.
The issue page says upgrading node.js will resolve the problem.

@cuhavp
Copy link
Author

cuhavp commented Oct 24, 2018

@NozomiIto : I ran this current script pass on IOS 11.4 but for 12.0 is failed.

@NozomiIto
Copy link
Contributor

@cuhavp What is your node.js version?

@cuhavp
Copy link
Author

cuhavp commented Oct 26, 2018

hi @NozomiIto version of node JS is v10.12.0

@NozomiIto
Copy link
Contributor

How about trying node.js 8.12.0 (node.js LTS lastest version) or node.js 11.0.0 (latest version)?

Automattic/node-canvas#1252
Automattic/node-canvas#1284

@DeChrish
Copy link

DeChrish commented Nov 18, 2018

@NozomiIto

My setup:
node: v11.2.0 ~ tried in v8.12.0 too
npm: 6.4.1
Appium: 1.9.2-beta.2

ai: installed via - npm install -g test-ai-classifier

Appium Log:

Encountered internal error running command: Error: Could not load your custom find module 'ai'. Did you put it somewhere Appium can 'require' it? Original error: Error: The module '/usr/local/lib/node_modules/test-ai-classifier/node_modules/canvas/build/Release/canvas.node'
[debug] [MJSONWP (07ea2938)] was compiled against a different Node.js version using
[debug] [MJSONWP (07ea2938)] NODE_MODULE_VERSION 67. This version of Node.js requires
[debug] [MJSONWP (07ea2938)] NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
[debug] [MJSONWP (07ea2938)] the module (for instance, using npm rebuild or npm install).
[debug] [MJSONWP (07ea2938)] at AndroidUiautomator2Driver. (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/commands/find.js:137:11)
[debug] [MJSONWP (07ea2938)] at Generator.next ()
[debug] [MJSONWP (07ea2938)] at asyncGeneratorStep (/usr/local/lib/node_modules/appium/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)

Mocha Error Log:

  1. Finding an Android element with machine learning magic
    should find the cart button:
    Error: [elementByCustom("ai:cart")] Error response status: 13, , UnknownError - An unknown server-side error occurred while processing the command. Selenium error: An unknown server-side error occurred while processing the command. Original error: Could not load your custom find module 'ai'. Did you put it somewhere Appium can 'require' it? Original error: Error: The module '/usr/local/lib/node_modules/test-ai-classifier/node_modules/canvas/build/Release/canvas.node'
    was compiled against a different Node.js version using
    NODE_MODULE_VERSION 67. This version of Node.js requires
    NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
    the module (for instance, using npm rebuild or npm install).
    at exports.newError (node_modules/wd/lib/utils.js:151:13)
    at /Users/dechrish/github/appium-classifier-plugin/node_modules/wd/lib/callbacks.js:94:19
    at /Users/dechrish/github/appium-classifier-plugin/node_modules/wd/lib/webdriver.js:183:5
    at Request._callback (node_modules/wd/lib/http-utils.js:89:7)
    at Request.self.callback (node_modules/wd/node_modules/request/request.js:186:22)
    at Request. (node_modules/wd/node_modules/request/request.js:1163:10)
    at IncomingMessage. (node_modules/wd/node_modules/request/request.js:1085:12)
    at endReadableNT (_stream_readable.js:1098:12)
    at process.internalTickCallback (internal/process/next_tick.js:72:19)

@DeChrish
Copy link

@NozomiIto worked fine after installing,
brew install pkg-config cairo pango libpng jpeg giflib librsvg
npm rebulild -g test-ai-classifier

@ghost
Copy link

ghost commented Aug 9, 2019

I am getting the similar error even after trying all these.
Error: [elementByCustom("ai:favorite")] Error response status: 13, , UnknownError - An unknown server-side error occurred while processing the command. Selenium error: An unknown server-side error occurred while processing the command. Original error: Could not load your custom find module 'ai'. Did you put it somewhere Appium can 'require' it? Original error: Error: Cannot find module 'test-ai-classifier' at exports.newError (node_modules/wd/lib/utils.js:152:13) at /Users/vn0xue9/mtest-singleRepo-asda/node_modules/wd/lib/callbacks.js:94:19 at /Users/vn0xue9/mtest-singleRepo-asda/node_modules/wd/lib/webdriver.js:194:5 at Request._callback (node_modules/wd/lib/http-utils.js:89:7) at Request.self.callback (node_modules/request/request.js:185:22) at Request.<anonymous> (node_modules/request/request.js:1161:10) at IncomingMessage.<anonymous> (node_modules/request/request.js:1083:12) at endReadableNT (_stream_readable.js:1129:12) at process._tickCallback (internal/process/next_tick.js:63:19)

@anbunathan
Copy link

I am getting the following error:
Requested to provide solution.

FAILED: testFindElementUsingAI
org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
Build info: version: '4.0.0-alpha-1', revision: 'd1d3728cae', time: '2019-04-24T13:42:21'
System info: host: 'anbunathan-VirtualBox.cluster2.com', ip: '192.168.56.101', os.name: 'Linux', os.arch: 'amd64', os.version: '5.0.0-27-generic', java.version: '1.8.0_222'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {appActivity: .app.main.MainActivity, appPackage: com.walmart.android, automationName: uiautomator2, customFindModules: {ai: test-ai-classifier}, databaseEnabled: false, desired: {appActivity: .app.main.MainActivity, appPackage: com.walmart.android, automationName: uiautomator2, customFindModules: {ai: test-ai-classifier}, deviceName: G5 SE, noReset: false, platformName: android, platformVersion: 6.0.1, shouldUseCompactResponses: false, skipUnlock: true, takesScreenshot: true, udid: LGH8451bb031b0}, deviceApiLevel: 23, deviceManufacturer: LGE, deviceModel: LG-H845, deviceName: LGH8451bb031b0, deviceScreenDensity: 640, deviceScreenSize: 1440x2560, deviceUDID: LGH8451bb031b0, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, noReset: false, pixelRatio: 4, platform: LINUX, platformName: Android, platformVersion: 6.0.1, shouldUseCompactResponses: false, skipUnlock: true, statBarHeight: 96, takesScreenshot: true, udid: LGH8451bb031b0, viewportRect: {height: 2296, left: 0, top: 96, width: 1440}, warnings: {}, webStorageEnabled: false}
Session ID: 8792492e-97fa-4aa1-8000-c4822eaf889c
*** Element info: {Using=-custom, value=ai:cart}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:190)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:124)
at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:51)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:161)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:577)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:328)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:61)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at io.appium.java_client.FindsByCustom.findElementByCustom(FindsByCustom.java:38)
at io.appium.java_client.MobileBy$ByCustom.findElement(MobileBy.java:625)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:320)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:57)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at com.example.appium.testClassifier.testFindElementUsingAI(testClassifier.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:584)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:172)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:804)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at org.testng.TestRunner.privateRun(TestRunner.java:770)
at org.testng.TestRunner.run(TestRunner.java:591)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
at org.testng.SuiteRunner.run(SuiteRunner.java:304)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
at org.testng.TestNG.runSuites(TestNG.java:1032)
at org.testng.TestNG.run(TestNG.java:1000)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0

===============================================
Default suite
Total tests run: 1, Passes: 0, Failures: 1, Skips: 0

Appium server log:

(8792492e)] Calling AppiumDriver.findElement() with args: ["-custom","ai:cart","8792492e-97fa-4aa1-8000-c4822eaf889c"]
[debug] [BaseDriver] Find plugin 'ai' requested; will attempt to use it from 'test-ai-classifier'
[debug] [BaseDriver] Waiting up to 0 ms for condition
[ai] Retrieving current settings to check element response attributes
[debug] [WD Proxy] Matched '/appium/settings' to command name 'getSettings'
[debug] [WD Proxy] Proxying [GET /appium/settings] to [GET http://localhost:8200/wd/hub/session/a0b0f810-87de-4d9b-9d79-cd2f50c7be11/appium/settings] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"a0b0f810-87de-4d9b-9d79-cd2f50c7be11","value":{"actionAcknowledgmentTimeout":3000,"allowInvisibleElements":false,"ignoreUnimportantViews":false,"elementResponseAttributes":"","enableNotificationListener":true,"keyInjectionDelay":0,"scrollAcknowledgmentTimeout":200,"shouldUseCompactResponses":false,"waitForIdleTimeout":10000,"waitForSelectorTimeout":10000,"normalizeTagNames":false,"shutdownOnPowerDisconnect":true,"trackScrollEvents":true,"wakeLockTimeout":86390692}}
[ai] We will need to update settings to include element response attributes
[UiAutomator2] Forwarding the following settings to the UiAutomator2 server: ["elementResponseAttributes"]
[debug] [WD Proxy] Matched '/appium/settings' to command name 'updateSettings'
[debug] [WD Proxy] Proxying [POST /appium/settings] to [POST http://localhost:8200/wd/hub/session/a0b0f810-87de-4d9b-9d79-cd2f50c7be11/appium/settings] with body: {"settings":{"elementResponseAttributes":"rect"}}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"a0b0f810-87de-4d9b-9d79-cd2f50c7be11","value":null}
[ai] Setting confidence threshold to default value of 0.2
[ai] Retrieving data for all leaf-node elements on screen
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[debug] [BaseDriver] Waiting up to 0 ms for condition
[debug] [WD Proxy] Matched '/elements' to command name 'findElements'
[debug] [WD Proxy] Proxying [POST /elements] to [POST http://localhost:8200/wd/hub/session/a0b0f810-87de-4d9b-9d79-cd2f50c7be11/elements] with body: {"strategy":"xpath","selector":"//[not(child::)]","context":"","multiple":true}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"a0b0f810-87de-4d9b-9d79-cd2f50c7be11","value":[{"ELEMENT":"9caa4be1-7816-4e0d-9d10-755f64b7f7a2","element-6066-11e4-a52e-4f735466cecf":"9caa4be1-7816-4e0d-9d10-755f64b7f7a2","rect":{"x":0,"y":96,"width":224,"height":224}},{"ELEMENT":"ad2daff6-ad78-4fb5-8f85-5c0593093c3b","element-6066-11e4-a52e-4f735466cecf":"ad2daff6-ad78-4fb5-8f85-5c0593093c3b","rect":{"x":288,"y":160,"width":384,"height":96}},{"ELEMENT":"b6132332-41e2-4890-bbb6-7484ab10137b","element-6066-11e4-a52e-4f735466cecf":"b6132332-41e2-4890-bbb6-7484ab10137b","rect":{"x":1056,"y":112,"width":192,"height":192}},{"ELEMENT":"af7fe4ee-c492-46ea-bc71-3a5e554ddcd4","element-6066-11e4-a52e-4f735466cecf":"af7fe4ee-c492-46ea-bc71-3a5e554ddcd4","rect":{"x":1280,"y":160,"width":96,"height":96}},{"ELEMENT":"0f4b25fe-1cd0-483d-84c2-398ea41c8f68","element-6066-11e4-a52e-4f735466cecf":"0f4b25fe-1cd0-483d-84c2-398ea41c8f68","rect":{"x":0,"y":320,"width":1440,"height":256}},{"ELEMENT":"ecd46c2c-e3c6-46d8-a594-ba0c06ea88b4","element-6066-11e4-a52e-4...
[ai] Getting window size in case we need to scale screenshot
[debug] [WD Proxy] Matched '/window/current/size' to command name 'getWindowSize'
[debug] [WD Proxy] Proxying [GET /window/current/size] to [GET http://localhost:8200/wd/hub/session/a0b0f810-87de-4d9b-9d79-cd2f50c7be11/window/current/size] with body: {}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"a0b0f810-87de-4d9b-9d79-cd2f50c7be11","value":{"height":2392,"width":1440}}
[ai] Getting screenshot to use for classifier
[debug] [WD Proxy] Matched '/screenshot' to command name 'getScreenshot'
[debug] [WD Proxy] Proxying [GET /screenshot] to [GET http://localhost:8200/wd/hub/session/a0b0f810-87de-4d9b-9d79-cd2f50c7be11/screenshot] with no body
[debug] [Instrumentation] The process has exited with code 0
[debug] [WD Proxy] Got response with status 500: {"sessionId":"a0b0f810-87de-4d9b-9d79-cd2f50c7be11","value":{"error":"unable to capture screen","message":"Failed to capture a screenshot. Does the current view have 'secure' flag set?","stacktrace":"io.appium.uiautomator2.common.exceptions.TakeScreenshotException: Failed to capture a screenshot. Does the current view have 'secure' flag set?\n\tat io.appium.uiautomator2.utils.ScreenshotHelper.takeDeviceScreenshot(ScreenshotHelper.java:124)\n\tat io.appium.uiautomator2.utils.ScreenshotHelper.takeScreenshot(ScreenshotHelper.java:59)\n\tat io.appium.uiautomator2.utils.ScreenshotHelper.takeScreenshot(ScreenshotHelper.java:77)\n\tat io.appium.uiautomator2.handler.CaptureScreenshot.safeHandle(CaptureScreenshot.java:34)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:38)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:252)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:242)\n\tat io.appium.uia...
[debug] [W3C] Matched W3C error code 'unable to capture screen' to UnableToCaptureScreen
[ai] Resetting element response attribute setting to original value: ""
[UiAutomator2] Forwarding the following settings to the UiAutomator2 server: ["elementResponseAttributes"]
[debug] [WD Proxy] Matched '/appium/settings' to command name 'updateSettings'
[debug] [WD Proxy] Proxying [POST /appium/settings] to [POST http://localhost:8200/wd/hub/session/a0b0f810-87de-4d9b-9d79-cd2f50c7be11/appium/settings] with body: {"settings":{"elementResponseAttributes":""}}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"a0b0f810-87de-4d9b-9d79-cd2f50c7be11","value":null}
[debug] [W3C (8792492e)] Encountered internal error running command: io.appium.uiautomator2.common.exceptions.TakeScreenshotException: Failed to capture a screenshot. Does the current view have 'secure' flag set?
[debug] [W3C (8792492e)] at io.appium.uiautomator2.utils.ScreenshotHelper.takeDeviceScreenshot(ScreenshotHelper.java:124)
[debug] [W3C (8792492e)] at io.appium.uiautomator2.utils.ScreenshotHelper.takeScreenshot(ScreenshotHelper.java:59)
[debug] [W3C (8792492e)] at io.appium.uiautomator2.utils.ScreenshotHelper.takeScreenshot(ScreenshotHelper.java:77)
[debug] [W3C (8792492e)] at io.appium.uiautomator2.handler.CaptureScreenshot.safeHandle(CaptureScreenshot.java:34)
[debug] [W3C (8792492e)] at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:38)
[debug] [W3C (8792492e)] at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:252)
[debug] [W3C (8792492e)] at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:242)
[debug] [W3C (8792492e)] at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:44)
[debug] [W3C (8792492e)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
[debug] [W3C (8792492e)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
[debug] [W3C (8792492e)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
[debug] [W3C (8792492e)] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
[debug] [W3C (8792492e)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
[debug] [W3C (8792492e)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
[debug] [W3C (8792492e)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
[debug] [W3C (8792492e)] at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
[debug] [W3C (8792492e)] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
[debug] [W3C (8792492e)] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
[debug] [W3C (8792492e)] at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
[debug] [W3C (8792492e)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
[debug] [W3C (8792492e)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
[debug] [W3C (8792492e)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
[debug] [W3C (8792492e)] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
[debug] [W3C (8792492e)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
[debug] [W3C (8792492e)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
[debug] [W3C (8792492e)] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
[debug] [W3C (8792492e)] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
[debug] [W3C (8792492e)] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)
[debug] [W3C (8792492e)] at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:514)
[debug] [W3C (8792492e)] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:468)
[debug] [W3C (8792492e)] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
[debug] [W3C (8792492e)] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
[debug] [W3C (8792492e)] at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
[debug] [W3C (8792492e)] at java.lang.Thread.run(Thread.java:818)
[debug] [W3C (8792492e)]
[HTTP] <-- POST /wd/hub/session/8792492e-97fa-4aa1-8000-c4822eaf889c/element 500 507 ms - 3660
[HTTP]
[HTTP] --> DELETE /wd/hub/session/8792492e-97fa-4aa1-8000-c4822eaf889c
[HTTP] {}
[debug] [W3C (8792492e)] Calling AppiumDriver.deleteSession() with args: ["8792492e-97fa-4aa1-8000-c4822eaf889c"]
[debug] [BaseDriver] Event 'quitSessionRequested' logged at 1568135786759 (22:46:26 GMT+0530 (IST))
[Appium] Removing session 8792492e-97fa-4aa1-8000-c4822eaf889c from our master session list
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[debug] [WD Proxy] Matched '/' to command name 'deleteSession'
[debug] [WD Proxy] Proxying [DELETE /] to [DELETE http://localhost:8200/wd/hub/session/a0b0f810-87de-4d9b-9d79-cd2f50c7be11] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"a0b0f810-87de-4d9b-9d79-cd2f50c7be11","value":null}
[debug] [ADB] Running '/home/anbunathan/Android/Sdk/platform-tools/adb -P 5037 -s LGH8451bb031b0 shell am force-stop com.walmart.android'
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200
[debug] [ADB] Running '/home/anbunathan/Android/Sdk/platform-tools/adb -P 5037 -s LGH8451bb031b0 forward --remove tcp:8200'
[debug] [BaseDriver] Event 'quitSessionFinished' logged at 1568135787713 (22:46:27 GMT+0530 (IST))
[debug] [W3C (8792492e)] Received response: null
[debug] [W3C (8792492e)] But deleting session, so not returning
[debug] [W3C (8792492e)] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/8792492e-97fa-4aa1-8000-c4822eaf889c 200 956 ms - 14
[HTTP]

Source code:
package com.example.appium;

import io.appium.java_client.MobileElement;

import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.net.MalformedURLException;
import java.net.URL;
import io.appium.java_client.MobileBy;
import java.io.IOException;
import java.util.HashMap;
//import org.junit.After;
//import org.junit.Before;
//import org.junit.Test;

public class testClassifier {
public AndroidDriver driver;
public WebDriverWait wait;
@BeforeMethod
public void setUp() throws IOException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "G5 SE");
caps.setCapability("udid", "LGH8451bb031b0"); //Give Device ID of your mobile phone
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "6.0.1");
caps.setCapability("automationName", "uiautomator2");
caps.setCapability("skipUnlock","true");
caps.setCapability( "takesScreenshot" , true ) ;
caps.setCapability("appPackage", "com.walmart.android");
caps.setCapability("appActivity", ".app.main.MainActivity");
/*
* caps.setCapability("appWaitPackage", "com.walmart.android");
* caps.setCapability("appWaitActivity", ".app.main.MainActivity");
*/

    //caps.setCapability("appPackage", "in.amazon.mShop.android.shopping");
	//caps.setCapability("appActivity", "com.amazon.mShop.home.HomeActivity");
	//caps.setCapability("appWaitPackage", "in.amazon.mShop.android.shopping");
	//caps.setCapability("appWaitActivity", "com.amazon.mShop.home.HomeActivity");
	
    caps.setCapability("noReset","false");
	HashMap<String, String> customFindModules = new HashMap<>();
    customFindModules.put("ai", "test-ai-classifier");
    caps.setCapability("customFindModules", customFindModules);
    caps.setCapability("shouldUseCompactResponses", false);
    driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"),caps);
    wait = new WebDriverWait(driver, 300);     
    
}
@AfterTest
public void tearDown() {
    try {
        driver.quit();
    } catch (Exception ign) {}
}
@Test
public void testFindElementUsingAI() throws InterruptedException {
	Thread.sleep(5000);
	driver.findElementByAccessibilityId("Open navigation drawer");
	driver.findElement(MobileBy.custom("ai:cart")).click();
	//driver.findElementByCustom("cart").click();
	//driver.elementByAccessibilityId("Open navigation drawer");
	//driver.elementByCustom("ai:cart").click();
    wait = new WebDriverWait(driver, 10);
	
}

}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants