forked from JasmineChiu/sample-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.Net sample was updated to release 1.4.0.2
Now it shows capabilities of the latest stable release.
- Loading branch information
1 parent
1c44567
commit 9581563
Showing
24 changed files
with
3,285 additions
and
9 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
sample-code/examples/dotnet/AppiumDotNetSample/AndroidGestureTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
sample-code/examples/dotnet/AppiumDotNetSample/IosGestureTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
155 changes: 155 additions & 0 deletions
155
...mples/dotnet/AppiumDotNetSample/PageObjectTests/Android/AndroidNativeAppAttributesTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.