Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting list of contexts is no longer working #101

Closed
huminzhi opened this issue Aug 23, 2016 · 10 comments
Closed

getting list of contexts is no longer working #101

huminzhi opened this issue Aug 23, 2016 · 10 comments

Comments

@huminzhi
Copy link

Hi, I am trying to list available contexts (it should have native_app, a UIWebview and a WKWebview), however, I was hitting errors as below:

info MJSONWP Calling XCUITestDriver.getContexts() with args: ["6c7e9549-324e-40f5-8570-7...
dbug XCUITest Executing command 'getContexts'
dbug iOS Getting list of available contexts
dbug iOS Retrieving contexts and views
dbug iOS Selecting by url: false
dbug RemoteDebugger useNewSafari --> false
dbug RemoteDebugger Debugger socket connected to ::1:27753
dbug RemoteDebugger Sending connection key request
dbug RemoteDebugger Sending '_rpc_reportIdentifier:' message to remote debugger
dbug RemoteDebugger Receiving data from remote debugger: '{"__argument":{"WIRSimulatorBuildKey":"13E230","WIRSimulatorProductVersionKey":"9.3","WIRSimulatorNameKey":"iPhone"},"__selector":"_rpc_reportSetup:"}'
dbug RemoteDebugger Received response from socket send: '["iPhone","13E230","9.3"]'
dbug RemoteDebugger Sim name: iPhone
dbug RemoteDebugger Sim build: 13E230
dbug RemoteDebugger Sim platform version: 9.3
dbug RemoteDebugger Receiving data from remote debugger: '{"__argument":{"WIRApplicationDictionaryKey":{"PID:61366":{"WIRApplicationIdentifierKey":"PID:61366","WIRIsApplicationProxyKey":false,"WIRApplicationNameKey":"Salesforce1","WIRApplicationBundleIdentifierKey":"com.salesforce.internal.chatter2","WIRIsApplicationActiveKey":1},"PID:61368":{"WIRApplicationIdentifierKey":"PID:61368","WIRIsApplicationProxyKey":true,"WIRApplicationNameKey":"","WIRApplicationBundleIdentifierKey":"com.apple.WebKit.WebContent","WIRIsApplicationActiveKey":1,"WIRHostApplicationIdentifierKey":"PID:61366"}}},"__selector":"_rpc_reportConnectedApplicationList:"}'
dbug RemoteDebugger Connected to application
dbug RemoteDebugger Selecting application
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
dbug RemoteDebugger Trying out the possible app ids:
ERR! RemoteDebugger Error: Could not connect to a valid app after 20 tries.
ERR! RemoteDebugger at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)
ERR! RemoteDebugger at RemoteDebugger.selectApp$ (lib/remote-debugger.js:231:11)
ERR! RemoteDebugger at tryCatch (/Users/mhu/Git/appium/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
ERR! RemoteDebugger at GeneratorFunctionPrototype.invoke as _invoke
ERR! RemoteDebugger at GeneratorFunctionPrototype.prototype.(anonymous function) as next
ERR! RemoteDebugger at invoke (/Users/mhu/Git/appium/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
ERR! RemoteDebugger at enqueueResult (/Users/mhu/Git/appium/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:185:17)
ERR! RemoteDebugger at new Promise (/Users/mhu/Git/appium/node_modules/appium-xcuitest-driver/node_modules/core-js/library/modules/es6.promise.js:201:7)
ERR! RemoteDebugger at AsyncIterator.enqueue (/Users/mhu/Git/appium/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:184:12)
ERR! RemoteDebugger at AsyncIterator.prototype.(anonymous function) as next
ERR! RemoteDebugger at Object.runtime.async (/Users/mhu/Git/appium/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:209:12)
ERR! RemoteDebugger at RemoteDebugger.selectApp (lib/remote-debugger.js:261:21)
ERR! RemoteDebugger at XCUITestDriver.callee$0$0$ (lib/commands/context.js:208:35)
ERR! RemoteDebugger at tryCatch (/Users/mhu/Git/appium/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:67:40)
ERR! RemoteDebugger at GeneratorFunctionPrototype.invoke as _invoke
ERR! RemoteDebugger at GeneratorFunctionPrototype.prototype.(anonymous function) as next
ERR! RemoteDebugger at GeneratorFunctionPrototype.invoke (/Users/mhu/Git/appium/node_modules/appium-xcuitest-driver/node_modules/babel-runtime/regenerator/runtime.js:136:37)
ERR! RemoteDebugger at run (/Users/mhu/Git/appium/node_modules/appium-xcuitest-driver/node_modules/core-js/library/modules/es6.promise.js:108:47)
ERR! RemoteDebugger at /Users/mhu/Git/appium/node_modules/appium-xcuitest-driver/node_modules/core-js/library/modules/es6.promise.js:119:28
ERR! RemoteDebugger at flush (/Users/mhu/Git/appium/node_modules/appium-xcuitest-driver/node_modules/core-js/library/modules/$.microtask.js:19:5)
ERR! RemoteDebugger at nextTickCallbackWith0Args (node.js:452:9)
ERR! RemoteDebugger at process._tickCallback (node.js:381:13)
ERR! RemoteDebugger [Error: Could not connect to a valid app after 20 tries.]

And today, I got latest code and try to list all contexts, it's showing me "undefined method `contexts' for #Appium::Driver:0x007f7fc8ac8f38 (NoMethodError)"

So what's the right way to list all the contexts now and how shall I switch to the WKWebview context... Thanks for advice!

@imurchie
Copy link
Contributor

Can you give the logs for the undefined problem with the latest code? That should not happen.

@huminzhi
Copy link
Author

@imurchie sorry it's my typo.. so I am still hitting the previous issue: Could not connect to a valid app after 20 tries.

/Users/mhu/.rvm/gems/ruby-2.2.1/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/response.rb:70:in assert_ok': An unknown server-side error occurred while proc essing the command. Original error: Could not connect to a valid app after 20 tries. (Selenium::WebDriver::Error::UnknownError) from /Users/mhu/.rvm/gems/ruby-2.2.1/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/response.rb:34:ininitialize'
from /Users/mhu/.rvm/gems/ruby-2.2.1/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/common.rb:78:in new' from /Users/mhu/.rvm/gems/ruby-2.2.1/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/common.rb:78:increate_response'
from /Users/mhu/.rvm/gems/ruby-2.2.1/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:90:in request' from /Users/mhu/.rvm/gems/ruby-2.2.1/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/common.rb:59:incall'
from /Users/mhu/.rvm/gems/ruby-2.2.1/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:649:in raw_execute' from /Users/mhu/.rvm/gems/ruby-2.2.1/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:627:inexecute'
from /Users/mhu/.rvm/gems/ruby-2.2.1/gems/appium_lib-8.0.2/lib/appium_lib/device/device.rb:118:in `available_contexts'

@huminzhi
Copy link
Author

huminzhi commented Aug 23, 2016

Some more updates.. so it turns out that the issue happens only when appium driver is launched with udid capability:

so for an example,

this works:

desired_caps = {
    caps:       {
        platformName:  'iOS',
        automationName:'xcuitest',
        deviceName:    'iPhone 6',
        platformVersion: '9.3',
        app:           APP_PATH
    },
    appium_lib: {
        sauce_username:   nil, # don't run on Sauce
        sauce_access_key: nil
    }
}

but this DOESN'T work:

desired_caps = {
    caps:       {
        platformName:  'iOS',
        automationName:'xcuitest',
        deviceName:    'iPhone 6',
        **udid: 'a defined udid',**
        app:           APP_PATH
    },
    appium_lib: {
        sauce_username:   nil, # don't run on Sauce
        sauce_access_key: nil
    }
}

I won't say it's a major issue, however, it will be nice to be able to specify a udid in case we want to test multiple apps on same device. Also it seems just need an easy fix to populate platformVersion from the device(udid)... Thank you for help!

@imurchie
Copy link
Contributor

Interesting. Ok. I will look into what is going on here. Thanks for the updated information!

@imurchie
Copy link
Contributor

Alrighty. I can reproduce. Working on a solution.

@imurchie
Copy link
Contributor

I've tracked down the issue. It is when the remote debugger does not have a platformVersion. The quick solution is to pass one in in the desired capabilities.

I've also created a fix, which gets the pv from the device. Travis is being slow so it will take a little bit of time to get it through the build and into a release.

@imurchie
Copy link
Contributor

appium-xcuitest-driver 2.0.10 has a fix for the issue. Can you try that out?

@jlipps
Copy link
Member

jlipps commented Aug 24, 2016

For some reason I thought we had made platformVersion a required capability? i guess not

@imurchie
Copy link
Contributor

I thought we had, too. But apparently not.

@huminzhi
Copy link
Author

it works now with the fix..thanks a lot!

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

No branches or pull requests

3 participants