Skip to content

Commit ed6b81d

Browse files
petrucjimevans
authored andcommitted
Add HTML5 functionality to .NET bindings
This includes being able to access appCache status, local and session storage, and geolocation. Each feature has a role-based marker interface (IHasApplicationCache, IHasWebStorage, or IHasLocationContext), and the implementation has a boolean property to query if the driver supports that feature. Attempting to use the feature for a driver which does not support it will throw an exception. Signed-off-by: Jim Evans <james.h.evans.jr@gmail.com>
1 parent 9c1b1e6 commit ed6b81d

27 files changed

+1477
-5
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// <copyright file="AppCacheStatus.cs" company="WebDriver Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// </copyright>
18+
19+
using System;
20+
using System.Collections.Generic;
21+
22+
namespace OpenQA.Selenium.Html5
23+
{
24+
/// <summary>
25+
/// Represents the application cache status.
26+
/// </summary>
27+
public enum AppCacheStatus
28+
{
29+
/// <summary>
30+
/// AppCache status is uncached
31+
/// </summary>
32+
Uncached = 0,
33+
34+
/// <summary>
35+
/// AppCache status is idle
36+
/// </summary>
37+
Idle = 1,
38+
39+
/// <summary>
40+
/// AppCache status is checkint
41+
/// </summary>
42+
Checking,
43+
44+
/// <summary>
45+
/// AppCache status is downloading
46+
/// </summary>
47+
Downloading,
48+
49+
/// <summary>
50+
/// AppCache status is updated-ready
51+
/// </summary>
52+
UpdateReady,
53+
54+
/// <summary>
55+
/// AppCache status is obsolete
56+
/// </summary>
57+
Obsolete
58+
}
59+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// <copyright file="IApplicationCache.cs" company="WebDriver Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// </copyright>
18+
19+
namespace OpenQA.Selenium.Html5
20+
{
21+
/// <summary>
22+
/// Defines an interface allowing the user to access application cache status
23+
/// </summary>
24+
public interface IApplicationCache
25+
{
26+
/// <summary>
27+
/// Gets the current state of the application cache.
28+
/// </summary>
29+
AppCacheStatus Status { get; }
30+
}
31+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// <copyright file="IHasApplicationCache.cs" company="WebDriver Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// </copyright>
18+
19+
namespace OpenQA.Selenium.Html5
20+
{
21+
/// <summary>
22+
/// Interface allowing the user to determine if the driver instance supports application cache.
23+
/// </summary>
24+
public interface IHasApplicationCache
25+
{
26+
/// <summary>
27+
/// Gets a value indicating whether manipulating the application cache is supported for this driver.
28+
/// </summary>
29+
bool HasApplicationCache{ get; }
30+
31+
/// <summary>
32+
/// Gets an <see cref="IApplicationCache"/> object for managing application cache.
33+
/// </summary>
34+
IApplicationCache ApplicationCache { get; }
35+
}
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// <copyright file="IHasLocationContext.cs" company="WebDriver Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// </copyright>
18+
19+
namespace OpenQA.Selenium.Html5
20+
{
21+
/// <summary>
22+
/// Interface allowing the user to determine if the driver instance supports geolocation.
23+
/// </summary>
24+
public interface IHasLocationContext
25+
{
26+
/// <summary>
27+
/// Gets a value indicating whether manipulating geolocation is supported for this driver.
28+
/// </summary>
29+
bool HasLocationContext { get; }
30+
31+
/// <summary>
32+
/// Gets an <see cref="ILocationContext"/> object for managing browser location.
33+
/// </summary>
34+
ILocationContext LocationContext { get; }
35+
}
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// <copyright file="IHasWebStorage.cs" company="WebDriver Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// </copyright>
18+
19+
namespace OpenQA.Selenium.Html5
20+
{
21+
/// <summary>
22+
/// Interface allowing the user to determine if the driver instance supports web storage.
23+
/// </summary>
24+
public interface IHasWebStorage
25+
{
26+
/// <summary>
27+
/// Gets a value indicating whether web storage is supported for this driver.
28+
/// </summary>
29+
bool HasWebStorage { get; }
30+
31+
/// <summary>
32+
/// Gets an <see cref="IWebStorage"/> object for managing web storage.
33+
/// </summary>
34+
IWebStorage WebStorage { get; }
35+
}
36+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// <copyright file="ILocalStorage.cs" company="WebDriver Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// </copyright>
18+
19+
using System.Collections.Generic;
20+
using System.Collections.ObjectModel;
21+
22+
namespace OpenQA.Selenium.Html5
23+
{
24+
/// <summary>
25+
/// Represents the local storage for the site currently opened in the browser.
26+
/// Each site has its own separate storage area.
27+
/// </summary>
28+
public interface ILocalStorage
29+
{
30+
/// <summary>
31+
/// Gets the number of items in local storage.
32+
/// </summary>
33+
int Count { get; }
34+
35+
/// <summary>
36+
/// Returns value of the local storage given a key.
37+
/// </summary>
38+
/// <param name="key">key to for a local storage entry</param>
39+
/// <returns>Value of the local storage entry as <see cref="string"/> given a key.</returns>
40+
string GetItem(string key);
41+
42+
/// <summary>
43+
/// Returns the set of keys associated with local storage.
44+
/// </summary>
45+
/// <returns>Returns the set of keys associated with local storage as <see cref="HashSet{T}"/>.</returns>
46+
ReadOnlyCollection<string> KeySet();
47+
48+
/// <summary>
49+
/// Adds key/value pair to local storage.
50+
/// </summary>
51+
/// <param name="key">storage key</param>
52+
/// <param name="value">storage value</param>
53+
void SetItem(string key, string value);
54+
55+
/// <summary>
56+
/// Removes key/value pair from local storage.
57+
/// </summary>
58+
/// <param name="key">key to remove from storage</param>
59+
/// <returns>Value from local storage as <see cref="string">string</see> for the given key.</returns>
60+
string RemoveItem(string key);
61+
62+
/// <summary>
63+
/// Clears local storage.
64+
/// </summary>
65+
void Clear();
66+
}
67+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// <copyright file="ILocationContext.cs" company="WebDriver Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// </copyright>
18+
19+
namespace OpenQA.Selenium.Html5
20+
{
21+
/// <summary>
22+
/// Interface for location context
23+
/// </summary>
24+
public interface ILocationContext
25+
{
26+
/// <summary>
27+
/// Gets or sets a value indicating the physical location of the browser.
28+
/// </summary>
29+
Location PhysicalLocation { get; set; }
30+
}
31+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// <copyright file="ISessionStorage.cs" company="WebDriver Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
// </copyright>
18+
19+
using System.Collections.Generic;
20+
using System.Collections.ObjectModel;
21+
22+
namespace OpenQA.Selenium.Html5
23+
{
24+
/// <summary>
25+
/// Represents the session storage for the site currently opened in the browser.
26+
/// Each site has its own separate storage area.
27+
/// </summary>
28+
public interface ISessionStorage
29+
{
30+
/// <summary>
31+
/// Gets the number of items in session storage.
32+
/// </summary>
33+
int Count { get; }
34+
35+
/// <summary>
36+
/// Returns value of the session storage given a key.
37+
/// </summary>
38+
/// <param name="key">key to for a session storage entry</param>
39+
/// <returns>Value of the session storage entry as <see cref="string"/> given a key.</returns>
40+
string GetItem(string key);
41+
42+
/// <summary>
43+
/// Returns the set of keys associated with session storage.
44+
/// </summary>
45+
/// <returns>Returns the set of keys associated with session storage as <see cref="HashSet{T}"/>.</returns>
46+
ReadOnlyCollection<string> KeySet();
47+
48+
/// <summary>
49+
/// Adds key/value pair to session storage.
50+
/// </summary>
51+
/// <param name="key">storage key</param>
52+
/// <param name="value">storage value</param>
53+
void SetItem(string key, string value);
54+
55+
/// <summary>
56+
/// Removes key/value pair from session storage.
57+
/// </summary>
58+
/// <param name="key">key to remove from storage</param>
59+
/// <returns>Value from session storage as <see cref="string">string</see> for the given key.</returns>
60+
string RemoveItem(string key);
61+
62+
/// <summary>
63+
/// Clears local storage.
64+
/// </summary>
65+
void Clear();
66+
}
67+
}

0 commit comments

Comments
 (0)