Skip to content

Commit b090565

Browse files
Upgrade to latest stable version of Selenium
1 parent 9a7079a commit b090565

File tree

5 files changed

+34
-68
lines changed

5 files changed

+34
-68
lines changed

GuiTests/App.config

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
<!--
55
Configure Selenium grid settings http://www.seleniumhq.org/projects/grid/
66
-->
7-
<add key="UseGrid" value="false" />
8-
<add key="GridUrl" value="http://riskitseleniumgrid:4444/wd/hub" />
97
<!--
108
Choose on of the following drivers:
119
InternetExplorer

GuiTests/GuiTests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@
5353
<Reference Include="System.Drawing" />
5454
<Reference Include="System.Xml" />
5555
<Reference Include="System.Xml.Linq" />
56-
<Reference Include="WebDriver, Version=2.53.1.0, Culture=neutral, processorArchitecture=MSIL">
57-
<HintPath>..\packages\Selenium.WebDriver.2.53.1\lib\net40\WebDriver.dll</HintPath>
56+
<Reference Include="WebDriver, Version=3.141.0.0, Culture=neutral, processorArchitecture=MSIL">
57+
<HintPath>..\packages\Selenium.WebDriver.3.141.0\lib\net40\WebDriver.dll</HintPath>
5858
</Reference>
59-
<Reference Include="WebDriver.Support, Version=2.53.1.0, Culture=neutral, processorArchitecture=MSIL">
60-
<HintPath>..\packages\Selenium.Support.2.53.1\lib\net40\WebDriver.Support.dll</HintPath>
59+
<Reference Include="WebDriver.Support, Version=3.141.0.0, Culture=neutral, processorArchitecture=MSIL">
60+
<HintPath>..\packages\Selenium.Support.3.141.0\lib\net40\WebDriver.Support.dll</HintPath>
6161
</Reference>
6262
</ItemGroup>
6363
<ItemGroup>

GuiTests/SeleniumHelpers/DriverFactory.cs

Lines changed: 26 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using OpenQA.Selenium.IE;
88
using OpenQA.Selenium.Remote;
99
using Structura.GuiTests.Utilities;
10-
using Tests.SeleniumHelpers;
1110

