@chenhengjie123
你好:
在代码中使用了 driver1.context(“NATIVE_APP”)以后用 swipe 就不会出现错误了
谢谢,你的帮忙。
@chenhengjie123
我的代码是这样的
Set<String> contextNames = driver1.getContextHandles();
for (String contextName : contextNames){
System.out.println(contextName);
if(contextName.contains("WEBVIEW")||contextName.contains("webview"))
{ driver1.context(contextName); }
else{ System.out.println("no WEBVIEW"); }
}
driver1.findElementByClassName("item-container");
driver1.swipe(60, 0, -700, 60, 500);
for 循环的到的结果是 NATIVE_APP no WEBVIEW CHROMIUM no WEBVIEW
这是不是能够说明我是在 native app 这个 context
@chenhengjie123
但是用 uiautomatorviewer 才看页面的时候是 WEBVIEW
Set<String> contextNames = driver1.getContextHandles();
for (String contextName : contextNames){
System.out.println(contextName);
if(contextName.contains("WEBVIEW")||contextName.contains("webview"))
{ driver1.context(contextName); }
else{ System.out.println("no WEBVIEW"); }
}
得到的结果是
NATIVE_APP
no WEBVIEW
CHROMIUM
no WEBVIEW
@chenhengjie123
不行呀,报的同样的错误。
你看一下是不是我的写的代码不对
driver1.manage().timeouts().pageLoadTimeout(7000, TimeUnit.SECONDS);
driver1.get("https://estore-int01.mercedes-benz.com.cn/");
Set<String> contextNames = driver1.getContextHandles();
WebElement start = driver1.findElement(By.id("classes-and-campaigns"));
Point beginLoc = start.getLocation();
driver1.swipe(beginLoc.getX(), beginLoc.getY(), beginLoc.getX()-700, beginLoc.getY(), 8000);
@chenhengjie123
你再帮帮看看是什么问题
@bueaty
TouchAction 的 perform() 方法会报错 Method has not yet been implemented
用的 appium 是 1.6.3
@a3096556718
我用你的方法时候报错
org.openqa.selenium.WebDriverException: Method has not yet been implemented (WARNING: The server did not provide any stacktrace information)
主要是 perform() 这个方法
@666
你好:你用的 os.popen("adb shell input tap " + str(676.0) + " " + str(1783.0)) ,其中的 os 是什么东西
如果用 java 如何实现。
@Denselight
你用的 appium-client 是那个版本。
我这边也报错
不过错误是
org.openqa.selenium.WebDriverException: Method has not yet been implemented (WARNING: The server did not provide any stacktrace information)
我是这样写的
driver.tap(1, 100, 820, 300);
你好,我用 AndroidDriver 中的 tap 报错
我用的 appium-client 是 1.6.3 的
@gui3836337
你能用了吗?咋样用的
我用了 tap 的时候报出同样的错误
@chenhengjie123
你好:我用的 appium-client 版本是 1.6.3
日志报错
Exception in thread "main" org.openqa.selenium.WebDriverException: Method has not yet been implemented (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 33 milliseconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'DESKTOP-5QUNUQR', ip: '192.168.6.193', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.7.0_79'
Session ID: 5c8fa93a-a973-4b3a-9e72-7d7b649b1330
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{platform=LINUX, javascriptEnabled=true, browserName=browser, networkConnectionEnabled=true, desired={newCommandTimeout=200000, platformVersion=5.0.2, platformName=Android, deviceName=emulator-5554, browserName=browser, unicodeKeyboard=true, resetKeyboard=true}, locationContextEnabled=false, deviceUDID=emulator-5554, newCommandTimeout=200000, platformVersion=5.0.2, databaseEnabled=false, platformName=Android, deviceName=emulator-5554, webStorageEnabled=false, unicodeKeyboard=true, resetKeyboard=true, warnings={}, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:43)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at io.appium.java_client.AppiumDriver.performTouchAction(AppiumDriver.java:316)
at io.appium.java_client.TouchAction.perform(TouchAction.java:318)
at io.appium.java_client.AppiumDriver.swipe(AppiumDriver.java:365)
at estore.Test.main(Test.java:47)
appim 报错
[HTTP] --> POST /wd/hub/session/5c8fa93a-a973-4b3a-9e72-7d7b649b1330/url {"url":"*************"}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/5c8fa93a-a973-4b3a-9e72-7d7b649b1330/url] to [POST http://127.0.0.1:8000/wd/hub/session/19fc6b414b91e5520209ef9ace6f1bdb/url] with body: {"url":"*****************"}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"19fc6b414b91e5520209ef9ace6f1bdb","status":0,"value":null}
[JSONWP Proxy] Replacing sessionId 19fc6b414b91e5520209ef9ace6f1bdb with 5c8fa93a-a973-4b3a-9e72-7d7b649b1330
[HTTP] <-- POST /wd/hub/session/5c8fa93a-a973-4b3a-9e72-7d7b649b1330/url 200 129133 ms - 76
[HTTP] --> POST /wd/hub/session/5c8fa93a-a973-4b3a-9e72-7d7b649b1330/element {"using":"id","value":"classes-and-campaigns"}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/5c8fa93a-a973-4b3a-9e72-7d7b649b1330/element] to [POST http://127.0.0.1:8000/wd/hub/session/19fc6b414b91e5520209ef9ace6f1bdb/element] with body: {"using":"id","value":"classes-and-campaigns"}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"19fc6b414b91e5520209ef9ace6f1bdb","status":0,"value":{"ELEMENT":"0.6417469698935747-1"}}
[JSONWP Proxy] Replacing sessionId 19fc6b414b91e5520209ef9ace6f1bdb with 5c8fa93a-a973-4b3a-9e72-7d7b649b1330
[HTTP] <-- POST /wd/hub/session/5c8fa93a-a973-4b3a-9e72-7d7b649b1330/element 200 100 ms - 106
[HTTP] --> GET /wd/hub/session/5c8fa93a-a973-4b3a-9e72-7d7b649b1330/element/0.6417469698935747-1/location {}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [GET /wd/hub/session/5c8fa93a-a973-4b3a-9e72-7d7b649b1330/element/0.6417469698935747-1/location] to [GET http://127.0.0.1:8000/wd/hub/session/19fc6b414b91e5520209ef9ace6f1bdb/element/0.6417469698935747-1/location] with body: {}
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"19fc6b414b91e5520209ef9ace6f1bdb\",\"status\":0,\"value\":{\"ceil\":{},\"clone\":{},\"floor\":{},\"round\":{},\"scale\":{},\"toString\":{},\"translate\":{},\"x\":0,\"y\":60}}"
[JSONWP Proxy] Replacing sessionId 19fc6b414b91e5520209ef9ace6f1bdb with 5c8fa93a-a973-4b3a-9e72-7d7b649b1330
[HTTP] <-- GET /wd/hub/session/5c8fa93a-a973-4b3a-9e72-7d7b649b1330/element/0.6417469698935747-1/location 200 37 ms - 169
[HTTP] --> POST /wd/hub/session/5c8fa93a-a973-4b3a-9e72-7d7b649b1330/touch/perform {"actions":[{"action":"press","options":{"x":0,"y":60}},{"action":"wait","options":{"ms":8000}},{"action":"moveTo","options":{"x":-700,"y":60}},{"action":"release","options":{}}]}
[debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"x":0,"y":60}},{"action":"wait","options":{"ms":8000}},{"action":"moveTo","options":{"x":-700,"y":60}},{"action":"release","options":{}}],"5c8fa93a-a973-4b3a-9e72-7d7b649b1330"]
[HTTP] <-- POST /wd/hub/session/5c8fa93a-a973-4b3a-9e72-7d7b649b1330/touch/perform 501 27 ms - 122
java 代码
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "emulator-5554");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "5.0.2");
capabilities.setCapability("unicodeKeyboard", true);
capabilities.setCapability("resetKeyboard", true);
capabilities.setCapability(CapabilityType.BROWSER_NAME, "browser");
capabilities.setCapability("unicodeKeyboard",true);
capabilities.setCapability("resetKeyboard",true);
capabilities.setCapability("newCommandTimeout", 200000);
AndroidDriver driver1 = null;
try {
driver1 = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
} catch (MalformedURLException e) {
e.printStackTrace();
}
driver1.manage().timeouts().pageLoadTimeout(7000, TimeUnit.SECONDS);
// driver1.get("http://www.baidu.com");
driver1.get("***************************/");
WebElement start = driver1.findElement(By.id("classes-and-campaigns"));
Point beginLoc = start.getLocation();
driver1.swipe(beginLoc.getX(), beginLoc.getY(), beginLoc.getX()-700, beginLoc.getY(), 8000);
end
大侠们,帮帮忙