Skip to content

Commit 07c4d7b

Browse files
KazuCocoaCopilot
andauthored
chore: add bidi test with newser selenium webdriver dependency (#955)
* test: add bidi test * use newer webdriver deps * simplify the test code * Update Appium.Net.csproj * add redundant spaces to reduce diff * Use newer selenium webdriver * Use Task.Delay Co-authored-by: Copilot <[email protected]> * Use ? Co-authored-by: Copilot <[email protected]> * Update BiDiTests.cs * add try/catch to ignore exceptions here --------- Co-authored-by: Copilot <[email protected]>
1 parent 4e7ac27 commit 07c4d7b

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

src/Appium.Net/Appium.Net.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<PrivateAssets>all</PrivateAssets>
4444
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4545
</PackageReference>
46-
<PackageReference Include="Selenium.WebDriver" Version="4.32.0" />
46+
<PackageReference Include="Selenium.WebDriver" Version="4.35.0" />
4747
<PackageReference Include="System.Drawing.Common" Version="8.0.10" />
4848
</ItemGroup>
4949
</Project>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using Appium.Net.Integration.Tests.helpers;
2+
using NUnit.Framework;
3+
using OpenQA.Selenium.Appium.Android;
4+
using OpenQA.Selenium.BiDi;
5+
using System.Threading.Tasks;
6+
7+
namespace Appium.Net.Integration.Tests.Android
8+
{
9+
public class BiDiTests
10+
{
11+
private AndroidDriver _driver;
12+
13+
private BiDi _bidi;
14+
15+
[OneTimeSetUp]
16+
public void BeforeAll()
17+
{
18+
var capabilities = Caps.GetAndroidUIAutomatorCaps();
19+
capabilities.UseWebSocketUrl = true;
20+
var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri;
21+
_driver = new AndroidDriver(serverUri, capabilities, Env.InitTimeoutSec);
22+
}
23+
24+
[Test]
25+
public async Task RunBiDiScript()
26+
{
27+
_bidi = await _driver.AsBiDiAsync();
28+
await _bidi.StatusAsync();
29+
}
30+
31+
[OneTimeTearDown]
32+
public async Task AfterAll()
33+
{
34+
if (_bidi != null)
35+
{
36+
try
37+
{
38+
await _bidi.DisposeAsync();
39+
}
40+
catch { };
41+
}
42+
_driver?.Quit();
43+
if (!Env.ServerIsRemote())
44+
{
45+
AppiumServers.StopLocalService();
46+
}
47+
}
48+
}
49+
}

test/integration/helpers/Caps.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ public static AppiumOptions GetAndroidUIAutomatorCaps(string app)
2626
return capabilities;
2727
}
2828

29+
public static AppiumOptions GetAndroidUIAutomatorCaps()
30+
{
31+
var capabilities = new AppiumOptions();
32+
capabilities.AutomationName = AutomationName.AndroidUIAutomator2;
33+
capabilities.DeviceName = "Android Emulator";
34+
return capabilities;
35+
}
36+
2937
public static AppiumOptions GetAndroidEspressoCaps(string app)
3038
{
3139
var capabilities = new AppiumOptions();

0 commit comments

Comments
 (0)