Skip to content

Commit 362eb66

Browse files
committed
# Conflicts: # src/Tests/integrationtests/Tests.SeleniumTests/Tests/ColumnFiltersIntegrationTests.cs # src/Tests/integrationtests/Tests.SeleniumTests/Tests/CustomFiltersTests.cs # src/Tests/integrationtests/Tests.SeleniumTests/Tests/SearchTests.cs
2 parents 566d233 + 472f806 commit 362eb66

File tree

4 files changed

+79
-32
lines changed

4 files changed

+79
-32
lines changed

src/Tests/integrationtests/Tests.SeleniumTests/Common/DriverSingletonProvider.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ internal static class DriverSingletonProvider
99

1010
public static IWebDriver GetDriver()
1111
{
12+
if (driver == null)
13+
{
14+
driver = GetNewDriverInstance();
15+
driver.Manage().Timeouts().PageLoad = new System.TimeSpan(0, 0, 5);
16+
}
17+
1218
return driver;
1319
}
1420

@@ -20,11 +26,7 @@ public static void Dispose()
2026
}
2127

2228
driver.Dispose();
23-
}
24-
25-
static DriverSingletonProvider()
26-
{
27-
DriverSingletonProvider.driver = GetNewDriverInstance();
29+
driver = null;
2830
}
2931

3032
private static IWebDriver GetNewDriverInstance()
Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,50 @@
11
namespace Tests.SeleniumTests.ExtensionMethods
22
{
3+
using System;
34
using System.Collections.ObjectModel;
5+
using System.Threading;
46
using OpenQA.Selenium;
57

68
public static class SearchContextExtensionMethods
79
{
810
public static IWebElement FindElementByCssSelector(this ISearchContext context, string selector)
911
{
10-
return context.FindElement(By.CssSelector(selector));
12+
Exception outerEx = null;
13+
14+
for (int i = 0; i < 5; i++)
15+
{
16+
try
17+
{
18+
return context.FindElement(By.CssSelector(selector));
19+
}
20+
catch (System.Exception ex)
21+
{
22+
outerEx = ex;
23+
Thread.Sleep(1000);
24+
}
25+
}
26+
27+
throw outerEx;
1128
}
1229

1330
public static ReadOnlyCollection<IWebElement> FindElementsByCssSelector(this ISearchContext context, string selector)
1431
{
15-
return context.FindElements(By.CssSelector(selector));
32+
Exception outerEx = null;
33+
34+
for (int i = 0; i < 5; i++)
35+
{
36+
try
37+
{
38+
return context.FindElements(By.CssSelector(selector));
39+
}
40+
catch (System.Exception ex)
41+
{
42+
outerEx = ex;
43+
Thread.Sleep(1000);
44+
}
45+
}
46+
47+
throw outerEx;
1648
}
1749
}
1850
}

src/Tests/integrationtests/Tests.SeleniumTests/Tests.SeleniumTests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<DebugType>full</DebugType>
2626
<Optimize>false</Optimize>
2727
<OutputPath>bin\Debug\</OutputPath>
28-
<DefineConstants>DEBUG;TRACE</DefineConstants>
28+
<DefineConstants>TRACE;DEBUG;USE_UTYPES, USE_STYPES, USE_CHARTYPE, USE_DTOFFSET</DefineConstants>
2929
<ErrorReport>prompt</ErrorReport>
3030
<WarningLevel>4</WarningLevel>
3131
</PropertyGroup>
@@ -78,6 +78,7 @@
7878
<Compile Include="Common\CustomFilterContainer.cs" />
7979
<Compile Include="Common\Data.cs" />
8080
<Compile Include="Common\DriverSingletonProvider.cs" />
81+
<Compile Include="Common\ExceptionsHandler.cs" />
8182
<Compile Include="Common\GlobalConstants.cs" />
8283
<Compile Include="Common\Navigator.cs" />
8384
<Compile Include="Common\TableElement.cs" />