1211
namespace Structura.GuiTests.SeleniumHelpers
1312
{
@@ -20,78 +19,47 @@ public enum DriverToUse
2019

2120
public class DriverFactory
2221
{
23-
private static readonly FirefoxProfile FirefoxProfile = CreateFirefoxProfile();
24-
25-
private static FirefoxProfile CreateFirefoxProfile()
22+
private static FirefoxOptions FirefoxOptions
2623
{
27-
var firefoxProfile = new FirefoxProfile();
28-
firefoxProfile.SetPreference("network.automatic-ntlm-auth.trusted-uris", "http://localhost");
29-
return firefoxProfile;
24+
get
25+
{
26+
var firefoxProfile = new FirefoxOptions();
27+
firefoxProfile.SetPreference("network.automatic-ntlm-auth.trusted-uris", "http://localhost");
28+
return firefoxProfile;
29+
}
3030
}
3131

3232
public IWebDriver Create()
3333
{
3434
IWebDriver driver;
35-
var driverToUse = ConfigurationHelper.Get<DriverToUse>("DriverToUse");
36-
var useGrid = ConfigurationHelper.Get<bool>("UseGrid");
37-
if (useGrid)
38-
{
39-
driver = CreateGridDriver(driverToUse);
40-
}
41-
else
42-
{
43-
switch (driverToUse)
44-
{
45-
case DriverToUse.InternetExplorer:
46-
driver = new InternetExplorerDriver(AppDomain.CurrentDomain.BaseDirectory, new InternetExplorerOptions(), TimeSpan.FromMinutes(5));
47-
break;
48-
case DriverToUse.Firefox:
49-
var firefoxProfile = FirefoxProfile;
50-
driver = new FirefoxDriver(firefoxProfile);
51-
driver.Manage().Window.Maximize();
52-
break;
53-
case DriverToUse.Chrome:
54-
driver = new ChromeDriver();
55-
break;
56-
default:
57-
throw new ArgumentOutOfRangeException();
58-
}
35+
var driverToUse = ConfigurationHelper.Get<DriverToUse>("DriverToUse");
36+
37+
switch (driverToUse)
38+
{
39+
case DriverToUse.InternetExplorer:
40+
driver = new InternetExplorerDriver(AppDomain.CurrentDomain.BaseDirectory, new InternetExplorerOptions(), TimeSpan.FromMinutes(5));
41+
break;
42+
case DriverToUse.Firefox:
43+
var firefoxProfile = FirefoxOptions;
44+
driver = new FirefoxDriver(firefoxProfile);
45+
driver.Manage().Window.Maximize();
46+
break;
47+
case DriverToUse.Chrome:
48+
driver = new ChromeDriver();
49+
break;
50+
default:
51+
throw new ArgumentOutOfRangeException();
5952
}
6053

6154
driver.Manage().Window.Maximize();
6255
var timeouts = driver.Manage().Timeouts();
6356

64-
timeouts.ImplicitlyWait(TimeSpan.FromSeconds(ConfigurationHelper.Get<int>("ImplicitlyWait")));
65-
timeouts.SetPageLoadTimeout(TimeSpan.FromSeconds(ConfigurationHelper.Get<int>("PageLoadTimeout")));
57+
timeouts.ImplicitWait = TimeSpan.FromSeconds(ConfigurationHelper.Get<int>("ImplicitlyWait"));
58+
timeouts.PageLoad = TimeSpan.FromSeconds(ConfigurationHelper.Get<int>("PageLoadTimeout"));
6659

6760
// Suppress the onbeforeunload event first. This prevents the application hanging on a dialog box that does not close.
6861
((IJavaScriptExecutor)driver).ExecuteScript("window.onbeforeunload = function(e){};");
6962
return driver;
7063
}
71-
72-
public static IWebDriver CreateGridDriver(DriverToUse driverToUse)
73-
{
74-
var gridUrl = ConfigurationManager.AppSettings["GridUrl"];
75-
var desiredCapabilities = DesiredCapabilities.InternetExplorer();
76-
switch (driverToUse)
77-
{
78-
case DriverToUse.Firefox:
79-
desiredCapabilities = DesiredCapabilities.Firefox();
80-
desiredCapabilities.SetCapability(FirefoxDriver.ProfileCapabilityName, FirefoxProfile);
81-
82-
break;
83-
case DriverToUse.InternetExplorer:
84-
desiredCapabilities = DesiredCapabilities.InternetExplorer();
85-
break;
86-
case DriverToUse.Chrome:
87-
desiredCapabilities = DesiredCapabilities.Chrome();
88-
break;
89-
}
90-
desiredCapabilities.IsJavaScriptEnabled = true;
91-
var remoteDriver = new ExtendedRemoteWebDriver(new Uri(gridUrl), desiredCapabilities, TimeSpan.FromSeconds(180));
92-
var nodeHost = remoteDriver.GetNodeHost();
93-
Debug.WriteLine("Running tests on host " + nodeHost);
94-
return remoteDriver;
95-
}
9664
}
9765
}

GuiTests/SeleniumHelpers/SeleniumHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public static IWebDriver Driver
3535
}
3636
_driver = new DriverFactory().Create();
3737
// Avoid synchronization issues by applying timed delay to each step if necessary
38-
_driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMinutes((5)));
39-
_driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromMinutes(5));
38+
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMinutes((5));
39+
_driver.Manage().Timeouts().PageLoad = TimeSpan.FromMinutes(5);
4040
return _driver;
4141
}
4242
}

GuiTests/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<package id="FluentAssertions" version="3.2.2" targetFramework="net40" />
44
<package id="Newtonsoft.Json" version="6.0.7" targetFramework="net40" />
55
<package id="NUnit" version="3.11.0" targetFramework="net40" />
6-
<package id="Selenium.Support" version="2.53.1" targetFramework="net40" />
7-
<package id="Selenium.WebDriver" version="2.53.1" targetFramework="net40" />
6+
<package id="Selenium.Support" version="3.141.0" targetFramework="net40" />
7+
<package id="Selenium.WebDriver" version="3.141.0" targetFramework="net40" />
88
</packages>

0 commit comments

Comments
 (0)