本文整理汇总了C#中OpenQA.Selenium.Appium.Android.AndroidDriver.Manage方法的典型用法代码示例。如果您正苦于以下问题:C# AndroidDriver.Manage方法的具体用法?C# AndroidDriver.Manage怎么用?C# AndroidDriver.Manage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Appium.Android.AndroidDriver
的用法示例。
在下文中一共展示了AndroidDriver.Manage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeforeAll
public void BeforeAll()
{
DesiredCapabilities capabilities =
Caps.getAndroid19Caps(Apps.get("androidApiDemosLocal"));
Uri serverUri = AppiumServers.localURI;
driver = new AndroidDriver<AndroidElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC);
driver.Manage().Timeouts().ImplicitlyWait(Env.IMPLICIT_TIMEOUT_SEC);
}
示例2: Main
static void Main(string[] args)
{
AndroidDriver<AndroidElement> driver;
var INIT_TIMEOUT_SEC = TimeSpan.FromSeconds(180);
var Capabilities=new DesiredCapabilities();
var serverUrl = new Uri("http://172.0.0.1:4723/wd/hub");
// Capabilities.SetCapability(CapabilityType.BrowserName,"");
Capabilities.SetCapability(MobileCapabilityType.DeviceName,"Android");
//Capabilities.SetCapability(MobileCapabilityType.AppActivity,"");
//Capabilities.SetCapability(MobileCapabilityType.AppPackage,"");
Capabilities.SetCapability(MobileCapabilityType.AppiumVersion, "1.4.13");
Capabilities.SetCapability(MobileCapabilityType.App,@"C:/sample-code/apps/ApiDemos-debug.apk");
driver=new AndroidDriver<AndroidElement>(serverUrl,Capabilities,INIT_TIMEOUT_SEC);
driver.Manage().Timeouts().ImplicitlyWait(INIT_TIMEOUT_SEC);
driver.FindElementByName("Graphics").Click();
driver.ScrollTo("FingerPaint", "android:id/list");
driver.FindElementByName("FingerPaint").Click();
AndroidElement element = driver.FindElementById("android:id/content");
Point point = element.Coordinates.LocationInDom;
Size size = element.Size;
driver.Swipe
(
point.X + 5,
point.Y + 5,
point.X + size.Width - 5,
point.Y + size.Height - 5,
200
);
driver.Swipe
(
point.X + size.Width - 5,
point.Y + 5,
point.X + 5,
point.Y + size.Height - 5,
2000
);
driver.FindElementByName("Graphics").Click();
driver.ScrollTo("OpenGL ES", "android:id/list").Click();
//driver.FindElementByName("OpenGL ES").Click();
driver.ScrollTo("Touch Rotate", "android:id/list").Click();
//driver.FindElementByName("TouchRotate").Click();
AndroidElement element1 = driver.FindElementById("android:id/content");
driver.Pinch(element1);
driver.Zoom(element1);
Thread.Sleep(2000);
driver.Quit();
}
示例3: BeforeAll
public void BeforeAll(){
DesiredCapabilities capabilities = Env.isSauce () ?
Caps.getAndroid501Caps (Apps.get ("androidApiDemos")) :
Caps.getAndroid19Caps (Apps.get ("androidApiDemos"));
if (Env.isSauce ()) {
capabilities.SetCapability("username", Env.getEnvVar("SAUCE_USERNAME"));
capabilities.SetCapability("accessKey", Env.getEnvVar("SAUCE_ACCESS_KEY"));
capabilities.SetCapability("name", "android - simple");
capabilities.SetCapability("tags", new string[]{"sample"});
}
Uri serverUri = Env.isSauce () ? AppiumServers.sauceURI : AppiumServers.LocalServiceURIAndroid;
driver = new AndroidDriver<AndroidElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC);
driver.Manage().Timeouts().ImplicitlyWait(Env.IMPLICIT_TIMEOUT_SEC);
}
示例4: Main
static void Main(string[] args)
{
int EnableDemoN = 2;
#region Native Android App
if (EnableDemoN == 1)
{
//Set DesiredCapabilities
DesiredCapabilities nativeAppCapabilities = new DesiredCapabilities();
//Set device name if using emulator
nativeAppCapabilities.SetCapability(MobileCapabilityType.DeviceName, "192.168.56.101:5555");
nativeAppCapabilities.SetCapability(MobileCapabilityType.PlatformName, "Android");
//if android version<=4.1, should use Selendroid
nativeAppCapabilities.SetCapability(MobileCapabilityType.AutomationName, "Appium");
nativeAppCapabilities.SetCapability(MobileCapabilityType.PlatformVersion, "5.1");
//if don't want to launch the app in device directly, need set the package and activity
//otherwise, need specifies the absolute app folder
nativeAppCapabilities.SetCapability(MobileCapabilityType.AppPackage, "com.android.calculator2");
nativeAppCapabilities.SetCapability(MobileCapabilityType.AppActivity, "com.android.calculator2.Calculator");
//Start the driver
AppiumDriver<IWebElement> nativeAppdriver = new AndroidDriver<IWebElement>(
new Uri("http://127.0.0.1:4723/wd/hub"), nativeAppCapabilities);
//Specifies the amount of time the driver should wait when searching for an
// element if it is not immediately present
nativeAppdriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
//Get 0~9 button element
AndroidElement button_1 = (AndroidElement)nativeAppdriver.FindElement(By.Id("com.android.calculator2:id/digit_1"));
AndroidElement button_2 = (AndroidElement)nativeAppdriver.FindElement(By.Id("com.android.calculator2:id/digit_2"));
AndroidElement button_3 = (AndroidElement)nativeAppdriver.FindElement(By.Id("com.android.calculator2:id/digit_3"));
AndroidElement button_4 = (AndroidElement)nativeAppdriver.FindElement(By.Id("com.android.calculator2:id/digit_4"));
AndroidElement button_5 = (AndroidElement)nativeAppdriver.FindElement(By.Id("com.android.calculator2:id/digit_5"));
AndroidElement button_6 = (AndroidElement)nativeAppdriver.FindElement(By.Id("com.android.calculator2:id/digit_6"));
AndroidElement button_7 = (AndroidElement)nativeAppdriver.FindElement(By.Id("com.android.calculator2:id/digit_7"));
AndroidElement button_8 = (AndroidElement)nativeAppdriver.FindElement(By.Id("com.android.calculator2:id/digit_8"));
AndroidElement button_9 = (AndroidElement)nativeAppdriver.FindElement(By.Id("com.android.calculator2:id/digit_9"));
AndroidElement button_0 = (AndroidElement)nativeAppdriver.FindElement(By.Id("com.android.calculator2:id/digit_0"));
//Get +-*/ element
AndroidElement button_Add = (AndroidElement)nativeAppdriver.FindElementByName("+");
AndroidElement button_Sub = (AndroidElement)nativeAppdriver.FindElementByName("−");
AndroidElement button_Mul = (AndroidElement)nativeAppdriver.FindElementByName("×");
AndroidElement button_Div = (AndroidElement)nativeAppdriver.FindElementByName("÷");
//Get result element
IList<IWebElement> editElements = (IList<IWebElement>)nativeAppdriver.FindElements(By.ClassName("android.widget.EditText"));
AndroidElement formula = (AndroidElement)editElements[0];
AndroidElement result = (AndroidElement)editElements[1];
//Get equals element
AndroidElement equals = (AndroidElement)nativeAppdriver.FindElementByAccessibilityId("equals");
//#######Test Case1 verify 1+1=2
button_1.Click(); //press 1
button_Add.Click();//press +
button_1.Click();//press 1
equals.Click();//press =
string result_1 = formula.Text;//get result value
if (result_1 != "2")
{
Console.WriteLine("Test Case1 failed");
}
else
{
Console.WriteLine("Test Case1 pass");
}
//#######Test Case2 verify 1÷3=0.333333333333333333
button_1.Click();
button_Div.Click();
button_3.Click();
equals.Click();
string result_2 = formula.Text;
if (result_2 != "0.333333333333333333")
{
Console.WriteLine("Test Case1 failed");
}
else
{
Console.WriteLine("Test Case1 pass");
}
nativeAppdriver.Dispose();
}
#endregion
#region Hybird App
if (EnableDemoN == 2)
{
//Set DesiredCapabilities
DesiredCapabilities hybirdCapabilities = new DesiredCapabilities();
//Set device name if using emulator
hybirdCapabilities.SetCapability(MobileCapabilityType.DeviceName, "192.168.56.101:5555");
hybirdCapabilities.SetCapability(MobileCapabilityType.PlatformName, "Android");
hybirdCapabilities.SetCapability(MobileCapabilityType.AutomationName, "Appium");
hybirdCapabilities.SetCapability(MobileCapabilityType.PlatformVersion, "5.1");
//.........这里部分代码省略.........
示例5: BeforeAll
public void BeforeAll()
{
//Get Application Location
//string appURL = KeynoteHelper.GetApplicationURL("Remainder", "1.1", @"C:\Users\ssubram1\Desktop\Microsoft\app\com.expensemanager.apk"); //
Environment.SetEnvironmentVariable("APPIUM_DEVICE_LIST", "9021");
System.Console.WriteLine("APPIUM_DEVICE_LIST -->" + Environment.GetEnvironmentVariable("APPIUM_DEVICE_LIST"));
Environment.SetEnvironmentVariable("APPIUM_APP_URL", "samples/CSharp/app/com.expensemanager.apk");
string appURL = Environment.GetEnvironmentVariable("APPIUM_APP_URL");//, EnvironmentVariableTarget.Machine);
if (string.IsNullOrEmpty(appURL))
{
System.Console.WriteLine("APPIUM_APP_PATH -->" + Environment.GetEnvironmentVariable("APPIUM_APP_PATH"));
appURL = KeynoteHelper.GetApplicationURL("Remainder", "1.1", Environment.GetEnvironmentVariable("APPIUM_APP_PATH"));//, EnvironmentVariableTarget.Machine));
}
else
System.Console.WriteLine("APPIUM_APP_URL -->" + Environment.GetEnvironmentVariable("APPIUM_APP_URL"));
//set the desired capabilities
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.BrowserName, "");
capabilities.SetCapability(MobileCapabilityType.AppiumVersion, "1.0");
capabilities.SetCapability(MobileCapabilityType.PlatformVersion, "5.0.1");
//capabilities.SetCapability(MobileCapabilityType.PlatformName, "Android");
capabilities.SetCapability(MobileCapabilityType.DeviceName, "Samsung");
//Application download URI
//This can be any public url to download the app, MUST end with file type (*.apk or *.ipa)
//Please don not acquire device from website during complete automation mode, because script will acquire the device
capabilities.SetCapability(MobileCapabilityType.App, appURL);
Uri serverUri = null;
string devices = Environment.GetEnvironmentVariable("APPIUM_DEVICE_LIST");//, EnvironmentVariableTarget.Machine);
List<int> deviceList = new List<int>();
if (!string.IsNullOrEmpty(devices))
{
deviceList = devices.Split(",".ToCharArray()).Select(n => Convert.ToInt32(n)).ToList();
}
if (deviceList != null)
{
for (int i = 0; i < deviceList.Count; i++)
{
serverUri = KeynoteHelper.GetAppiumUrl(deviceList[i]);
}
}
//User following code for complete automation (acquire device and get appium Uri)
//serverUri = KeynoteHelper.GetAppiumUrl(9337);
//use following test for manual testing
//to use this option
// 1. Login to http://dademo112.deviceanywhere.com/
// 2. Acquire device
// 3. Tools --> Appium --> Start appium
// 4. copy the Uri from the browser and replace following url
//serverUri = new Uri("https://dademo112.deviceanywhere.com/appium/592fab14-2292-4353-b9ea-2585b06862ff/wd/hub/");
if (serverUri != null)
{
driver = new AndroidDriver<AndroidElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC);
driver.Manage().Timeouts().ImplicitlyWait(Env.IMPLICIT_TIMEOUT_SEC);
}
}