Dear All,
I had a same issue with WEBVIEW elements not being identified.
It was solved by instrumenting the application. If you are using Appium Studio, in the application capabilities section, there is a checkbox called “Instrument”. Selecting the Instrument checkbox before recording the script solved the problem. Selecting Instrument checkbox also added a new line of code:
dc.SetCapability(“instrumentApp”, true);
In case you are searching where is the Application Capabilities section: In Appium Studio, on the left hand side, there are 3 sections: 1) Device manager section with list of all connected devices, 2) Application Manager section with the list of all applications installed and 3) Application Capabilities section with 3 checkboxes: Install, No Reset, Instrument. This section is below the Application Manager section. Selecting the Instrument checkbox before recording the scripts solved the problem.
The code generated by Appium Studio looks like this:
//package ;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Appium.iOS;
using NUnit;
using NUnit.Framework;
using OpenQA.Selenium.Appium.Enums;
using OpenQA.Selenium.Support.UI;
namespace Experitest
{
[TestFixture]
public class WebviewLogin_Instrumented
{
private string reportDirectory = “reports”;
private string reportFormat = “xml”;
private string testName = “WebviewLogin-Instrumented”;
protected AndroidDriver driver = null;
DesiredCapabilities dc = new DesiredCapabilities();
[SetUp()]
public void SetupTest()
{
dc.SetCapability("reportDirectory", reportDirectory);
dc.SetCapability("reportFormat", reportFormat);
dc.SetCapability("testName", testName);
dc.SetCapability(MobileCapabilityType.Udid, "91FY17BQ9");
dc.SetCapability(AndroidMobileCapabilityType.AppPackage, "com.clearhorizon.chimedev");
dc.SetCapability(AndroidMobileCapabilityType.AppActivity, ".MainActivity");
dc.SetCapability("instrumentApp", true);
driver = new AndroidDriver<AndroidElement>(new Uri("http://localhost:4723/wd/hub"), dc);
}
[Test()]
public void TestWebviewLogin_Instrumented()
{
driver.Context = "WEBVIEW_1";
driver.FindElement(By.XPath("xpath=//ion-col[@class=\"syncButton md hydrated\"]")).Click();
new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementExists(By.LinkText(" Synchronise")));
driver.FindElement(By.LinkText(" Synchronise")).Click();
driver.FindElement(By.Id("i0116")).SendKeys("rk@clhoz.com");
new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementExists(By.Id("idSIButton9")));
driver.FindElement(By.Id("idSIButton9")).Click();
new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementExists(By.Id("i0118")));
driver.FindElement(By.Id("i0118")).SendKeys("ITIndustry123");
new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementExists(By.Id("idSIButton9")));
driver.FindElement(By.Id("idSIButton9")).Click();
}
[TearDown()]
public void TearDown()
{
driver.Quit();
}
}