问题描述
我正在使用 Appium 和 c# 在 Android 真实设备上自动化移动网络测试.我已经看到 Java 中有 get 方法可以导航到给定的 URL,例如:
I'm automating mobile web testing on Android real device with Appium and c#.I've seen that there is get method in Java that allows navigation to the given URL, for example:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setPlatform(Platform.ANDROID);
capabilities.setCapability("device", "android");
capabilities.setCapability("app", "chrome");
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.get("http://www.google.com");
System.out.println("Android Title is: " + driver.getTitle())
我在 appium dot net driver 中找不到这样的方法.是我的错误还是没有这样的方法?那么最好的导航方式是什么?
I couldn't find such method in appium dot net driver.Is it my mistake or there is no such method?What is the best way to navigate then?
这是我使用的 C# 代码:
Here is C# code i use:
[TestClass]
public class UnitTest1
{
private DesiredCapabilities _capabilities;
private AndroidDriver _driver;
public void InitializeDriver()
{
Console.WriteLine("Connecting to Appium server");
_capabilities = new DesiredCapabilities();
_capabilities.SetCapability("deviceName", "Nexus One");
_capabilities.SetCapability("newCommandTimeout", "300");
_capabilities.SetCapability(CapabilityType.BrowserName, "Chrome");
_capabilities.SetCapability(CapabilityType.Version, "5.0.1");
_capabilities.SetCapability(CapabilityType.Platform, "Android");
//Application path and configurations
_driver = new AndroidDriver(new Uri("http://127.0.0.1:4723/wd/hub"), _capabilities);
}
没有 _driver.Get() 或 _driver.SendKeys.我应该用什么?
There is no _driver.Get() or _driver.SendKeys. What should i use?
推荐答案
可以通过对象浏览器找到答案(我就是这样做的).Java 代码的类比如下:
The answer could be found via Object Browser (this is what I did).The analogue of Java code looks like:
_navigation = _driver.Navigate();
_navigation.GoToUrl(@"http://stackoverflow.com");
所以完整的列表会变成这样:
So the full listing will become this:
public void InitializeDriver()
{
Console.WriteLine("Connecting to Appium server");
_capabilities = new DesiredCapabilities();
_capabilities.SetCapability("deviceName", "Nexus One");
_capabilities.SetCapability("newCommandTimeout", "300");
_capabilities.SetCapability(CapabilityType.BrowserName, "Browser");
_capabilities.SetCapability(CapabilityType.Version, "5.0.1");
_capabilities.SetCapability(CapabilityType.Platform, "Android");
//Application path and configurations
_driver = new AndroidDriver(new Uri("http://127.0.0.1:4723/wd/hub"), _capabilities);
_navigation = _driver.Navigate();
_navigation.GoToUrl(@"http://stackoverflow.com");
}
这篇关于如何在真实设备上使用 c# 和 appium 在移动 Chrome 浏览器中访问给定的 URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!