appium 2.1.3(installed from npm)
appium desktop version 1.20.4
windows 10
android 3.1 2022
Here is my code:
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Appium.Android;
namespace DeviceTesting
{
[TestClass]
public class MobileTest
{
AppiumDriver driver;
[TestMethod]
public void SetCapabilities()
{
AppiumOptions cap = new AppiumOptions();
cap.AddAdditionalCapability("deviceName", "HUAWEI Y6 Prime 2019");
cap.AddAdditionalCapability("udid", "5HRNW19802009817");
cap.AddAdditionalCapability("platformName", "Android");
cap.AddAdditionalCapability("platformVersion", "9");
cap.AddAdditionalCapability("appPackage", "com.aw.smartcompanion.development");
cap.AddAdditionalCapability("appActivity", "com.aw.smartcompanion.development.MainActivity");
cap.AddAdditionalCapability("adbExecTimeout", "50000");
cap.AddAdditionalCapability("newCommandTimeout", "10000");
cap.AddAdditionalCapability("appWaitForLaunch", "false");
driver = new AndroidDriver<AppiumWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), cap);
Thread.Sleep(30000);
AppiumWebElement btn = driver.FindElementById("com.android.packageinstaller:id/permission_allow_button");
btn.Click();
AppiumWebElement name = driver.FindElementById("usernameBox");
name.Click();
name.SendKeys("MS HUAWEI");
AppiumWebElement locator = driver.FindElement(By.XPath("//android.widget.EditText[2]"));
locator.Click();
locator.SendKeys("0.0.0.0");
driver.FindElement(By.ClassName("android.view.View")).Click();
AppiumWebElement conectbtn = driver.FindElement(By.XPath("//android.widget.Button[@text='Connect']"));
conectbtn.Click();
Thread.Sleep(3000);
}
}
}
Here is the log:
[HTTP] Request idempotency key: 6f734930-2fc4-4612-83c0-33f6e498f440
[HTTP] --> POST /wd/hub/session/01569cf9-4ba3-4716-b21c-0f707e3b1ee3/element
[HTTP] {“using”:“id”,“value”:“com.android.packageinstaller:id/permission_allow_button”}
[W3C (01569cf9)] Calling AppiumDriver.findElement() with args: [“id”,“com.android.packageinstaller:id/permission_allow_button”,“01569cf9-4ba3-4716-b21c-0f707e3b1ee3”]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, css selector, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[WD Proxy] Matched ‘/element’ to command name ‘findElement’
[WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:8200/wd/hub/session/b8591a76-2403-4fed-a82b-8f624508084a/element] with body: {“strategy”:“id”,“selector”:“com.android.packageinstaller:id/permission_allow_button”,“context”:"",“multiple”:false}
[WD Proxy] Got response with status 200: {“sessionId”:“b8591a76-2403-4fed-a82b-8f624508084a”,“value”:{“ELEMENT”:“446aba33-4472-4f2d-af67-c11d8ed1545d”,“element-6066-11e4-a52e-4f735466cecf”:“446aba33-4472-4f2d-af67-c11d8ed1545d”}}
[W3C (01569cf9)] Responding to client with driver.findElement() result: {“element-6066-11e4-a52e-4f735466cecf”:“446aba33-4472-4f2d-af67-c11d8ed1545d”,“ELEMENT”:“446aba33-4472-4f2d-af67-c11d8ed1545d”}
[HTTP] <-- POST /wd/hub/session/01569cf9-4ba3-4716-b21c-0f707e3b1ee3/element 200 257 ms - 137
[HTTP]
[HTTP] Request idempotency key: dabb2504-6686-4fa8-a268-6d64622d7f47
[HTTP] --> POST /wd/hub/session/01569cf9-4ba3-4716-b21c-0f707e3b1ee3/element/446aba33-4472-4f2d-af67-c11d8ed1545d/click
[HTTP] {}
[W3C (01569cf9)] Calling AppiumDriver.click() with args: [“446aba33-4472-4f2d-af67-c11d8ed1545d”,“01569cf9-4ba3-4716-b21c-0f707e3b1ee3”]
[WD Proxy] Matched ‘/element/446aba33-4472-4f2d-af67-c11d8ed1545d/click’ to command name ‘click’
[WD Proxy] Proxying [POST /element/446aba33-4472-4f2d-af67-c11d8ed1545d/click] to [POST http://127.0.0.1:8200/wd/hub/session/b8591a76-2403-4fed-a82b-8f624508084a/element/446aba33-4472-4f2d-af67-c11d8ed1545d/click] with body: {“element”:“446aba33-4472-4f2d-af67-c11d8ed1545d”}
[WD Proxy] Got response with status 200: {“sessionId”:“b8591a76-2403-4fed-a82b-8f624508084a”,“value”:null}
[W3C (01569cf9)] Responding to client with driver.click() result: null
[HTTP] <-- POST /wd/hub/session/01569cf9-4ba3-4716-b21c-0f707e3b1ee3/element/446aba33-4472-4f2d-af67-c11d8ed1545d/click 200 136 ms - 14
[HTTP]
[HTTP] Request idempotency key: 24810a5a-cf28-4042-93b1-4c77c46c9ece
[HTTP] --> POST /wd/hub/session/01569cf9-4ba3-4716-b21c-0f707e3b1ee3/element
[HTTP] {“using”:“id”,“value”:“usernameBox”}
[W3C (01569cf9)] Calling AppiumDriver.findElement() with args: [“id”,“usernameBox”,“01569cf9-4ba3-4716-b21c-0f707e3b1ee3”]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, css selector, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[WD Proxy] Matched ‘/element’ to command name ‘findElement’
[WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:8200/wd/hub/session/b8591a76-2403-4fed-a82b-8f624508084a/element] with body: {“strategy”:“id”,“selector”:“usernameBox”,“context”:"",“multiple”:false}
[WD Proxy] Got response with status 404: {“sessionId”:“b8591a76-2403-4fed-a82b-8f624508084a”,“value”:{“error”:“no such element”,“message”:“An element could not be located on the page using the given search parameters”,“stacktrace”:"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:70)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:41)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:261)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:255)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:68)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.chann…
[W3C] Matched W3C error code ‘no such element’ to NoSuchElementError
[W3C (01569cf9)] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.
[W3C (01569cf9)] at AndroidUiautomator2Driver.findElOrEls (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\commands\find.js:75:11)
[W3C (01569cf9)] at runMicrotasks ()
[W3C (01569cf9)] at processTicksAndRejections (internal/process/task_queues.js:85:5)
[HTTP] <-- POST /wd/hub/session/01569cf9-4ba3-4716-b21c-0f707e3b1ee3/element 404 207 ms - 530