1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Drawing ;
4
+ using System . Linq ;
1
5
using Aquality . Selenium . Browsers ;
2
6
using Aquality . Selenium . Elements ;
3
7
using Aquality . Selenium . Tests . Integration . TestApp ;
@@ -22,7 +26,7 @@ public void Should_BePossibleTo_Click()
22
26
23
27
[ Test ]
24
28
public void Should_BePossibleTo_ClickAndWait ( )
25
- {
29
+ {
26
30
var welcomeForm = new WelcomeForm ( ) ;
27
31
welcomeForm . Open ( ) ;
28
32
welcomeForm . GetExampleLink ( AvailableExample . Dropdown ) . JsActions . ClickAndWait ( ) ;
@@ -75,7 +79,7 @@ public void Should_BePossibleTo_CheckIsElementOnScreen()
75
79
hoversForm . Open ( ) ;
76
80
Assert . Multiple ( ( ) =>
77
81
{
78
- Assert . IsFalse ( hoversForm . GetHiddenElement ( HoverExample . First , ElementState . ExistsInAnyState ) . JsActions . IsElementOnScreen ( ) ,
82
+ Assert . IsFalse ( hoversForm . GetHiddenElement ( HoverExample . First , ElementState . ExistsInAnyState ) . JsActions . IsElementOnScreen ( ) ,
79
83
$ "Hidden element for { HoverExample . First } should be invisible.") ;
80
84
Assert . IsTrue ( hoversForm . GetExample ( HoverExample . First ) . JsActions . IsElementOnScreen ( ) ,
81
85
$ "Element for { HoverExample . First } should be visible.") ;
@@ -87,7 +91,7 @@ public void Should_BePossibleTo_SetValue()
87
91
{
88
92
var keyPressesForm = new KeyPressesForm ( ) ;
89
93
keyPressesForm . Open ( ) ;
90
- var text = "text" ;
94
+ const string text = "text" ;
91
95
keyPressesForm . InputTextBox . JsActions . SetValue ( text ) ;
92
96
var actualText = keyPressesForm . InputTextBox . Value ;
93
97
Assert . AreEqual ( text , actualText , $ "Text should be '{ text } ' after setting value via JS") ;
@@ -108,7 +112,7 @@ public void Should_BePossibleTo_GetXPathLocator()
108
112
var welcomeForm = new WelcomeForm ( ) ;
109
113
welcomeForm . Open ( ) ;
110
114
var actualLocator = welcomeForm . SubTitleLabel . JsActions . GetXPath ( ) ;
111
- var expectedLocator = "/html/body/DIV[2]/DIV[1]/H2[1]" ;
115
+ const string expectedLocator = "/html/body/DIV[2]/DIV[1]/H2[1]" ;
112
116
Assert . AreEqual ( expectedLocator , actualLocator , $ "Locator of sub title should be { expectedLocator } ") ;
113
117
}
114
118
@@ -126,48 +130,59 @@ public void Should_BePossibleTo_ScrollIntoView()
126
130
{
127
131
var infiniteScrollForm = new InfiniteScrollForm ( ) ;
128
132
infiniteScrollForm . Open ( ) ;
133
+ infiniteScrollForm . WaitForPageToLoad ( ) ;
129
134
var defaultCount = infiniteScrollForm . ExampleLabels . Count ;
130
- infiniteScrollForm . LastExampleLabel . JsActions . ScrollIntoView ( ) ;
131
135
Assert . DoesNotThrow (
132
136
( ) => ConditionalWait . WaitForTrue ( ( ) =>
133
137
{
134
138
infiniteScrollForm . LastExampleLabel . JsActions . ScrollIntoView ( ) ;
135
139
return infiniteScrollForm . ExampleLabels . Count > defaultCount ;
136
- } ) ,
137
- "Some examples should be added after scroll" ) ;
140
+ } ) , "Some examples should be added after scroll" ) ;
138
141
}
139
142
140
- [ Ignore ( "Need to fix on Azure" ) ]
141
143
[ Test ]
142
144
public void Should_BePossibleTo_ScrollBy ( )
143
145
{
144
- var infiniteScrollForm = new InfiniteScrollForm ( ) ;
145
- infiniteScrollForm . Open ( ) ;
146
- var defaultCount = infiniteScrollForm . ExampleLabels . Count ;
147
- Assert . DoesNotThrow (
148
- ( ) => ConditionalWait . WaitForTrue ( ( ) =>
149
- {
150
- infiniteScrollForm . LastExampleLabel . JsActions . ScrollBy ( 100000 , 100000 ) ;
151
- return infiniteScrollForm . ExampleLabels . Count > defaultCount ;
152
- } ) ,
153
- "Some examples should be added after scroll ") ;
146
+ var point = new Point ( 50 , 40 ) ;
147
+ var homeDemoSiteForm = new HomeDemoSiteForm ( ) ;
148
+ homeDemoSiteForm . Open ( ) ;
149
+ homeDemoSiteForm . FirstScrollableExample . JsActions . ScrollBy ( point . X , point . Y ) ;
150
+ var currentCoordinates = BrowserManager . Browser
151
+ . ExecuteScriptFromFile < IList < object > > ( "Resources.GetScrollCoordinates.js" ,
152
+ homeDemoSiteForm . FirstScrollableExample . GetElement ( ) ) . Select ( item => int . Parse ( item . ToString ( ) ) )
153
+ . ToList ( ) ;
154
+ var actualPoint = new Point ( currentCoordinates [ 0 ] , currentCoordinates [ 1 ] ) ;
155
+ Assert . AreEqual ( point , actualPoint , $ "Current coordinates should be ' { point } ' ") ;
154
156
}
155
157
156
- [ Ignore ( "Need to fix on Azure" ) ]
157
158
[ Test ]
158
159
public void Should_BePossibleTo_ScrollToTheCenter ( )
160
+ {
161
+ const int accuracy = 1 ;
162
+ var welcomeForm = new WelcomeForm ( ) ;
163
+ welcomeForm . Open ( ) ;
164
+ welcomeForm . GetExampleLink ( AvailableExample . Dropdown ) . JsActions . ScrollToTheCenter ( ) ;
165
+
166
+ var windowSize = BrowserManager . Browser . ExecuteScriptFromFile < object > ( "Resources.GetWindowSize.js" ) . ToString ( ) ;
167
+ var currentY = BrowserManager . Browser . ExecuteScriptFromFile < object > ( "Resources.GetElementYCoordinate.js" ,
168
+ welcomeForm . GetExampleLink ( AvailableExample . Dropdown ) . GetElement ( ) ) . ToString ( ) ;
169
+ var coordinateRelatingWindowCenter = double . Parse ( windowSize ) / 2 - double . Parse ( currentY ) ;
170
+ Assert . LessOrEqual ( Math . Abs ( coordinateRelatingWindowCenter ) , accuracy , "Upper bound of element should be in the center of the page" ) ;
171
+ }
172
+
173
+ [ Test ]
174
+ public void Should_BePossibleTo_ScrollToTheCenter_CheckUI ( )
159
175
{
160
176
var infiniteScrollForm = new InfiniteScrollForm ( ) ;
161
177
infiniteScrollForm . Open ( ) ;
162
- var defaultCount = infiniteScrollForm . ExampleLabels . Count ;
163
-
178
+ infiniteScrollForm . WaitForPageToLoad ( ) ;
179
+ var defaultCount = infiniteScrollForm . ExampleLabels . Count ;
164
180
Assert . DoesNotThrow (
165
181
( ) => ConditionalWait . WaitForTrue ( ( ) =>
166
182
{
167
- infiniteScrollForm . LastExampleLabel . JsActions . ScrollToTheCenter ( ) ;
183
+ infiniteScrollForm . Footer . JsActions . ScrollToTheCenter ( ) ;
168
184
return infiniteScrollForm . ExampleLabels . Count > defaultCount ;
169
- } ) ,
170
- "Some examples should be added after scroll" ) ;
185
+ } ) , "Some examples should be added after scroll" ) ;
171
186
}
172
187
}
173
188
}
0 commit comments