Skip to content

Commit

Permalink
Add HTML5 functionality to .NET bindings
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
petruc authored and jimevans committed Oct 19, 2015
1 parent 9c1b1e6 commit ed6b81d
Show file tree
Hide file tree
Showing 27 changed files with 1,477 additions and 5 deletions.
59 changes: 59 additions & 0 deletions dotnet/src/webdriver/HTML5/AppCacheStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// <copyright file="AppCacheStatus.cs" company="WebDriver Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System;
using System.Collections.Generic;

namespace OpenQA.Selenium.Html5
{
/// <summary>
/// Represents the application cache status.
/// </summary>
public enum AppCacheStatus
{
/// <summary>
/// AppCache status is uncached
/// </summary>
Uncached = 0,

/// <summary>
/// AppCache status is idle
/// </summary>
Idle = 1,

/// <summary>
/// AppCache status is checkint
/// </summary>
Checking,

/// <summary>
/// AppCache status is downloading
/// </summary>
Downloading,

/// <summary>
/// AppCache status is updated-ready
/// </summary>
UpdateReady,

/// <summary>
/// AppCache status is obsolete
/// </summary>
Obsolete
}
}
31 changes: 31 additions & 0 deletions dotnet/src/webdriver/HTML5/IApplicationCache.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// <copyright file="IApplicationCache.cs" company="WebDriver Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

namespace OpenQA.Selenium.Html5
{
/// <summary>
/// Defines an interface allowing the user to access application cache status
/// </summary>
public interface IApplicationCache
{
/// <summary>
/// Gets the current state of the application cache.
/// </summary>
AppCacheStatus Status { get; }
}
}
36 changes: 36 additions & 0 deletions dotnet/src/webdriver/HTML5/IHasApplicationCache.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// <copyright file="IHasApplicationCache.cs" company="WebDriver Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

namespace OpenQA.Selenium.Html5
{
/// <summary>
/// Interface allowing the user to determine if the driver instance supports application cache.
/// </summary>
public interface IHasApplicationCache
{
/// <summary>
/// Gets a value indicating whether manipulating the application cache is supported for this driver.
/// </summary>
bool HasApplicationCache{ get; }

/// <summary>
/// Gets an <see cref="IApplicationCache"/> object for managing application cache.
/// </summary>
IApplicationCache ApplicationCache { get; }
}
}
36 changes: 36 additions & 0 deletions dotnet/src/webdriver/HTML5/IHasLocationContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// <copyright file="IHasLocationContext.cs" company="WebDriver Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

namespace OpenQA.Selenium.Html5
{
/// <summary>
/// Interface allowing the user to determine if the driver instance supports geolocation.
/// </summary>
public interface IHasLocationContext
{
/// <summary>
/// Gets a value indicating whether manipulating geolocation is supported for this driver.
/// </summary>
bool HasLocationContext { get; }

/// <summary>
/// Gets an <see cref="ILocationContext"/> object for managing browser location.
/// </summary>
ILocationContext LocationContext { get; }
}
}
36 changes: 36 additions & 0 deletions dotnet/src/webdriver/HTML5/IHasWebStorage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// <copyright file="IHasWebStorage.cs" company="WebDriver Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

namespace OpenQA.Selenium.Html5
{
/// <summary>
/// Interface allowing the user to determine if the driver instance supports web storage.
/// </summary>
public interface IHasWebStorage
{
/// <summary>
/// Gets a value indicating whether web storage is supported for this driver.
/// </summary>
bool HasWebStorage { get; }

/// <summary>
/// Gets an <see cref="IWebStorage"/> object for managing web storage.
/// </summary>
IWebStorage WebStorage { get; }
}
}
67 changes: 67 additions & 0 deletions dotnet/src/webdriver/HTML5/ILocalStorage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// <copyright file="ILocalStorage.cs" company="WebDriver Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace OpenQA.Selenium.Html5
{
/// <summary>
/// Represents the local storage for the site currently opened in the browser.
/// Each site has its own separate storage area.
/// </summary>
public interface ILocalStorage
{
/// <summary>
/// Gets the number of items in local storage.
/// </summary>
int Count { get; }

/// <summary>
/// Returns value of the local storage given a key.
/// </summary>
/// <param name="key">key to for a local storage entry</param>
/// <returns>Value of the local storage entry as <see cref="string"/> given a key.</returns>
string GetItem(string key);

/// <summary>
/// Returns the set of keys associated with local storage.
/// </summary>
/// <returns>Returns the set of keys associated with local storage as <see cref="HashSet{T}"/>.</returns>
ReadOnlyCollection<string> KeySet();

/// <summary>
/// Adds key/value pair to local storage.
/// </summary>
/// <param name="key">storage key</param>
/// <param name="value">storage value</param>
void SetItem(string key, string value);

/// <summary>
/// Removes key/value pair from local storage.
/// </summary>
/// <param name="key">key to remove from storage</param>
/// <returns>Value from local storage as <see cref="string">string</see> for the given key.</returns>
string RemoveItem(string key);

/// <summary>
/// Clears local storage.
/// </summary>
void Clear();
}
}
31 changes: 31 additions & 0 deletions dotnet/src/webdriver/HTML5/ILocationContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// <copyright file="ILocationContext.cs" company="WebDriver Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

namespace OpenQA.Selenium.Html5
{
/// <summary>
/// Interface for location context
/// </summary>
public interface ILocationContext
{
/// <summary>
/// Gets or sets a value indicating the physical location of the browser.
/// </summary>
Location PhysicalLocation { get; set; }
}
}
67 changes: 67 additions & 0 deletions dotnet/src/webdriver/HTML5/ISessionStorage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// <copyright file="ISessionStorage.cs" company="WebDriver Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace OpenQA.Selenium.Html5
{
/// <summary>
/// Represents the session storage for the site currently opened in the browser.
/// Each site has its own separate storage area.
/// </summary>
public interface ISessionStorage
{
/// <summary>
/// Gets the number of items in session storage.
/// </summary>
int Count { get; }

/// <summary>
/// Returns value of the session storage given a key.
/// </summary>
/// <param name="key">key to for a session storage entry</param>
/// <returns>Value of the session storage entry as <see cref="string"/> given a key.</returns>
string GetItem(string key);

/// <summary>
/// Returns the set of keys associated with session storage.
/// </summary>
/// <returns>Returns the set of keys associated with session storage as <see cref="HashSet{T}"/>.</returns>
ReadOnlyCollection<string> KeySet();

/// <summary>
/// Adds key/value pair to session storage.
/// </summary>
/// <param name="key">storage key</param>
/// <param name="value">storage value</param>
void SetItem(string key, string value);

/// <summary>
/// Removes key/value pair from session storage.
/// </summary>
/// <param name="key">key to remove from storage</param>
/// <returns>Value from session storage as <see cref="string">string</see> for the given key.</returns>
string RemoveItem(string key);

/// <summary>
/// Clears local storage.
/// </summary>
void Clear();
}
}
Loading

0 comments on commit ed6b81d

Please sign in to comment.