src/Tests/integrationtests/Tests.SeleniumTests/Tests/SortDataTests.cs

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,19 @@ public void SetUp()
3737
[TestCase("Nested Model CharNullable", SortDirectionsEnum.Desc)]
3838
public void Sort_SholdWorkAppropriateForTextTypes(string columnName, SortDirectionsEnum direction)
3939
{
40-
this.navigator.AllTypesDataPage().GoTo();
41-
var tableElement = new TableElement("table", this.driver);
42-
tableElement.ClickSortButton(columnName, direction);
40+
ExceptionsHandler.Hande(() =>
41+
{
42+
this.navigator.AllTypesDataPage().GoTo();
43+
var tableElement = new TableElement("table", this.driver);
44+
tableElement.ClickSortButton(columnName, direction);
4345

44-
// Assert that rows are in correct order for the first page
45-
AssertTextPropertyOrder(columnName, direction, tableElement);
46-
tableElement.GoToLastPage();
47-
// Assert that rows are in correct order for the last page
48-
AssertTextPropertyOrder(columnName, direction, tableElement);
46+
// Assert that rows are in correct order for the first page
47+
AssertTextPropertyOrder(columnName, direction, tableElement);
48+
tableElement.GoToLastPage();
49+
// Assert that rows are in correct order for the last page
50+
AssertTextPropertyOrder(columnName, direction, tableElement);
51+
},
52+
this.driver);
4953
}
5054

5155
[Test]
@@ -204,30 +208,38 @@ public void Sort_SholdWorkAppropriateForTextTypes(string columnName, SortDirecti
204208
[TestCase(nameof(AllTypesModel.NestedModel) + "." + nameof(AllTypesModel.CharNullable), SortDirectionsEnum.Desc, typeof(char?))]
205209
public void Sort_SholdWorkAppropriateForNonTextTypes(string columnName, SortDirectionsEnum direction, Type propertyType)
206210
{
207-
this.navigator.AllTypesDataPage().GoTo();
208-
var tableElement = new TableElement("table", this.driver);
209-
string columnHeader = columnName.StartsWith("NestedModel") ? this.GetHeaderForNestedModel(columnName) : columnName;
210-
tableElement.ClickSortButton(columnHeader, direction);
211+
ExceptionsHandler.Hande(() =>
212+
{
213+
this.navigator.AllTypesDataPage().GoTo();
214+
var tableElement = new TableElement("table", this.driver);
215+
string columnHeader = columnName.StartsWith("NestedModel") ? this.GetHeaderForNestedModel(columnName) : columnName;
216+
tableElement.ClickSortButton(columnHeader, direction);
211217

212-
AssertNonTextPropertyOrder(columnName, columnHeader, direction, propertyType, tableElement);
213-
tableElement.GoToLastPage();
214-
AssertNonTextPropertyOrder(columnName, columnHeader, direction, propertyType, tableElement);
218+
AssertNonTextPropertyOrder(columnName, columnHeader, direction, propertyType, tableElement);
219+
tableElement.GoToLastPage();
220+
AssertNonTextPropertyOrder(columnName, columnHeader, direction, propertyType, tableElement);
221+
},
222+
this.driver);
215223
}
216224

217225
[Test]
218226
public void Sort_SholdWorkWithSubsecuentPropertiesSortOperations()
219227
{
220-
string firstColumnName = "Integer";
221-
string secondColumnName = "DoubleProperty";
228+
ExceptionsHandler.Hande(() =>
229+
{
230+
string firstColumnName = "Integer";
231+
string secondColumnName = "DoubleProperty";
222232

223-
this.navigator.AllTypesDataPage().GoTo();
224-
var tableElement = new TableElement("table", this.driver);
225-
tableElement.ClickSortButton(firstColumnName, SortDirectionsEnum.Asc);
226-
tableElement.ClickSortButton(secondColumnName, SortDirectionsEnum.Asc);
233+
this.navigator.AllTypesDataPage().GoTo();
234+
var tableElement = new TableElement("table", this.driver);
235+
tableElement.ClickSortButton(firstColumnName, SortDirectionsEnum.Asc);
236+
tableElement.ClickSortButton(secondColumnName, SortDirectionsEnum.Asc);
227237

228-
AssertNonTextPropertyOrder(secondColumnName, secondColumnName, SortDirectionsEnum.Asc, typeof(double), tableElement);
229-
tableElement.GoToLastPage();
230-
AssertNonTextPropertyOrder(secondColumnName, secondColumnName, SortDirectionsEnum.Asc, typeof(double), tableElement);
238+
AssertNonTextPropertyOrder(secondColumnName, secondColumnName, SortDirectionsEnum.Asc, typeof(double), tableElement);
239+
tableElement.GoToLastPage();
240+
AssertNonTextPropertyOrder(secondColumnName, secondColumnName, SortDirectionsEnum.Asc, typeof(double), tableElement);
241+
},
242+
this.driver);
231243
}
232244

233245
private string GetHeaderForNestedModel(string columnName)

0 commit comments

Comments
 (0)