1
- using Appium . Net . Integration . Tests . helpers ;
1
+ using System ;
2
+ using Appium . Net . Integration . Tests . helpers ;
2
3
using NUnit . Framework ;
3
4
using OpenQA . Selenium ;
4
5
using OpenQA . Selenium . Appium ;
5
6
using OpenQA . Selenium . Appium . iOS ;
7
+ using OpenQA . Selenium . Support . UI ;
6
8
7
9
namespace Appium . Net . Integration . Tests . IOS
8
10
{
9
- class ElementTest
11
+ class ElementTests
10
12
{
11
13
private AppiumDriver _driver ;
14
+ private WebDriverWait _driverWait ;
12
15
13
16
[ OneTimeSetUp ]
14
17
public void BeforeAll ( )
@@ -17,6 +20,7 @@ public void BeforeAll()
17
20
var serverUri = Env . ServerIsRemote ( ) ? AppiumServers . RemoteServerUri : AppiumServers . LocalServiceUri ;
18
21
_driver = new IOSDriver ( serverUri , capabilities , Env . InitTimeoutSec ) ;
19
22
_driver . Manage ( ) . Timeouts ( ) . ImplicitWait = Env . ImplicitTimeoutSec ;
23
+ _driverWait = new WebDriverWait ( _driver , TimeSpan . FromSeconds ( 5 ) ) ;
20
24
}
21
25
22
26
[ OneTimeTearDown ]
@@ -35,20 +39,29 @@ public void FindByAccessibilityIdTest()
35
39
By byAccessibilityId = new ByAccessibilityId ( "ComputeSumButton" ) ;
36
40
Assert . Multiple ( ( ) =>
37
41
{
38
- Assert . That ( Is . Not . EqualTo ( _driver . FindElements ( MobileBy . ClassName ( "UIAWindow" ) ) [ 1 ] . FindElement ( byAccessibilityId ) . Text ) , null ) ;
39
- Assert . That ( _driver . FindElements ( MobileBy . ClassName ( "UIAWindow" ) ) [ 1 ] . FindElements ( byAccessibilityId ) , Is . Not . Empty ) ;
42
+ Assert . That ( _driver . FindElement ( MobileBy . ClassName ( "UIAWindow" ) ) . FindElement ( byAccessibilityId ) . Text , Is . EqualTo ( "Compute Sum" ) ) ;
43
+ Assert . That ( _driver . FindElement ( MobileBy . ClassName ( "UIAWindow" ) ) . FindElements ( byAccessibilityId ) , Is . Not . Empty ) ;
40
44
} ) ;
41
45
}
42
46
43
47
[ Test ]
44
- public void FindByByIosUiAutomationTest ( )
48
+ public void FindElementsByClassNameTest ( )
45
49
{
46
- By byIosUiAutomation = new ByIosUIAutomation ( ".elements().withName(\" Answer\" )" ) ;
47
- Assert . Multiple ( ( ) =>
50
+ By byClassName = new ByClassName ( "XCUIElementTypeTextField" ) ;
51
+ Assert . That ( _driverWait . Until ( _driver => _driver . FindElements ( byClassName ) . Count == 2 ) , Is . True ) ;
52
+ }
53
+
54
+ [ Test ]
55
+ public void FindElementMobileByClassNameTest ( )
56
+ {
57
+ try
48
58
{
49
- Assert . That ( _driver . FindElements ( MobileBy . ClassName ( "UIAWindow" ) ) [ 1 ] . FindElement ( byIosUiAutomation ) . Text , Is . Not . Null ) ;
50
- Assert . That ( _driver . FindElements ( MobileBy . ClassName ( "UIAWindow" ) ) [ 1 ] . FindElements ( byIosUiAutomation ) , Is . Not . Empty ) ;
51
- } ) ;
59
+ var switchElement = _driver . FindElement ( MobileBy . ClassName ( "XCUIElementTypeSwitch" ) ) ;
60
+ }
61
+ catch ( NoSuchElementException ex )
62
+ {
63
+ Assert . Fail ( "Element not found, exception: " + ex . Message ) ;
64
+ }
52
65
}
53
66
54
67
}
0 commit comments