forked from appium/dotnet-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AndroidConnectionTest.cs
68 lines (62 loc) · 2.27 KB
/
AndroidConnectionTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Appium.Samples.Helpers;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Remote;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Appium.Samples
{
[TestFixture()]
class AndroidConnectionTest
{
private AppiumDriver driver;
private bool allPassed = true;
[TestFixtureSetUp]
public void BeforeAll()
{
DesiredCapabilities capabilities = Env.isSauce() ?
Caps.getAndroid18Caps(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 - complex");
capabilities.SetCapability("tags", new string[] { "sample" });
}
Uri serverUri = Env.isSauce() ? AppiumServers.sauceURI : AppiumServers.localURI;
driver = new AndroidDriver(serverUri, capabilities, Env.INIT_TIMEOUT_SEC);
driver.Manage().Timeouts().ImplicitlyWait(Env.IMPLICIT_TIMEOUT_SEC);
}
[TestFixtureTearDown]
public void AfterAll()
{
try
{
if (Env.isSauce())
((IJavaScriptExecutor)driver).ExecuteScript("sauce:job-result=" + (allPassed ? "passed" : "failed"));
}
finally
{
driver.Quit();
}
}
[TearDown]
public void AfterEach()
{
allPassed = allPassed && (TestContext.CurrentContext.Result.State == TestState.Success);
}
[Test]
public void ConnectionTest()
{
((AndroidDriver)driver).ConnectionType = ConnectionType.AirplaneMode;
Assert.AreEqual(ConnectionType.AirplaneMode, ((AndroidDriver)driver).ConnectionType);
((AndroidDriver)driver).ConnectionType = ConnectionType.WifiOnly;
Assert.AreEqual(ConnectionType.WifiOnly, ((AndroidDriver)driver).ConnectionType);
}
}
}