受益匪浅,互帮互助~~
css 定位的优势?
css 在我理解中就是页面样式。。这个怎么会成为优势呢?请指教~~
#3 楼 @seveniruby 我表示我也在中软呆过。。。。叫你师哥吗 哈哈
#12 楼 @seveniruby 表示大脑有点捉急了。。。。这个错误是在 PAD 上出来的,我怎么把这些文字当到我的 MAC 上呀?
#9 楼 @lihuazhang
#10 楼 @seveniruby
尝试了好多次 ,还是又错误,不过这次不是在 appium,而是在我 app 的 webview 里出现了一个很长很长的错误,我觉得又点意义的就那个错误说明:illegal character in fragment at index 7903:....
下面就全部都是代码了。。很长很长
code:
DesiredCapabilities cap = new DesiredCapabilities();
WebDriver wd = null;
// cap.setCapability(CapabilityType.BROWSER_NAME, "");
cap.setCapability(CapabilityType.VERSION, "4.4.2");
cap.setCapability(CapabilityType.PLATFORM, "MAC");//iPhone Simulator iPad Device Selendroid
cap.setCapability("device", "selendroid");//
cap.setCapability("app", "/Users/administrator/Documents/sf.apk");//app.getAbsolutePath() chromium ContactManager /Users/administrator/Documents/ContactManager.apk Users/administrator/Documents/sf.apk
//cap.setCapability("launch", "true");
cap.setCapability("app-activity", ".activities.SFLoginActivity");//MainActivity .ContactManager .activities.SFAccountSelectActivity
cap.setCapability("app-package", "com.sharefile.mobile.tablet");//com.example.android.contactmanager
wd = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
wd = new Augmenter().augment(wd);
wd.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
// System.out.println(wd.getWindowHandles().size());
// for (String s : wd.getWindowHandles()) {
// System.out.println(s);
// wd = wd.switchTo().window(s);
// }
Thread.sleep(5000);
wd.switchTo().window("WEBVIEW");
//CScreenShot.takeScreenShot(wd, "/Users/administrator/Documents/AND/1-screenshot", "0");
// wd.findElement(By.xpath("//input[@type='text']")).click();
wd.findElement(By.xpath("//input[@type='text']")).sendKeys("123");
在 wd.findElement(By.xpath("//input[@type='text']")).sendKeys("123"); 这句的时候出错的
screenshot:
#7 楼 @seveniruby You are right! 改了后就解决了~可以顺利起来,然后我去尝试操作 WEBVIEW 里的内容又是一堆报错 我先研究下吧,不懂在上来问,THANKS!
#4 楼 @seveniruby 大神呀 这段代码是在 appium 哪个文件夹/文件下呀?
wo 换了低版本 de 也是这个错误
我的设备是 nexus7 4.4.2 版本的 难不成 shi 因为这个版本没法使用 selendroid?
要是这样的话 那我怎么测试 werbview 类型的呀?
这个问题 我根据 http://stackoverflow.com/questions/16619143/android-maven-could-not-find-tool-aapt 这个帖子 可以解决 但是又出了新的 error
error:
nfo: Using local app from desiredCaps: /Users/administrator/Documents/sf.apk
info: Creating new appium session 962652b6-1b4b-406f-a5c1-ee75ef25e39a
info: Starting selendroid server
info: Checking whether selendroid is built yet
info: Selendroid server exists!
info: Preparing device for session
info: Checking whether app is actually present
info: Checking whether adb is present
info: [ADB] Using adb from /Users/administrator/Downloads/adt-bundle-mac-x86_64-20131030/sdk/platform-tools/adb
info: Trying to find a connected android device
info: [ADB] Getting connected devices...
debug: executing: "/Users/administrator/Downloads/adt-bundle-mac-x86_64-20131030/sdk/platform-tools/adb" devices
info: [ADB] 1 device(s) connected
debug: executing: "/Users/administrator/Downloads/adt-bundle-mac-x86_64-20131030/sdk/platform-tools/adb" -s 072008a5 wait-for-device
info: Setting device id to 072008a5
info: [ADB] Waiting for device to be ready and to respond to shell commands (timeout = 5)
debug: executing: "/Users/administrator/Downloads/adt-bundle-mac-x86_64-20131030/sdk/platform-tools/adb" -s 072008a5 shell "echo 'ready'"
info: Starting logcat capture
debug: executing: "/Users/administrator/Downloads/adt-bundle-mac-x86_64-20131030/sdk/platform-tools/adb" -s 072008a5 uninstall com.sharefile.mobile.tablet.selendroid
info: Rebuilt selendroid apk does not exist, uninstalling any instances of it on device to make way for new one
info: Uninstalling com.sharefile.mobile.tablet.selendroid
debug: App was not uninstalled, maybe it wasn't on device?
info: Rebuilt selendroid server does not exist, inserting modified manifest
info: Inserting selendroid manifest
info: Checking whether aapt is present
error: Failed to start an Appium session, err was: Error: Required platform doesn't exist (API level >= 17)
info: [ADB] Using aapt from /Users/administrator/Downloads/adt-bundle-mac-x86_64-20131030/sdk/platform-tools/aapt
info: Compiling manifest /tmp/com.sharefile.mobile.tablet/AndroidManifest.xml
info: Cleaning up appium session
info: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Required platform doesn't exist (API level >= 17))","origValue":"Required platform doesn't exist (API level >= 17)"},"sessionId":null}
POST /wd/hub/session 500 1277ms - 248b
debug: Appium request initiated at /wd/hub/status
info: Responding to client with success: {"status":0,"value":{"build":{"version":"0.12.3","revision":"c8abd030c0cedcc387532f2aa986fd956e46eb4f"}}}
debug: Request received with params: {}
GET /wd/hub/status 200 1ms - 144b
debug: Appium request initiated at /wd/hub/status
info: Responding to client with success: {"status":0,"value":{"build":{"version":"0.12.3","revision":"c8abd030c0cedcc387532f2aa986fd956e46eb4f"}}}
debug: Request received with params: {}
GET /wd/hub/status 200 1ms - 144b
#5 楼 @seveniruby
#6 楼 @lihuazhang
好的 非常感谢 2 位
#2 楼 @lihuazhang 另外 是不是 app-activity 和 app-package 只能向开发获取呀?没有工具可以得到吗?
#2 楼 @lihuazhang 第二个问题 我尝试过使用你说的这种方式,也是一样的错误。。
另外我还有个疑问,如果我想在 android 中测试 native 的程序,比如 mms,phone 等,那我的 app 应该设置为什么?
我当前的设置是
"app","mms"
如果不指定 app-activity 或者 pachage 的话 ,appium 会让你指定,可是我不知道怎么获取 app 的 activity?
MainActivity incorrent.
cap.setCapability(CapabilityType.BROWSER_NAME, "");
cap.setCapability(CapabilityType.VERSION, "4.4.2");
cap.setCapability(CapabilityType.PLATFORM, "MAC");//iPhone Simulator iPad Device Selendroid
cap.setCapability("device","Android");
cap.setCapability("app", "mms");//app.getAbsolutePath() chromium ContactManager /Users/administrator/Documents/ContactManager.apk
//cap.setCapability("launch", "true");
cap.setCapability("app-activity", "MainActivity");//MainActivity .ContactManager
cap.setCapability("app-package", "com.android.mms");//com.example.android.contactmanager
#2 楼 @lihuazhang
好的 非常感谢你的帮助
好的 非常感谢你的帮助
hi 你好
非常感谢你的帮助。
我按照你的帖子,在我这台 mac 上运行起来有以下 2 个问题,我都尝试搜索了下。。。实在出于我的英文太烂了,用 google 翻译都是一只半解的,还请帮忙看下这些问题呀。
1.当我在模拟器上 launch safari 的时候,每次都回先打开 apple 的网址,等加载完后,webdriver 就抛出异常了,没有到达我制定的网址。
APPIUM 异常:
info: Welcome to Appium v0.12.3
info: Appium REST http interface listener started on 0.0.0.0:4723
info - socket.io started
info: Not spawning instruments force-quit watcher since it only works on 10.9 and you have 10.8.5
info: Responding to client with success: {"status":0,"value":{"build":{"version":"0.12.3","revision":"c8abd030c0cedcc387532f2aa986fd956e46eb4f"}}}
GET /wd/hub/status 200 7ms - 144b
debug: Appium request initiated at /wd/hub/status
debug: Request received with params: {}
debug: Appium request initiated at /wd/hub/session
info: Determining current user
debug: Request received with params: {"desiredCapabilities":{"platform":"iPhone Simulator","app":"safari","version":"7.0"}}
info: User is administrator
error: Could not find support directory for mobile safari, does it exist at Library/Application Support/iPhone Simulator/7.0/Library/ or /Users/administrator/Library/Application Support/iPhone Simulator/7.0/Library/?
info: ENOENT, stat '/Users/administrator/Library/Application Support/iPhone Simulator/7.0/Library'
info: Using local zip or ipa from desiredCaps: ./build/SafariLauncher/SafariLauncherSim.zip
info: Copying local zip to tmp dir
info: ./build/SafariLauncher/SafariLauncherSim.zip copied to /var/folders/b8/1vfhv4bx50g84c0brnnqtj9w0000gn/T/1131122-1506-19wavvt/appium-app.zip
info: Unzipping /var/folders/b8/1vfhv4bx50g84c0brnnqtj9w0000gn/T/1131122-1506-19wavvt/appium-app.zip
info: Testing zip archive: /var/folders/b8/1vfhv4bx50g84c0brnnqtj9w0000gn/T/1131122-1506-19wavvt/appium-app.zip
info: Zip archive tested clean
info: Unzip successful
info: Using locally extracted app: /var/folders/b8/1vfhv4bx50g84c0brnnqtj9w0000gn/T/1131122-1506-19wavvt/submodules/SafariLauncher/build/Release-iphonesimulator/SafariLauncher.app
info: Creating new appium session 25762106-558d-467e-8652-efdecd8a2f4b
info: Removing any remaining instruments sockets
info: Cleaned up instruments socket /tmp/instruments_sock
warn: Could not parse plist file at /var/folders/b8/1vfhv4bx50g84c0brnnqtj9w0000gn/T/1131122-1506-19wavvt/submodules/SafariLauncher/build/Release-iphonesimulator/SafariLauncher.app/en.lproj/Localizable.strings
debug: Launching device: iPhone Retina (4-inch)
info: Killing the simulator process
info: Parsed app Info.plist
info: Wrote new app Info.plist with device type
info: Starting iOS 7.* simulator log capture
debug: No device id or app, not installing to real device.
info: Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
debug: Creating instruments
info: [INSTSERVER] Instruments socket server started at /tmp/instruments_sock
info: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate /var/folders/b8/1vfhv4bx50g84c0brnnqtj9w0000gn/T/1131122-1506-19wavvt/submodules/SafariLauncher/build/Release-iphonesimulator/SafariLauncher.app -e UIASCRIPT /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/uiauto/bootstrap.js -e UIARESULTSPATH /tmp/appium-instruments/
info: And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/Applications/Appium.app/Contents/Resources/node_modules/appium/build/iwd/InstrumentsShim.dylib","LIB_PATH":"/Applications/Appium.app/Contents/Resources/node_modules/appium/build/iwd"}
info: And launch timeout: 90000ms
debug: Appium request initiated at /wd/hub/status
info: Responding to client with success: {"status":0,"value":{"build":{"version":"0.12.3","revision":"c8abd030c0cedcc387532f2aa986fd956e46eb4f"}},"sessionId":"25762106-558d-467e-8652-efdecd8a2f4b"}
debug: Request received with params: {}
GET /wd/hub/status 200 4ms - 199b
info: [INST STDERR] 2013-12-22 08:31:04.631 ScriptAgent[1591:3007] CLTilesManagerClient: initialize, sSharedTilesManagerClient
info: [INST STDERR] 2013-12-22 08:31:04.632 ScriptAgent[1591:3007] CLTilesManagerClient: init
info: [INST STDERR] 2013-12-22 08:31:04.633 ScriptAgent[1591:3007] CLTilesManagerClient: reconnecting, 0xa176510
info: [INSTSERVER] Instruments is ready to receive commands
info: Instruments launched. Starting poll loop for new commands.
info: [INSTSERVER] Socket data received (15 bytes)
info: [INSTSERVER] Socket data being routed for 'cmd' event
info: Navigating to most recently opened webview
info: [REMOTE] Debugger socket connected to ::1:27753
debug: [REMOTE] Sending _rpc_reportIdentifier: message to remote debugger
info: [REMOTE] Sending connection key
info: [REMOTE] Selecting app
info: Picking webview 1
info: [REMOTE] Selecting page 1 and forwarding socket setup
info: [REMOTE] Set sender key
debug: [REMOTE] { __argument: { WIRConnectionIdentifierKey: 'd06114b4-f048-4d4f-b7a1-a743c38f5184' },
__selector: '_rpc_reportIdentifier:' }
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] { __selector: '_rpc_reportSetup:',
__argument:
{ WIRSimulatorNameKey: 'iPhone Simulator',
WIRSimulatorProductVersionKey: '7.0.3',
WIRSimulatorBuildKey: '11B508' } }
debug: [REMOTE] Sim name: iPhone Simulator
debug: [REMOTE] Sim build: 11B508
debug: [REMOTE] { __selector: '_rpc_reportConnectedApplicationList:',
__argument:
{ WIRApplicationDictionaryKey:
{ 'com.apple.mobilesafari':
{ WIRApplicationIdentifierKey: 'com.apple.mobilesafari',
WIRApplicationNameKey: 'Safari',
WIRIsApplicationProxyKey: false } } } }
debug: [REMOTE] Sending _rpc_forwardGetListing: message to remote debugger
debug: [REMOTE] { __argument:
{ WIRConnectionIdentifierKey: 'd06114b4-f048-4d4f-b7a1-a743c38f5184',
WIRApplicationIdentifierKey: 'com.apple.mobilesafari' },
__selector: '_rpc_forwardGetListing:' }
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] { __selector: '_rpc_applicationSentListing:',
__argument:
{ WIRApplicationIdentifierKey: 'com.apple.mobilesafari',
WIRListingKey:
{ '1':
{ WIRPageIdentifierKey: 1,
WIRTitleKey: 'Apple',
WIRURLKey: 'http://www.apple.com/' } } } }
debug: [REMOTE] Sending _rpc_forwardSocketSetup: message to remote debugger
debug: [REMOTE] { __argument:
{ WIRApplicationIdentifierKey: 'com.apple.mobilesafari',
WIRConnectionIdentifierKey: 'd06114b4-f048-4d4f-b7a1-a743c38f5184',
WIRSenderKey: 'bc8a3a50-d0e6-4c68-bbdc-cbede9cd210e',
WIRPageIdentifierKey: 1 },
__selector: '_rpc_forwardSocketSetup:' }
debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] <applicationSentData response>
debug: [REMOTE] Checking document readyState
debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] <applicationSentData response>
debug: [REMOTE] readyState was complete
info: [REMOTE] Enabled activity on page
info: [REMOTE] Sending javascript command
info: Overriding session id with [object Object]
info: Device launched! Ready for commands (will time out in 60secs)
info: Appium session started with sessionId [object Object]
POST /wd/hub/session 303 15334ms - 9b
debug: [REMOTE] Receiving data from remote debugger
info: Remote debugger notified us of a new page listing
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] { __selector: '_rpc_applicationSentListing:',
__argument:
{ WIRApplicationIdentifierKey: 'com.apple.mobilesafari',
WIRListingKey:
{ '1':
{ WIRConnectionIdentifierKey: 'd06114b4-f048-4d4f-b7a1-a743c38f5184',
WIRURLKey: 'http://www.apple.com/',
WIRTitleKey: 'Apple',
WIRPageIdentifierKey: 1 } } } }
debug: [REMOTE] Page loaded, verifying through readyState
debug: [REMOTE] Checking document readyState
debug: [REMOTE] Sending _rpc_forwardSocketData: message to remote debugger
info: [REMOTE] Sending javascript command
info: New page listing is same as old, doing nothing
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] Receiving data from remote debugger
debug: [REMOTE] <applicationSentData response>
debug: [REMOTE] readyState was complete
debug: [REMOTE] Page is ready, calling onload cbs
Code:
public static void callMac() throws MalformedURLException, InterruptedException {
DesiredCapabilities cap = new DesiredCapabilities();
WebDriver wd = null;
cap.setCapability(CapabilityType.VERSION, "7.0");
cap.setCapability(CapabilityType.PLATFORM, "iPhone Simulator");
cap.setCapability("app", "safari");///Users/administrator/Documents/WebViewApp.app
wd = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
wd.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
for (String winHandle : wd.getWindowHandles()) {
wd.switchTo().window(winHandle);
}
wd.get("http://www.baidu.com");
Thread.sleep(10000);
wd.quit();
}
public static void main(String... args) throws MalformedURLException, InterruptedException {
callMac();
}
WebDriver exceptions:
run:
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.38.0', revision: 'bd32d4e', time: '2013-12-05 16:16:40'
System info: host: 'administrators-Mac-mini.local', ip: '192.168.1.100', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.5', java.version: '1.7.0_45'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
at apptest.iMAC.callMac(iMAC.java:28)
at apptest.iMAC.main(iMAC.java:39)
Caused by: org.apache.http.client.ClientProtocolException
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:867)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:319)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:298)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
... 5 more
Caused by: org.apache.http.ProtocolException: Invalid redirect URI: http://127.0.0.1:4723/wd/hub/session/[object Object]
at org.apache.http.impl.client.DefaultRedirectStrategy.createLocationURI(DefaultRedirectStrategy.java:197)
at org.apache.http.impl.client.DefaultRedirectStrategy.getLocationURI(DefaultRedirectStrategy.java:145)
at org.apache.http.impl.client.DefaultRedirectStrategy.getRedirect(DefaultRedirectStrategy.java:217)
at org.apache.http.impl.client.DefaultRequestDirector.handleResponse(DefaultRequestDirector.java:1065)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:514)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
... 10 more
Caused by: java.net.URISyntaxException: Illegal character in path at index 37: http://127.0.0.1:4723/wd/hub/session/[object Object]
at java.net.URI$Parser.fail(URI.java:2829)
at java.net.URI$Parser.checkChars(URI.java:3002)
at java.net.URI$Parser.parseHierarchical(URI.java:3086)
at java.net.URI$Parser.parse(URI.java:3034)
at java.net.URI.<init>(URI.java:595)
at org.apache.http.impl.client.DefaultRedirectStrategy.createLocationURI(DefaultRedirectStrategy.java:186)
... 15 more
Java Result: 1
BUILD SUCCESSFUL (total time: 16 seconds)
第二个问题:
我尝试配置并且启动 ios_webkit_debug_proxy 的时候曝出以下错误,我试着去找解决办法,找了下面 2 个帮助,我看他们说的 貌似解决了。。但是我没看懂怎么解决的。。我下的也是最新 branch 的 master。
http://www.google.com.hk/url?sa=t&rct=j&q=Invalid+idevice_connection+struct%3F&source=web&cd=1&ved=0CCwQFjAA&url=%68%74%74%70%73%3a%2f%2f%67%69%74%68%75%62%2e%63%6f%6d%2f%67%6f%6f%67%6c%65%2f%69%6f%73%2d%77%65%62%6b%69%74%2d%64%65%62%75%67%2d%70%72%6f%78%79%2f%69%73%73%75%65%73%2f%33%38&ei=7jW2UoPGMOO1iQeX5IDYDQ&usg=AFQjCNESThDmaZ9MwPFpEU9dE3z7UQ5HMw
error:
administrators-Mac-mini:~ administrator$ ios_webkit_debug_proxy
Invalid idevice_connection struct?: Undefined error: 0
Unable to get connection file descriptor.: Undefined error: 0
Unable to attach e999ccef170a38133665c2c1120f471ca90e06ed inspector```
报名~~~顶一个