Skip to content

Commit 9581563

Browse files
.Net sample was updated to release 1.4.0.2
Now it shows capabilities of the latest stable release.
1 parent 1c44567 commit 9581563

24 files changed

Lines changed: 3285 additions & 9 deletions
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using Appium.Samples.Helpers;
2+
using NUnit.Framework;
3+
using OpenQA.Selenium;
4+
using OpenQA.Selenium.Appium;
5+
using OpenQA.Selenium.Appium.Android;
6+
using OpenQA.Selenium.Remote;
7+
using System;
8+
using System.Drawing;
9+
using System.Threading;
10+
11+
namespace Appium.Samples
12+
{
13+
[TestFixture()]
14+
class AndroidGestureTest
15+
{
16+
private AndroidDriver<AndroidElement> driver;
17+
private bool allPassed = true;
18+
19+
[SetUp]
20+
public void BeforeAll()
21+
{
22+
DesiredCapabilities capabilities = Env.isSauce() ?
23+
Caps.getAndroid18Caps(Apps.get("androidApiDemos")) :
24+
Caps.getAndroid19Caps(Apps.get("androidApiDemos"));
25+
if (Env.isSauce())
26+
{
27+
capabilities.SetCapability("username", Env.getEnvVar("SAUCE_USERNAME"));
28+
capabilities.SetCapability("accessKey", Env.getEnvVar("SAUCE_ACCESS_KEY"));
29+
capabilities.SetCapability("name", "android - complex");
30+
capabilities.SetCapability("tags", new string[] { "sample" });
31+
}
32+
Uri serverUri = Env.isSauce() ? AppiumServers.sauceURI : AppiumServers.localURI;
33+
driver = new AndroidDriver<AndroidElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC);
34+
driver.Manage().Timeouts().ImplicitlyWait(Env.IMPLICIT_TIMEOUT_SEC);
35+
}
36+
37+
[TearDown]
38+
public void AfterEach()
39+
{
40+
allPassed = allPassed && (TestContext.CurrentContext.Result.State == TestState.Success);
41+
if (Env.isSauce())
42+
((IJavaScriptExecutor)driver).ExecuteScript("sauce:job-result=" + (allPassed ? "passed" : "failed"));
43+
driver.Quit();
44+
}
45+
46+
[Test()]
47+
public void scrollAndSwipeTest()
48+
{
49+
driver.FindElementByName("Graphics").Click();
50+
driver.ScrollTo("FingerPaint", "android:id/list");
51+
driver.FindElementByName("FingerPaint").Click();
52+
AndroidElement element = driver.FindElementById("android:id/content");
53+
Point point = element.Coordinates.LocationInDom;
54+
Size size = element.Size;
55+
driver.Swipe
56+
(
57+
point.X + 5,
58+
point.Y + 5,
59+
point.X + size.Width - 5,
60+
point.Y + size.Height - 5,
61+
200
62+
);
63+
64+
driver.Swipe
65+
(
66+
point.X + size.Width - 5,
67+
point.Y + 5,
68+
point.X + 5,
69+
point.Y + size.Height - 5,
70+
2000
71+
);
72+
}
73+
74+
[Test()]
75+
public void pinchAndZoomTest()
76+
{
77+
driver.FindElementByName("Graphics").Click();
78+
driver.ScrollTo("OpenGL ES", "android:id/list").Click();
79+
//driver.FindElementByName("OpenGL ES").Click();
80+
driver.ScrollTo("Touch Rotate", "android:id/list").Click();
81+
//driver.FindElementByName("TouchRotate").Click();
82+
83+
AndroidElement element = driver.FindElementById("android:id/content");
84+
driver.Pinch(element);
85+
driver.Zoom(element);
86+
87+
Thread.Sleep(2000);
88+
}
89+
}
90+
}

