Skip to content

Commit

Permalink
.Net sample was updated to release 1.4.0.2
Browse files Browse the repository at this point in the history
Now it shows capabilities of the latest stable release.
  • Loading branch information
TikhomirovSergey committed Aug 12, 2015
1 parent 1c44567 commit 9581563
Show file tree
Hide file tree
Showing 24 changed files with 3,285 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
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.Drawing;
using System.Threading;

namespace Appium.Samples
{
[TestFixture()]
class AndroidGestureTest
{
private AndroidDriver<AndroidElement> driver;
private bool allPassed = true;

[SetUp]
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<AndroidElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC);
driver.Manage().Timeouts().ImplicitlyWait(Env.IMPLICIT_TIMEOUT_SEC);
}

[TearDown]
public void AfterEach()
{
allPassed = allPassed && (TestContext.CurrentContext.Result.State == TestState.Success);
if (Env.isSauce())
((IJavaScriptExecutor)driver).ExecuteScript("sauce:job-result=" + (allPassed ? "passed" : "failed"));
driver.Quit();
}

[Test()]
public void scrollAndSwipeTest()
{
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
);
}

[Test()]
public void pinchAndZoomTest()
{
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 element = driver.FindElementById("android:id/content");
driver.Pinch(element);
driver.Zoom(element);

Thread.Sleep(2000);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="appium-dotnet-driver">
<HintPath>..\packages\Appium.WebDriver.1.3.0.1\lib\net40\appium-dotnet-driver.dll</HintPath>
<HintPath>..\packages\Appium.WebDriver.1.4.0.2\lib\net40\appium-dotnet-driver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Castle.Core">
<HintPath>..\packages\Castle.Core.3.3.3\lib\net40-client\Castle.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="nunit.framework">
Expand All @@ -40,15 +46,18 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Web.Extensions" />
<Reference Include="WebDriver">
<HintPath>..\packages\Selenium.WebDriver.2.46.0\lib\net40\WebDriver.dll</HintPath>
<HintPath>..\packages\Selenium.WebDriver.2.47.0\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WebDriver.Support">
<HintPath>..\packages\Selenium.Support.2.46.0\lib\net40\WebDriver.Support.dll</HintPath>
<HintPath>..\packages\Selenium.Support.2.47.0\lib\net40\WebDriver.Support.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AndroidComplexTest.cs" />
<Compile Include="AndroidConnectionTest.cs" />
<Compile Include="AndroidGestureTest.cs" />
<Compile Include="AndroidLocalServerTest.cs" />
<Compile Include="AndroidLocationTest.cs" />
<Compile Include="AndroidOrientationTest.cs" />
Expand All @@ -63,15 +72,35 @@
<Compile Include="helpers\LocalServer.cs" />
<Compile Include="IosActionsTest.cs" />
<Compile Include="IosComplexTest.cs" />
<Compile Include="IosGestureTest.cs" />
<Compile Include="IosLocalServerTest.cs" />
<Compile Include="IOSLocationTest.cs" />
<Compile Include="IosOrientationTest.cs" />
<Compile Include="IosSimpleTest.cs" />
<Compile Include="IosWebviewTest.cs" />
<Compile Include="PageObjects\AndroidPageObjectChecksAttributeMixOnNativeApp1.cs" />
<Compile Include="PageObjects\AndroidPageObjectChecksAttributeMixOnNativeApp2.cs" />
<Compile Include="PageObjects\AndroidPageObjectChecksAttributesForNativeAndroidApp.cs" />
<Compile Include="PageObjects\AndroidPageObjectChecksSelendroidModeOnNativeApp.cs" />
<Compile Include="PageObjects\AndroidPageObjectChecksSeleniumFindsByCompatibility.cs" />
<Compile Include="PageObjects\AndroidWebView.cs" />
<Compile Include="PageObjects\IOSPageObjectChecksAttributeMixOnNativeApp.cs" />
<Compile Include="PageObjects\IOSPageObjectChecksAttributesForNativeIOSApp.cs" />
<Compile Include="PageObjectTests\Android\AndroidNativeAppAttributesTest.cs" />
<Compile Include="PageObjectTests\Android\AndroidTestThatChecksAttributeMix1.cs" />
<Compile Include="PageObjectTests\Android\AndroidTestThatChecksAttributeMix2.cs" />
<Compile Include="PageObjectTests\Android\AndroidTestThatChecksAttributeMix3SelendroidMode.cs" />
<Compile Include="PageObjectTests\Android\AndroidWebViewTest.cs" />
<Compile Include="PageObjectTests\Android\SeleniumAttributesCompatipilityTest.cs" />
<Compile Include="PageObjectTests\DesktopBrowserCompatibility\DesctopBrowserCompatibilityTest.cs" />
<Compile Include="PageObjectTests\IOS\IOSNativeAppAttributesTest.cs" />
<Compile Include="PageObjectTests\IOS\IOSTestThatChecksAttributeMix.cs" />
<Compile Include="PageObjectTests\TimeOutManagement\TimeOutManagementTest.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<None Include="AppiumDotNetSample.csproj" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
</Project>
54 changes: 54 additions & 0 deletions sample-code/examples/dotnet/AppiumDotNetSample/IosGestureTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Appium.Samples.Helpers;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.iOS;
using OpenQA.Selenium.Remote;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Appium.Samples
{
[TestFixture()]
class IosGestureTest
{
private AppiumDriver<IOSElement> driver;
private bool allPassed = true;

[SetUp]
public void BeforeAll()
{
DesiredCapabilities capabilities = Caps.getIos71Caps(Apps.get("iosUICatalogApp"));
if (Env.isSauce())
{
capabilities.SetCapability("username", Env.getEnvVar("SAUCE_USERNAME"));
capabilities.SetCapability("accessKey", Env.getEnvVar("SAUCE_ACCESS_KEY"));
capabilities.SetCapability("name", "ios - complex");
capabilities.SetCapability("tags", new string[] { "sample" });
}
Uri serverUri = Env.isSauce() ? AppiumServers.sauceURI : AppiumServers.localURI;
driver = new IOSDriver<IOSElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC);
driver.Manage().Timeouts().ImplicitlyWait(Env.IMPLICIT_TIMEOUT_SEC);
}

[TearDown]
public void AfterEach()
{
allPassed = allPassed && (TestContext.CurrentContext.Result.State == TestState.Success);
if (Env.isSauce())
((IJavaScriptExecutor)driver).ExecuteScript("sauce:job-result=" + (allPassed ? "passed" : "failed"));
driver.Quit();
}

[Test()]
public void GestureTestCase()
{
IOSElement e = driver.FindElementByName("TextField1");
driver.Tap(1, e, 2000);
driver.Zoom(e);
driver.Pinch(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
using Appium.Samples.Helpers;
using Appium.Samples.PageObjects;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Appium.PageObjects;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.PageObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Appium.Samples.PageObjectTests.Android
{
[TestFixture()]
public class AndroidNativeAppAttributesTest
{
private AndroidDriver<AppiumWebElement> driver;
private bool allPassed = true;
private AndroidPageObjectChecksAttributesForNativeAndroidApp pageObject;

[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<AppiumWebElement>(serverUri, capabilities, Env.INIT_TIMEOUT_SEC);
TimeOutDuration timeSpan = new TimeOutDuration(new TimeSpan(0, 0, 0, 5, 0));
pageObject = new AndroidPageObjectChecksAttributesForNativeAndroidApp();
PageFactory.InitElements(driver, pageObject, new AppiumPageObjectMemberDecorator(timeSpan));
}

[TestFixtureTearDown]
public void AfterEach()
{
allPassed = allPassed && (TestContext.CurrentContext.Result.State == TestState.Success);
if (Env.isSauce())
((IJavaScriptExecutor)driver).ExecuteScript("sauce:job-result=" + (allPassed ? "passed" : "failed"));
driver.Quit();
}

[Test()]
public void CheckMobileElement()
{
Assert.NotNull(pageObject.GetMobileElementText());
}

[Test()]
public void CheckMobileElements()
{
Assert.GreaterOrEqual(pageObject.GetMobileElementSize(), 1);
}

[Test()]
public void CheckMobileElementProperty()
{
Assert.NotNull(pageObject.GetMobileElementPropertyText());
}

[Test()]
public void CheckMobileElementsProperty()
{
Assert.GreaterOrEqual(pageObject.GetMobileElementPropertySize(), 1);
}

[Test()]
public void CheckElementFoundUsingMultipleLocators()
{
Assert.NotNull(pageObject.GetMultipleFindByElementText());
}

[Test()]
public void CheckElementsFoundUsingMultipleLocators()
{
Assert.GreaterOrEqual(pageObject.GetMultipleFindByElementSize(), 10);
Assert.LessOrEqual(pageObject.GetMultipleFindByElementSize(), 14);
}

[Test()]
public void CheckElementFoundUsingMultipleLocatorsProperty()
{
Assert.NotNull(pageObject.GetMultipleFindByElementPropertyText());
}

[Test()]
public void CheckElementsFoundUsingMultipleLocatorssProperty()
{
Assert.GreaterOrEqual(pageObject.GetMultipleFindByElementPropertySize(), 10);
Assert.LessOrEqual(pageObject.GetMultipleFindByElementSize(), 14);
}

[Test()]
public void CheckElementFoundByChainedSearch()
{
Assert.NotNull(pageObject.GetFoundByChainedSearchElementText());
}

[Test()]
public void CheckElementsFoundByChainedSearch()
{
Assert.GreaterOrEqual(pageObject.GetFoundByChainedSearchElementSize(), 10);
Assert.LessOrEqual(pageObject.GetMultipleFindByElementSize(), 14);
}

[Test()]
public void CheckFoundByChainedSearchElementProperty()
{
Assert.NotNull(pageObject.GetFoundByChainedSearchElementPropertyText());
}

[Test()]
public void CheckFoundByChainedSearchElementsProperty()
{
Assert.GreaterOrEqual(pageObject.GetFoundByChainedSearchElementPropertySize(), 10);
Assert.LessOrEqual(pageObject.GetMultipleFindByElementSize(), 14);
}

[Test()]
public void CheckElementMatchedToAll()
{
Assert.NotNull(pageObject.GetMatchedToAllLocatorsElementText());
}

[Test()]
public void CheckElementsMatchedToAll()
{
Assert.GreaterOrEqual(pageObject.GetMatchedToAllLocatorsElementSize(), 1);
Assert.LessOrEqual(pageObject.GetMatchedToAllLocatorsElementSize(), 13);
}

[Test()]
public void CheckElementMatchedToAllProperty()
{
Assert.NotNull(pageObject.GetMatchedToAllLocatorsElementPropertyText());
}

[Test()]
public void CheckElementMatchedToAllElementsProperty()
{
Assert.GreaterOrEqual(pageObject.GetMatchedToAllLocatorsElementPropertySize(), 1);
Assert.LessOrEqual(pageObject.GetMatchedToAllLocatorsElementPropertySize(), 13);
}
}
}
Loading

0 comments on commit 9581563

Please sign in to comment.