Hi Tom,
I am trying to run my test for our Hybrid mobile application using C# as programming language in visual studio. I recorded the actions using appium studio and exported in visual studio and modified few things in the script. When appium studio recorded i dont see the script in hybrid mode. I made the change in script by setting the capability “AutoWebview” as true and executed by setting the driver context as “WEBVIEW_1”. I am getting the following error when executing the test. Below is the error snapshot
Also is there a way in appium studio to get the recorded scripts in hybrid mode.
Result StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Appium.AppiumDriver
1.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value) at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByXPath(String xpath) at OpenQA.Selenium.By.<>c__DisplayClasse.<XPath>b__c(ISearchContext context) at OpenQA.Selenium.By.FindElement(ISearchContext context) at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by) at OpenQA.Selenium.Appium.AppiumDriver
1.FindElement(By by)
Result Message: System.InvalidOperationException : no such element (An element could not be located on the page using the given search parameters (XPATH=’//select/option[1]’))
I have pasted the script below
[TestFixture]
public class CRM_LOGIN
{
private string reportDirectory = “reports”;
private string reportFormat = “xml”;
private string testName = “CRM_LOGIN”;
protected AndroidDriver driver = null;
DesiredCapabilities dc = new DesiredCapabilities();
[SetUp()]
public void SetupTest()
{
dc.SetCapability("reportDirectory", reportDirectory);
dc.SetCapability("reportFormat", reportFormat);
dc.SetCapability("testName", "CRMFunctionTest");
dc.SetCapability(MobileCapabilityType.Udid, "Moto78");
dc.SetCapability(MobileCapabilityType.App, "C:\\test.apk");
dc.SetCapability(AndroidMobileCapabilityType.AppPackage, "test.package");
dc.SetCapability("noReset", false);
dc.SetCapability(MobileCapabilityType.AutoWebview, true);
dc.SetCapability(AndroidMobileCapabilityType.AppActivity, ".MainActivity");
driver = new AndroidDriver<AndroidElement>(new Uri("http://localhost:4723/wd/hub"), dc);
}
[Test()]
public void TestCRM_LOGIN()
{
driver.Context = "WEBVIEW_1";
driver.FindElement(By.XPath("xpath=//select/option[1]")).Click();
driver.FindElement(By.XPath("xpath=//*[@class='android.widget.Button' and ./preceding-sibling::*[@contentDescription='Accept? ']]")).Click();
}
[TearDown()]
public void TearDown()
{
driver.Quit();
}
}
}