Hello,
I read the documentation but no have information about do with C# ( http://appium.io/docs/en/commands/context/set-context/ )
I have this CODE:
using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Remote;
using System.Drawing.Imaging;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
namespace NEWTEST
{
public class Test13
{
AndroidDriver<AndroidElement> driver;
DesiredCapabilities cap;
[SetUp]
public void Initdriver()
{
cap = new DesiredCapabilities();
cap.SetCapability("platformName", "Android");
cap.SetCapability("deviceName", "Mi A1");
cap.SetCapability("appPackage", "app.test.customerapp");
cap.SetCapability("appActivity", "app.test.customerapp.MainActivity");
cap.SetCapability("automationName", "Uiautomator2");
cap.SetCapability("autoWebview", true);
cap.SetCapability("setWebContentsDebuggingEnabled", true);
driver = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), cap);
driver.Context = ("WEBVIEW_app.test.customerapp");
}
[Test]
public void Test4565()
{
System.Threading.Thread.Sleep(10000);
//Take the screenshot
Screenshot image = ((ITakesScreenshot)driver).GetScreenshot();
//Save the screenshot
image.SaveAsFile("C:/temp/Screenshot.png", ScreenshotImageFormat.Png);
driver.FindElementByXPath("//Button[@id=\"Button_1\"]").Click();
driver.Quit();
}
[Test]
public void CloseDriver()
{
driver.Quit();
}
}
}
And in the appium server says that I have 2 contexts, but I do not know how to establish the context with the web view.:
Getting a list of available webviews
[ADB] Running 'C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -P 5037 -s ce091719ddb87f2c02 shell cat /proc/net/unix'
[AndroidDriver] WEBVIEW_25848 mapped to pid 25848
[AndroidDriver] Getting process name for webview
[ADB] Running 'C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -P 5037 -s ce091719ddb87f2c02 shell ps'
[AndroidDriver] Parsed pid: '25848' pkg: 'app.test.customerapp' from
[AndroidDriver] USER PID PPID VSIZE RSS WCHAN PC NAME
[AndroidDriver] u0_a509 25848 3269 110120 381736 SyS_epoll_ 0000000000 S com.riafinancial.customerapp
[AndroidDriver] Returning process name: 'app.test.customerapp'
[AndroidDriver] Found webviews: ["WEBVIEW_app.test.customerapp"]
[AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_app.test.customerapp"]
How i can select the context with the webview “WEBVIEW_app.test.customerapp”???
Thank you very much in advance
Regards