Hi,
I am not able to click a button on the ionic app. I am testing it on the Samsung S6 Edge device. I am not sure what’s wrong. Need help!
UIAutomator info:(Forum not letting me upload the screenshot. getting error)
index: 0
class: android.widget.Button
package: dt.buyer.application.test
content-desc: menu (I see an extra space in the uiautomator. Not sure it’s the code issue or uiautomator adds that space after the menu)
bounds: [40,144][216,272]
Appium Log:
Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘//android.widget.Button[@content-desc=“menu”]’ using ‘XPATH’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] Received command result from bootstrap
[BaseDriver] Waited for 58948 ms so far
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“Could not find an element using supplied strategy. “}
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:”//android.widget.Button[@content-desc=“menu”]”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“xpath”,“selector”:"//android.widget.Button[@content-desc=“menu”]",“context”:"",“multiple”:false}}
Here’s my code:
using System;
//using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Appium.Enums;
using OpenQA.Selenium.Remote;
using NUnit.Framework;
using OpenQA.Selenium.Support.UI;
using System.Threading;
namespace IonicTests
{
[TestClass]
public class UnitTest1
{
private static AppiumDriver<AndroidElement> _driver;
[SetUp]
public static void BeforeAll() {
DesiredCapabilities cap = new DesiredCapabilities();
cap.SetCapability("deviceName", "Android");
cap.SetCapability("udid", "xxxxxxx");
cap.SetCapability(OpenQA.Selenium.Appium.Enums.MobileCapabilityType.NoReset, true);
cap.SetCapability("app","C:\\IonicTests\\android-debug.apk"); /* App-Push */
cap.SetCapability("appPackage", "dt.inv.buyer");
cap.SetCapability("appActivity", "dt.inv.buyer.MainActivity");
cap.SetCapability("newCommandTimeout", 120);
cap.SetCapability("appWaitActivity", "dt.inv.buyer.MainActivity");
cap.SetCapability(MobileCapabilityType.NewCommandTimeout, "1500");
TimeSpan t = new TimeSpan(300);
_driver = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), cap);
_driver.InstallApp("C:\\IonicTests\\android-debug.apk");
}
[Test]
public static void TestMethod1()
{
// _driver.Context = ("NATIVE_APP");
//_driver.FindElement(By.Name("SIGN IN")).Click();
//_driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMinutes(1));
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMinutes(1);
//Thread.Sleep(30);
_driver.FindElement(By.XPath("//android.widget.Button[@content-desc=\"menu\"]")).Click();
//_driver.FindElement(By.XPath("//android.widget.Button[@content-desc='menu']")).Click();
}
[TearDown]
public static void AfterAll()
{
_driver.Quit();
_driver.Dispose();
_driver = null;
}
}
}