sample-code/examples/dotnet/AppiumDotNetSample/AppiumDotNetSample.csproj

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@
2828
</PropertyGroup>
2929
<ItemGroup>
3030
<Reference Include="appium-dotnet-driver">
31-
<HintPath>..\packages\Appium.WebDriver.1.3.0.1\lib\net40\appium-dotnet-driver.dll</HintPath>
31+
<HintPath>..\packages\Appium.WebDriver.1.4.0.2\lib\net40\appium-dotnet-driver.dll</HintPath>
32+
<Private>True</Private>
33+
</Reference>
34+
<Reference Include="Castle.Core">
35+
<HintPath>..\packages\Castle.Core.3.3.3\lib\net40-client\Castle.Core.dll</HintPath>
36+
<Private>True</Private>
3237
</Reference>
3338
<Reference Include="Newtonsoft.Json">
34-
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
39+
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
40+
<Private>True</Private>
3541
</Reference>
3642
<Reference Include="System" />
3743
<Reference Include="nunit.framework">
@@ -40,15 +46,18 @@
4046
<Reference Include="System.Drawing" />
4147
<Reference Include="System.Web.Extensions" />
4248
<Reference Include="WebDriver">
43-
<HintPath>..\packages\Selenium.WebDriver.2.46.0\lib\net40\WebDriver.dll</HintPath>
49+
<HintPath>..\packages\Selenium.WebDriver.2.47.0\lib\net40\WebDriver.dll</HintPath>
50+
<Private>True</Private>
4451
</Reference>
4552
<Reference Include="WebDriver.Support">
46-
<HintPath>..\packages\Selenium.Support.2.46.0\lib\net40\WebDriver.Support.dll</HintPath>
53+
<HintPath>..\packages\Selenium.Support.2.47.0\lib\net40\WebDriver.Support.dll</HintPath>
54+
<Private>True</Private>
4755
</Reference>
4856
</ItemGroup>
4957
<ItemGroup>
5058
<Compile Include="AndroidComplexTest.cs" />
5159
<Compile Include="AndroidConnectionTest.cs" />
60+
<Compile Include="AndroidGestureTest.cs" />
5261
<Compile Include="AndroidLocalServerTest.cs" />
5362
<Compile Include="AndroidLocationTest.cs" />
5463
<Compile Include="AndroidOrientationTest.cs" />
@@ -63,15 +72,35 @@
6372
<Compile Include="helpers\LocalServer.cs" />
6473
<Compile Include="IosActionsTest.cs" />
6574
<Compile Include="IosComplexTest.cs" />
75+
<Compile Include="IosGestureTest.cs" />
6676
<Compile Include="IosLocalServerTest.cs" />
6777
<Compile Include="IOSLocationTest.cs" />
6878
<Compile Include="IosOrientationTest.cs" />
6979
<Compile Include="IosSimpleTest.cs" />
7080
<Compile Include="IosWebviewTest.cs" />
81+
<Compile Include="PageObjects\AndroidPageObjectChecksAttributeMixOnNativeApp1.cs" />
82+
<Compile Include="PageObjects\AndroidPageObjectChecksAttributeMixOnNativeApp2.cs" />
83+
<Compile Include="PageObjects\AndroidPageObjectChecksAttributesForNativeAndroidApp.cs" />
84+
<Compile Include="PageObjects\AndroidPageObjectChecksSelendroidModeOnNativeApp.cs" />
85+
<Compile Include="PageObjects\AndroidPageObjectChecksSeleniumFindsByCompatibility.cs" />
86+
<Compile Include="PageObjects\AndroidWebView.cs" />
87+
<Compile Include="PageObjects\IOSPageObjectChecksAttributeMixOnNativeApp.cs" />
88+
<Compile Include="PageObjects\IOSPageObjectChecksAttributesForNativeIOSApp.cs" />
89+
<Compile Include="PageObjectTests\Android\AndroidNativeAppAttributesTest.cs" />
90+
<Compile Include="PageObjectTests\Android\AndroidTestThatChecksAttributeMix1.cs" />
91+
<Compile Include="PageObjectTests\Android\AndroidTestThatChecksAttributeMix2.cs" />
92+
<Compile Include="PageObjectTests\Android\AndroidTestThatChecksAttributeMix3SelendroidMode.cs" />
93+
<Compile Include="PageObjectTests\Android\AndroidWebViewTest.cs" />
94+
<Compile Include="PageObjectTests\Android\SeleniumAttributesCompatipilityTest.cs" />
95+
<Compile Include="PageObjectTests\DesktopBrowserCompatibility\DesctopBrowserCompatibilityTest.cs" />
96+
<Compile Include="PageObjectTests\IOS\IOSNativeAppAttributesTest.cs" />
97+
<Compile Include="PageObjectTests\IOS\IOSTestThatChecksAttributeMix.cs" />
98+
<Compile Include="PageObjectTests\TimeOutManagement\TimeOutManagementTest.cs" />
7199
</ItemGroup>
72100
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
73101
<ItemGroup>
74102
<None Include="AppiumDotNetSample.csproj" />
75103
<None Include="packages.config" />
76104
</ItemGroup>
105+
<ItemGroup />
77106
</Project>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Appium.Samples.Helpers;
2+
using NUnit.Framework;
3+
using OpenQA.Selenium;
4+
using OpenQA.Selenium.Appium;
5+
using OpenQA.Selenium.Appium.iOS;
6+
using OpenQA.Selenium.Remote;
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Linq;
10+
using System.Text;
11+
12+
namespace Appium.Samples
13+
{
14+
[TestFixture()]
15+
class IosGestureTest
16+
{
17+
private AppiumDriver<IOSElement> driver;
18+
private bool allPassed = true;
19+
20+
[SetUp]
21+
public void BeforeAll()
22+
{
23+
DesiredCapabilities capabilities = Caps.getIos71Caps(Apps.get("iosUICatalogApp"));
24+
if (Env.isSauce())
25+
{
26+
capabilities.SetCapability("username", Env.getEnvVar("SAUCE_USERNAME"));
27+
capabilities.SetCapability("accessKey", Env.getEnvVar("SAUCE_ACCESS_KEY"));
28+
capabilities.SetCapability("name", "ios - complex");
29+
capabilities.SetCapability("tags", new string[] { "sample" });
30+
}
31+
Uri serverUri = Env.isSauce() ? AppiumServers.sauceURI : AppiumServers.localURI;
32+
driver = new IOSDriver<IOSElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC);
33+
driver.Manage().Timeouts().ImplicitlyWait(Env.IMPLICIT_TIMEOUT_SEC);
34+
}
35+
36+
[TearDown]
37+
public void AfterEach()
38+
{
39+
allPassed = allPassed && (TestContext.CurrentContext.Result.State == TestState.Success);
40+
if (Env.isSauce())
41+
((IJavaScriptExecutor)driver).ExecuteScript("sauce:job-result=" + (allPassed ? "passed" : "failed"));
42+
driver.Quit();
43+
}
44+
45+
[Test()]
46+
public void GestureTestCase()
47+
{
48+
IOSElement e = driver.FindElementByName("TextField1");
49+
driver.Tap(1, e, 2000);
50+
driver.Zoom(e);
51+
driver.Pinch(e);
52+
}
53+
}
54+
}
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
using Appium.Samples.Helpers;
2+
using Appium.Samples.PageObjects;
3+
using NUnit.Framework;
4+
using OpenQA.Selenium;
5+
using OpenQA.Selenium.Appium;
6+
using OpenQA.Selenium.Appium.Android;
7+
using OpenQA.Selenium.Appium.PageObjects;
8+
using OpenQA.Selenium.Remote;
9+
using OpenQA.Selenium.Support.PageObjects;
10+
using System;
11+
using System.Collections.Generic;
12+
using System.Linq;
13+
using System.Text;
14+
15+
namespace Appium.Samples.PageObjectTests.Android
16+
{
17+
[TestFixture()]
18+
public class AndroidNativeAppAttributesTest
19+
{
20+
private AndroidDriver<AppiumWebElement> driver;
21+
private bool allPassed = true;
22+
private AndroidPageObjectChecksAttributesForNativeAndroidApp pageObject;
23+
24+
[TestFixtureSetUp]
25+
public void BeforeAll()
26+
{
27+
DesiredCapabilities capabilities = Env.isSauce() ?
28+
Caps.getAndroid18Caps(Apps.get("androidApiDemos")) :
29+
Caps.getAndroid19Caps(Apps.get("androidApiDemos"));
30+
if (Env.isSauce())
31+
{
32+
capabilities.SetCapability("username", Env.getEnvVar("SAUCE_USERNAME"));
33+
capabilities.SetCapability("accessKey", Env.getEnvVar("SAUCE_ACCESS_KEY"));
34+
capabilities.SetCapability("name", "android - complex");
35+
capabilities.SetCapability("tags", new string[] { "sample" });
36+
}
37+
Uri serverUri = Env.isSauce() ? AppiumServers.sauceURI : AppiumServers.localURI;
38+
driver = new AndroidDriver<AppiumWebElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC);
39+
TimeOutDuration timeSpan = new TimeOutDuration(new TimeSpan(0, 0, 0, 5, 0));
40+
pageObject = new AndroidPageObjectChecksAttributesForNativeAndroidApp();
41+
PageFactory.InitElements(driver, pageObject, new AppiumPageObjectMemberDecorator(timeSpan));
42+
}
43+
44+
[TestFixtureTearDown]
45+
public void AfterEach()
46+
{
47+
allPassed = allPassed && (TestContext.CurrentContext.Result.State == TestState.Success);
48+
if (Env.isSauce())
49+
((IJavaScriptExecutor)driver).ExecuteScript("sauce:job-result=" + (allPassed ? "passed" : "failed"));
50+
driver.Quit();
51+
}
52+
53+
[Test()]
54+
public void CheckMobileElement()
55+
{
56+
Assert.NotNull(pageObject.GetMobileElementText());
57+
}
58+
59+
[Test()]
60+
public void CheckMobileElements()
61+
{
62+
Assert.GreaterOrEqual(pageObject.GetMobileElementSize(), 1);
63+
}
64+
65+
[Test()]
66+
public void CheckMobileElementProperty()
67+
{
68+
Assert.NotNull(pageObject.GetMobileElementPropertyText());
69+
}
70+
71+
[Test()]
72+
public void CheckMobileElementsProperty()
73+
{
74+
Assert.GreaterOrEqual(pageObject.GetMobileElementPropertySize(), 1);
75+
}
76+
77+
[Test()]
78+
public void CheckElementFoundUsingMultipleLocators()
79+
{
80+
Assert.NotNull(pageObject.GetMultipleFindByElementText());
81+
}
82+
83+
[Test()]
84+
public void CheckElementsFoundUsingMultipleLocators()
85+
{
86+
Assert.GreaterOrEqual(pageObject.GetMultipleFindByElementSize(), 10);
87+
Assert.LessOrEqual(pageObject.GetMultipleFindByElementSize(), 14);
88+
}
89+
90+
[Test()]
91+
public void CheckElementFoundUsingMultipleLocatorsProperty()
92+
{
93+
Assert.NotNull(pageObject.GetMultipleFindByElementPropertyText());
94+
}
95+
96+
[Test()]
97+
public void CheckElementsFoundUsingMultipleLocatorssProperty()
98+
{
99+
Assert.GreaterOrEqual(pageObject.GetMultipleFindByElementPropertySize(), 10);
100+
Assert.LessOrEqual(pageObject.GetMultipleFindByElementSize(), 14);
101+
}
102+
103+
[Test()]
104+
public void CheckElementFoundByChainedSearch()
105+
{
106+
Assert.NotNull(pageObject.GetFoundByChainedSearchElementText());
107+
}
108+
109+
[Test()]
110+
public void CheckElementsFoundByChainedSearch()
111+
{
112+
Assert.GreaterOrEqual(pageObject.GetFoundByChainedSearchElementSize(), 10);
113+
Assert.LessOrEqual(pageObject.GetMultipleFindByElementSize(), 14);
114+
}
115+
116+
[Test()]
117+
public void CheckFoundByChainedSearchElementProperty()
118+
{
119+
Assert.NotNull(pageObject.GetFoundByChainedSearchElementPropertyText());
120+
}
121+
122+
[Test()]
123+
public void CheckFoundByChainedSearchElementsProperty()
124+
{
125+
Assert.GreaterOrEqual(pageObject.GetFoundByChainedSearchElementPropertySize(), 10);
126+
Assert.LessOrEqual(pageObject.GetMultipleFindByElementSize(), 14);
127+
}
128+
129+
[Test()]
130+
public void CheckElementMatchedToAll()
131+
{
132+
Assert.NotNull(pageObject.GetMatchedToAllLocatorsElementText());
133+
}
134+
135+
[Test()]
136+
public void CheckElementsMatchedToAll()
137+
{
138+
Assert.GreaterOrEqual(pageObject.GetMatchedToAllLocatorsElementSize(), 1);
139+
Assert.LessOrEqual(pageObject.GetMatchedToAllLocatorsElementSize(), 13);
140+
}
141+
142+
[Test()]
143+
public void CheckElementMatchedToAllProperty()
144+
{
145+
Assert.NotNull(pageObject.GetMatchedToAllLocatorsElementPropertyText());
146+
}
147+
148+
[Test()]
149+
public void CheckElementMatchedToAllElementsProperty()
150+
{
151+
Assert.GreaterOrEqual(pageObject.GetMatchedToAllLocatorsElementPropertySize(), 1);
152+
Assert.LessOrEqual(pageObject.GetMatchedToAllLocatorsElementPropertySize(), 13);
153+
}
154+
}
155+
}

0 commit comments

Comments
 (0)