Я тестирую веб-приложение на реальном устройстве и использую браузер Chrome, пытаюсь установить коллекцию и получаю NATIVE_APP и WEBVIEW_chrome, но когда я пытаюсь переключиться на WEBVIEW_chrome с помощью метода driver.context (), он выдает исключение "io.appium.java_client.NoSuchContextException: io.appium.java_client.NoSuchContextException: неизвестная ошибка на стороне сервера при обработке команды. Исходная ошибка: при обработке команды возникла неизвестная ошибка на стороне сервера. Исходная ошибка: неизвестная ошибка: не удалосьпереадресация портов на устройство 18e6bebc: неизвестная ошибка: команда adb завершилась неудачно. Дополнительный ответ: <>. Пожалуйста, помогите мне, я борюсь с последние 2 недели. Заранее спасибо.
Я пробовал возможности и Testscriptдля amazon.in следующим образом:
private static AndroidDriver<WebElement> driver = null;
@BeforeTest
public void initConfig() throws MalformedURLException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Galaxy C9 Pro");
capabilities.setCapability("platformVersion", "8.0.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", "com.android.chrome");
capabilities.setCapability("appActivity", "com.google.android.apps.chrome.Main");
capabilities.setCapability("startIWDP", true);
capabilities.setCapability("adbExecTimeout", 20000);
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
}
@Test
public void chromeTest() throws InterruptedException {
System.out.println("Hello Android");
System.out.println("Started Mobile Testing......");
//driver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS);
System.out.println("start");
System.out.println("after wait 3000----------------------------------------------");
Set<String> context = driver.getContextHandles();
System.out.println(context.size());
for(String contexts : context) { System.out.println(contexts); }
WebElement searchbar_txt = driver.findElementById("com.android.chrome:id/search_box_text");
searchbar_txt.click();
WebElement url_Bar = driver.findElementById("com.android.chrome:id/url_bar");
url_Bar.sendKeys("amazon.in");
WebElement urlhistory = driver.findElementByXPath("//*[@text='amazon.in']");
// findElementByName("Kotak Securities");
urlhistory.click();
Thread.sleep(4000);
Set<String> context1 = driver.getContextHandles();
System.out.println(context1.size());
for(String contexts : context1) { System.out.println(contexts); }
// driver.context((String) context1.toArray()[1]);
driver.context("WEBVIEW_chrome");
Thread.sleep(4000);
driver.findElementById("nav-search-keywords").sendKeys("Bags");
driver.findElementByTagName("Submit").click();
Выход консоли Eclipse:
Nov 02, 2019 12:19:03 PM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C
Hello Android
Started Mobile Testing......
start
after wait 3000----------------------------------------------
1
NATIVE_APP
2
NATIVE_APP
WEBVIEW_chrome
FAILED: chromeTest
io.appium.java_client.NoSuchContextException: An unknown server-side error occurred while processing the command. Original error: An unknown server-side error occurred while processing the command. Original error: unknown error: Failed to forward ports to device 18e6bebc: . unknown error: The adb command failed. Extra response: <>.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'TVDLT020', ip: '192.168.1.12', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {adbExecTimeout: 20000, appActivity: com.google.android.apps.chr..., appPackage: com.android.chrome, databaseEnabled: false, desired: {adbExecTimeout: 20000, appActivity: com.google.android.apps.chr..., appPackage: com.android.chrome, deviceName: Galaxy C9 Pro, noReset: true, platformName: android, platformVersion: 8.0.0, startIWDP: true}, deviceApiLevel: 26, deviceManufacturer: samsung, deviceModel: SM-C900F, deviceName: 18e6bebc, deviceScreenDensity: 420, deviceScreenSize: 1080x1920, deviceUDID: 18e6bebc, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, noReset: true, pixelRatio: 2.625, platform: LINUX, platformName: Android, platformVersion: 8.0.0, startIWDP: true, statBarHeight: 63, takesScreenshot: true, viewportRect: {height: 1857, left: 0, top: 63, width: 1080}, warnings: {}, webStorageEnabled: false}
Session ID: 3e90e00b-2eba-40b9-9b85-fc66fde1b491
at io.appium.java_client.AppiumDriver.context(AppiumDriver.java:229)
at appiumAndroidApp.appiumAndroid_GoogleWeb.chromeTest(appiumAndroid_GoogleWeb.java:93)
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:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
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)
Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: An unknown server-side error occurred while processing the command. Original error: unknown error: Failed to forward ports to device 18e6bebc: . unknown error: The adb command failed. Extra response: <>.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'TVDLT020', ip: '192.168.1.12', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {adbExecTimeout: 20000, appActivity: com.google.android.apps.chr..., appPackage: com.android.chrome, databaseEnabled: false, desired: {adbExecTimeout: 20000, appActivity: com.google.android.apps.chr..., appPackage: com.android.chrome, deviceName: Galaxy C9 Pro, noReset: true, platformName: android, platformVersion: 8.0.0, startIWDP: true}, deviceApiLevel: 26, deviceManufacturer: samsung, deviceModel: SM-C900F, deviceName: 18e6bebc, deviceScreenDensity: 420, deviceScreenSize: 1080x1920, deviceUDID: 18e6bebc, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, noReset: true, pixelRatio: 2.625, platform: LINUX, platformName: Android, platformVersion: 8.0.0, startIWDP: true, statBarHeight: 63, takesScreenshot: true, viewportRect: {height: 1857, left: 0, top: 63, width: 1080}, warnings: {}, webStorageEnabled: false}
Session ID: 3e90e00b-2eba-40b9-9b85-fc66fde1b491
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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)
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.context(AppiumDriver.java:226)
... 26 more
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
Я не могу переключить контекст и отправить ключи на панели поиска amazon.in. Я сделал ошибку или я делаю что-то не так.
для Appium Loг, пожалуйста, обратитесь по ссылке ниже:
https://1drv.ms/t/s!AhlCZJfQWY3ngzWsr7mLaF4CtxO9?e=gFXxDd