admin管理员组文章数量:1025498
I need to do Appium mobile test with C# and Nunit on my real device which is "Xiaomi Poco X3" for an already installed app. I write the following code:
public class Tests
{
AppiumDriver driver;
AppiumOptions appiumOptions;
[SetUp]
public void Setup()
{
appiumOptions = new AppiumOptions();
appiumOptions.PlatformVersion = "12";
appiumOptions.DeviceName = "285f941f";
appiumOptions.PlatformName = "Android";
appiumOptions.PlatformVersion = "11";
appiumOptions.AddAdditionalAppiumOption("uiautomator2ServerInstallTimeout", "6000");
appiumOptions.AddAdditionalAppiumOption("appPackage", "com.xxxc");
appiumOptions.AddAdditionalAppiumOption("appActivity", "com.xxxc.activity.MainActivity"); // Replace with your app's main activity
appiumOptions.AddAdditionalAppiumOption("udid", "285f941f");
appiumOptions.AddAdditionalAppiumOption("noReset", "true");
appiumOptions.AddAdditionalAppiumOption("adbExecTimeout", "20000");
//appWaitForLaunch
appiumOptions.AddAdditionalAppiumOption("appWaitForLaunch", "true");
appiumOptions.AddAdditionalAppiumOption("AndroidMobileCapabilityType.AutoGrantPermissions", "true"); // Grant permissions = true;
}
[Test]
public void Test1()
{
AppiumDriver driver = null;
try
{
driver = new AndroidDriver(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions);
Console.WriteLine("App launched successfully!");
// Wait for a few seconds to keep the app running
Thread.Sleep(5000); // Adjust the sleep time as needed
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.Message);
}
finally
{
// Close the driver session
driver?.Quit();
Console.WriteLine("Driver session ended.");
}
}
}
When I run the test I got the following exception: Activity name '.xxxc.activity/.MainActivity' used to start the app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity.
I am sure from the activity name as I get it from the adb command: dumpsys window displays -E "myCurrentFocus"
.
My code is similar to the code in the answer of this question but the application doesn't launched.
I appreciate any help you provide.
I need to do Appium mobile test with C# and Nunit on my real device which is "Xiaomi Poco X3" for an already installed app. I write the following code:
public class Tests
{
AppiumDriver driver;
AppiumOptions appiumOptions;
[SetUp]
public void Setup()
{
appiumOptions = new AppiumOptions();
appiumOptions.PlatformVersion = "12";
appiumOptions.DeviceName = "285f941f";
appiumOptions.PlatformName = "Android";
appiumOptions.PlatformVersion = "11";
appiumOptions.AddAdditionalAppiumOption("uiautomator2ServerInstallTimeout", "6000");
appiumOptions.AddAdditionalAppiumOption("appPackage", "com.xxxc");
appiumOptions.AddAdditionalAppiumOption("appActivity", "com.xxxc.activity.MainActivity"); // Replace with your app's main activity
appiumOptions.AddAdditionalAppiumOption("udid", "285f941f");
appiumOptions.AddAdditionalAppiumOption("noReset", "true");
appiumOptions.AddAdditionalAppiumOption("adbExecTimeout", "20000");
//appWaitForLaunch
appiumOptions.AddAdditionalAppiumOption("appWaitForLaunch", "true");
appiumOptions.AddAdditionalAppiumOption("AndroidMobileCapabilityType.AutoGrantPermissions", "true"); // Grant permissions = true;
}
[Test]
public void Test1()
{
AppiumDriver driver = null;
try
{
driver = new AndroidDriver(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions);
Console.WriteLine("App launched successfully!");
// Wait for a few seconds to keep the app running
Thread.Sleep(5000); // Adjust the sleep time as needed
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.Message);
}
finally
{
// Close the driver session
driver?.Quit();
Console.WriteLine("Driver session ended.");
}
}
}
When I run the test I got the following exception: Activity name '.xxxc.activity/.MainActivity' used to start the app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity.
I am sure from the activity name as I get it from the adb command: dumpsys window displays -E "myCurrentFocus"
.
My code is similar to the code in the answer of this question but the application doesn't launched.
I appreciate any help you provide.
本文标签: cMobile Application is not launchedStack Overflow
版权声明:本文标题:c# - Mobile Application is not launched - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745628815a2160030.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论