-
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.
Include Asynchronous Server Socket and RestSharp.api
- Loading branch information
Showing
42 changed files
with
1,887 additions
and
2 deletions.
There are no files selected for viewing
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
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,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
|
||
<OutputType>WinExe</OutputType> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Appium.WebDriver" Version="4.4.5" /> | ||
<PackageReference Include="Microsoft.NETCore.Platforms" Version="6.0.13" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | ||
<PackageReference Include="nunit" Version="3.12.0" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,124 @@ | ||
using NUnit.Framework; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Appium; | ||
using OpenQA.Selenium.Appium.Android; | ||
using OpenQA.Selenium.Appium.Enums; | ||
using OpenQA.Selenium.Remote; | ||
using OpenQA.Selenium.Support.UI; | ||
using System; | ||
|
||
namespace AppiumTest | ||
{ | ||
public class TestRemote | ||
{ | ||
private AndroidDriver<AndroidElement> _driver; | ||
private AndroidElement WE; | ||
private static String XID = "//android.widget."; | ||
private static String PID = "com.soonr.apps.go.production:id/"; | ||
private static String AID = "android:id/"; | ||
public By getBy(String txt) | ||
{ | ||
if (txt.StartsWith("//")) return By.XPath(txt); | ||
By by = By.XPath(XID + txt); // default xpath | ||
if (txt.StartsWith("#")) return By.Id(PID + txt.Substring(1)); | ||
if (txt.StartsWith("$")) return By.Id(AID + txt.Substring(1)); | ||
if (txt.StartsWith("@")) return By.XPath(XID + "TextView[@text='" + txt.Substring(1) + "']"); //@Projects | ||
if (txt.StartsWith("&")) | ||
{ | ||
if (txt.Equals("&+")) return By.Id(PID + "fab_button"); | ||
if (txt.Equals("&UP")) return By.XPath(XID + "ImageButton[@content-desc='Navigate up']"); | ||
if (txt.Equals("&Allow")) return By.Id("com.android.permissioncontroller:id/permission_allow_button"); | ||
if (txt.Equals("&Strike")) return By.XPath(XID + "ImageButton[@content-desc='Strike Out']"); | ||
} | ||
|
||
return by; | ||
} | ||
public Boolean wait4(String txt, int n) | ||
{ | ||
try | ||
{ | ||
WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(n)); | ||
wait.Until(ExpectedConditions.ElementIsVisible(getBy(txt))); | ||
Check warning on line 41 in Solution/AppiumTest/Remote.cs GitHub Actions / Build_and_Test
|
||
return true; | ||
} | ||
catch (Exception t) | ||
{ | ||
Console.WriteLine("can not find element " + txt); | ||
return false; | ||
} | ||
} | ||
public Boolean has(String txt) | ||
{ | ||
try | ||
{ | ||
WE = _driver.FindElement(getBy(txt)); | ||
return WE != null; | ||
} | ||
catch (Exception t) | ||
{ | ||
return false; | ||
} | ||
} | ||
public String getList() | ||
{ | ||
//return text under id:list | ||
System.Threading.Thread.Sleep(2000); | ||
if (!has("$list")) return ""; | ||
String list = ""; | ||
if (has("#emptyText")) return WE.GetAttribute("text"); | ||
if (wait4("#label",10)) | ||
{ | ||
foreach (AndroidElement w in _driver.FindElements(getBy("#label"))) | ||
{ | ||
String name = w.GetAttribute("text"); | ||
if (list.Length==0) list = name; | ||
else list = list + ":" + name; | ||
} | ||
} | ||
Console.WriteLine(list); | ||
return list; | ||
} | ||
[OneTimeSetUp] | ||
public void SetUp() | ||
{ | ||
//using Appium on remote machine | ||
var serverUri = new Uri("http://uk.35cloud.com:4723/wd/hub"); | ||
var driverOptions = new AppiumOptions(); | ||
driverOptions.AddAdditionalCapability("platformName", "Android"); | ||
driverOptions.AddAdditionalCapability("automationName", "UIAutomator2"); | ||
driverOptions.AddAdditionalCapability("udid", "emulator-5554"); | ||
driverOptions.AddAdditionalCapability("deviceName", "PXL"); | ||
driverOptions.AddAdditionalCapability("platformVersion", "10"); | ||
driverOptions.AddAdditionalCapability("app", "C:\\Auto\\a\\VFSx.apk"); | ||
driverOptions.AddAdditionalCapability("appPackage", "com.soonr.apps.go.production"); | ||
driverOptions.AddAdditionalCapability("appActivity", "com.soonr.apps.workplace.ui.HomeActivity"); | ||
// app-option | ||
driverOptions.AddAdditionalCapability("noReset", true); | ||
driverOptions.AddAdditionalCapability("skipDeviceInitialization", true); | ||
driverOptions.AddAdditionalCapability("kipServerInstallation", true); | ||
|
||
_driver = new AndroidDriver<AndroidElement>(serverUri, driverOptions, TimeSpan.FromSeconds(180)); | ||
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); | ||
} | ||
|
||
[OneTimeTearDown] | ||
public void TearDown() | ||
{ | ||
_driver.Dispose(); | ||
_driver.Quit(); | ||
} | ||
|
||
[Test] | ||
public void TestView1() | ||
{ | ||
|
||
System.Threading.Thread.Sleep(5000); | ||
Console.WriteLine("has[0000]=" + has("@0000")); | ||
getList(); | ||
if(has("@0000")) WE.Click(); | ||
//if (has("@scribble.pdfauto.pdf")) WE.Click(); | ||
System.Threading.Thread.Sleep(5000); | ||
|
||
} | ||
} | ||
} |
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,133 @@ | ||
using NUnit.Framework; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Appium; | ||
using OpenQA.Selenium.Appium.Android; | ||
using OpenQA.Selenium.Appium.Enums; | ||
using OpenQA.Selenium.Remote; | ||
using OpenQA.Selenium.Support.UI; | ||
using System; | ||
|
||
namespace AppiumTest | ||
{ | ||
public class TestRemote2x | ||
{ | ||
/* Target Appium 2.x version without Workplace app setup. | ||
* URI: http://uk.35cloud.com:4723/wd/hub | ||
* | ||
*/ | ||
private AndroidDriver<AndroidElement> _driver; | ||
private AndroidElement WE; | ||
private static String XID = "//android.widget."; | ||
private static String PID = "com.soonr.apps.go.production:id/"; | ||
private static String AID = "android:id/"; | ||
public By getBy(String txt) | ||
{ | ||
if (txt.StartsWith("//")) return By.XPath(txt); | ||
By by = By.XPath(XID + txt); // default xpath | ||
if (txt.StartsWith("#")) return By.Id(PID + txt.Substring(1)); | ||
if (txt.StartsWith("$")) return By.Id(AID + txt.Substring(1)); | ||
if (txt.StartsWith("@")) return By.XPath(XID + "TextView[@text='" + txt.Substring(1) + "']"); //@Projects | ||
if (txt.StartsWith("&")) | ||
{ | ||
if (txt.Equals("&+")) return By.Id(PID + "fab_button"); | ||
if (txt.Equals("&UP")) return By.XPath(XID + "ImageButton[@content-desc='Navigate up']"); | ||
if (txt.Equals("&Allow")) return By.Id("com.android.permissioncontroller:id/permission_allow_button"); | ||
if (txt.Equals("&Strike")) return By.XPath(XID + "ImageButton[@content-desc='Strike Out']"); | ||
} | ||
|
||
return by; | ||
} | ||
public Boolean wait4(String txt, int n) | ||
{ | ||
try | ||
{ | ||
WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(n)); | ||
wait.Until(ExpectedConditions.ElementIsVisible(getBy(txt))); | ||
return true; | ||
} | ||
catch (Exception t) | ||
{ | ||
Console.WriteLine("can not find element " + txt); | ||
return false; | ||
} | ||
} | ||
public Boolean has(String txt) | ||
{ | ||
try | ||
{ | ||
WE = _driver.FindElement(getBy(txt)); | ||
return WE != null; | ||
} | ||
catch (Exception t) | ||
{ | ||
return false; | ||
} | ||
} | ||
public String getList() | ||
{ | ||
//return text under id:list | ||
System.Threading.Thread.Sleep(2000); | ||
if (!has("$list")) return ""; | ||
String list = ""; | ||
if (has("#emptyText")) return WE.GetAttribute("text"); | ||
if (wait4("#label",10)) | ||
{ | ||
foreach (AndroidElement w in _driver.FindElements(getBy("#label"))) | ||
{ | ||
String name = w.GetAttribute("text"); | ||
if (list.Length==0) list = name; | ||
else list = list + ":" + name; | ||
} | ||
} | ||
Console.WriteLine(list); | ||
return list; | ||
} | ||
[OneTimeSetUp] | ||
public void SetUp() | ||
{ | ||
//using Appium on remote machine | ||
var serverUri = new Uri("http://localhost:4723"); | ||
var driverOptions = new AppiumOptions(); | ||
driverOptions.AddAdditionalCapability("platformName", "Android");//newCommandTimeout | ||
driverOptions.AddAdditionalCapability("appium:automationName", "UIAutomator2"); | ||
driverOptions.AddAdditionalCapability("appium:newCommandTimeout", 600); | ||
driverOptions.AddAdditionalCapability("appium:udid", "emulator-5554"); | ||
driverOptions.AddAdditionalCapability("appium:deviceName", "PXL"); | ||
driverOptions.AddAdditionalCapability("appium:platformVersion", "10"); | ||
driverOptions.AddAdditionalCapability("appium:app", "C:\\Auto\\a\\VFSx.apk"); | ||
driverOptions.AddAdditionalCapability("appium:appPackage", "com.soonr.apps.go.production"); | ||
driverOptions.AddAdditionalCapability("appium:appActivity", "com.soonr.apps.workplace.ui.HomeActivity"); | ||
// app-option | ||
driverOptions.AddAdditionalCapability("appium:noReset", true); | ||
driverOptions.AddAdditionalCapability("appium:skipDeviceInitialization", true); | ||
driverOptions.AddAdditionalCapability("appium:kipServerInstallation", true); | ||
|
||
_driver = new AndroidDriver<AndroidElement>(serverUri, driverOptions, TimeSpan.FromSeconds(180)); | ||
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); | ||
} | ||
|
||
[OneTimeTearDown] | ||
public void TearDown() | ||
{ | ||
_driver.Dispose(); | ||
_driver.Quit(); | ||
} | ||
|
||
[Test] | ||
public void TestView2() | ||
{ | ||
//_driver.StartActivity("com.soonr.apps.go.production", "com.soonr.apps.workplace.ui.HomeActivity"); | ||
System.Threading.Thread.Sleep(2000); | ||
Console.WriteLine("has[newproject]=" + has("@newproject")); | ||
if(has("@0000")) WE.Click(); | ||
if (has("@scribble.pdfauto.pdf")) WE.Click(); | ||
System.Threading.Thread.Sleep(2000); | ||
if(has("&UP")) WE.Click(); | ||
System.Threading.Thread.Sleep(1000); | ||
if (has("&UP")) WE.Click(); | ||
getList(); | ||
Console.WriteLine("done"); | ||
|
||
} | ||
} | ||
} |
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,37 @@ | ||
using NUnit.Framework; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Chrome; | ||
using System; | ||
|
||
namespace SeleniumTest | ||
{ | ||
[TestFixture] | ||
public class BasicTests | ||
{ | ||
private IWebDriver driver; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
// Initialize ChromeDriver | ||
driver = new ChromeDriver(@"C:\AutoTest\res"); | ||
Check failure on line 17 in Solution/AppiumTest/SeleniumChrome.cs GitHub Actions / Test ReportSeleniumTest.BasicTests ► TestGoogleHomePageTitle
Raw output
|
||
} | ||
|
||
[Test] | ||
public void TestGoogleHomePageTitle() | ||
{ | ||
// Navigate to Google | ||
driver.Navigate().GoToUrl("https://www.google.com"); | ||
|
||
// Assert the title | ||
Assert.AreEqual("Google", driver.Title, "The title of the page is not as expected."); | ||
} | ||
|
||
[TearDown] | ||
public void TearDown() | ||
{ | ||
// Close the browser | ||
driver.Quit(); | ||
} | ||
} | ||
} |
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,48 @@ | ||
using NUnit.Framework; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Appium; | ||
using OpenQA.Selenium.Appium.Android; | ||
using OpenQA.Selenium.Appium.Enums; | ||
using OpenQA.Selenium.Remote; | ||
using System; | ||
|
||
namespace AppiumTest | ||
{ | ||
public class Test2xBattery | ||
{ | ||
private AndroidDriver<AndroidElement> _driver; | ||
|
||
[OneTimeSetUp] | ||
public void SetUp() | ||
{ | ||
//var serverUri = new Uri(Environment.GetEnvironmentVariable("APPIUM_HOST") ?? "http://127.0.0.1:4723/"); | ||
var serverUri = new Uri("http://127.0.0.1:4723/"); | ||
var driverOptions = new AppiumOptions(); | ||
driverOptions.AddAdditionalCapability("platformName", "Android"); | ||
driverOptions.AddAdditionalCapability("appium:automationName", "UIAutomator2"); | ||
driverOptions.AddAdditionalCapability("appium:udid", "emulator-5554"); | ||
driverOptions.AddAdditionalCapability("appium:platformVersion", "11"); | ||
driverOptions.AddAdditionalCapability("appium:appPackage", "com.android.settings"); | ||
driverOptions.AddAdditionalCapability("appium:appActivity", ".Settings"); | ||
// NoReset assumes the app com.google.android is preinstalled on the emulator | ||
driverOptions.AddAdditionalCapability("appium:noReset", true); | ||
|
||
_driver = new AndroidDriver<AndroidElement>(serverUri, driverOptions, TimeSpan.FromSeconds(180)); | ||
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); | ||
} | ||
|
||
[OneTimeTearDown] | ||
public void TearDown() | ||
{ | ||
_driver.Dispose(); | ||
_driver.Quit(); | ||
} | ||
|
||
[Test] | ||
public void TestBattery() | ||
{ | ||
_driver.StartActivity("com.android.settings", ".Settings"); | ||
_driver.FindElement(By.XPath("//*[@text='Battery']")).Click(); | ||
} | ||
} | ||
} |
Oops, something went wrong.