Skip to content

Commit

Permalink
Add XML documentation for all potential exceptions thrown across the …
Browse files Browse the repository at this point in the history
…libraries
  • Loading branch information
jamesmcroft committed Feb 17, 2023
1 parent 7363c45 commit 1cca7cd
Show file tree
Hide file tree
Showing 146 changed files with 12,114 additions and 10,753 deletions.
49 changes: 24 additions & 25 deletions src/Legerity.Android/AndroidByExtras.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
namespace Legerity.Android
{
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Android.UiAutomator;
namespace Legerity.Android;

using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Android.UiAutomator;

/// <summary>
/// Defines a collection of extra locator constraints for <see cref="By"/>.
/// </summary>
public static class AndroidByExtras
{
/// <summary>
/// Defines a collection of extra locator constraints for <see cref="By"/>.
/// Gets a mechanism to find elements by an Android content description.
/// </summary>
public static class AndroidByExtras
/// <param name="contentDesc">The content description to match exactly on.</param>
/// <returns>A <see cref="By"/> object the driver can use to find elements.</returns>
public static By ContentDescription(string contentDesc)
{
/// <summary>
/// Gets a mechanism to find elements by an Android content description.
/// </summary>
/// <param name="contentDesc">The content description to match exactly on.</param>
/// <returns>A <see cref="By"/> object the driver can use to find elements.</returns>
public static By ContentDescription(string contentDesc)
{
return new ByAndroidUIAutomator(new AndroidUiSelector().DescriptionEquals(contentDesc));
}
return new ByAndroidUIAutomator(new AndroidUiSelector().DescriptionEquals(contentDesc));
}

/// <summary>
/// Gets a mechanism to find elements by an Android partial content description.
/// </summary>
/// <param name="contentDesc">The partial content description to match on.</param>
/// <returns>A <see cref="By"/> object the driver can use to find elements.</returns>
public static By PartialContentDescription(string contentDesc)
{
return new ByAndroidUIAutomator(new AndroidUiSelector().DescriptionContains(contentDesc));
}
/// <summary>
/// Gets a mechanism to find elements by an Android partial content description.
/// </summary>
/// <param name="contentDesc">The partial content description to match on.</param>
/// <returns>A <see cref="By"/> object the driver can use to find elements.</returns>
public static By PartialContentDescription(string contentDesc)
{
return new ByAndroidUIAutomator(new AndroidUiSelector().DescriptionContains(contentDesc));
}
}
16 changes: 13 additions & 3 deletions src/Legerity.Android/Elements/AndroidElementWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,22 @@ public static implicit operator AndroidElementWrapper(RemoteWebElement element)
/// <param name="timeout">
/// The amount of time the driver should wait when searching for the <paramref name="locator"/> if it is not immediately present.
/// </param>
/// <exception cref="ElementNotShownException">Thrown when an element is not shown for the expected locator.</exception>
/// <exception cref="NoSuchElementException">Thrown when no element matches the expected locator.</exception>
protected void VerifyDriverElementShown(By locator, TimeSpan? timeout)
{
if (timeout == null)
{
if (this.Driver.FindElement(locator) == null)
try
{
throw new ElementNotShownException(locator.ToString());
if (this.Driver.FindElement(locator) == null)
{
throw new ElementNotShownException(locator.ToString());
}
}
catch (NoSuchElementException ex)
{
throw new ElementNotShownException(locator.ToString(), ex);
}
}
else
Expand All @@ -105,13 +114,14 @@ protected void VerifyDriverElementShown(By locator, TimeSpan? timeout)
/// <param name="timeout">
/// The amount of time the driver should wait when searching for the <paramref name="locator"/> if it is not immediately present.
/// </param>
/// <exception cref="ElementsNotShownException">Thrown when no elements are shown for the expected locator.</exception>
protected void VerifyDriverElementsShown(By locator, TimeSpan? timeout)
{
if (timeout == null)
{
if (this.Driver.FindElements(locator).Count == 0)
{
throw new ElementNotShownException(locator.ToString());
throw new ElementsNotShownException(locator.ToString());
}
}
else
Expand Down
113 changes: 56 additions & 57 deletions src/Legerity.Android/Elements/Core/Button.cs
Original file line number Diff line number Diff line change
@@ -1,66 +1,65 @@
namespace Legerity.Android.Elements.Core
{
using Legerity.Android.Elements;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Remote;
namespace Legerity.Android.Elements.Core;

using Legerity.Android.Elements;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Remote;

/// <summary>
/// Defines a <see cref="AndroidElement"/> wrapper for the core Android Button control.
/// </summary>
public class Button : AndroidElementWrapper
{
/// <summary>
/// Defines a <see cref="AndroidElement"/> wrapper for the core Android Button control.
/// Initializes a new instance of the <see cref="Button"/> class.
/// </summary>
public class Button : AndroidElementWrapper
/// <param name="element">
/// The <see cref="AndroidElement"/> reference.
/// </param>
public Button(AndroidElement element)
: base(element)
{
/// <summary>
/// Initializes a new instance of the <see cref="Button"/> class.
/// </summary>
/// <param name="element">
/// The <see cref="AndroidElement"/> reference.
/// </param>
public Button(AndroidElement element)
: base(element)
{
}
}

/// <summary>
/// Allows conversion of a <see cref="AndroidElement"/> to the <see cref="Button"/> without direct casting.
/// </summary>
/// <param name="element">
/// The <see cref="AndroidElement"/>.
/// </param>
/// <returns>
/// The <see cref="Button"/>.
/// </returns>
public static implicit operator Button(AndroidElement element)
{
return new Button(element);
}
/// <summary>
/// Allows conversion of a <see cref="AndroidElement"/> to the <see cref="Button"/> without direct casting.
/// </summary>
/// <param name="element">
/// The <see cref="AndroidElement"/>.
/// </param>
/// <returns>
/// The <see cref="Button"/>.
/// </returns>
public static implicit operator Button(AndroidElement element)
{
return new Button(element);
}

/// <summary>
/// Allows conversion of a <see cref="AppiumWebElement"/> to the <see cref="Button"/> without direct casting.
/// </summary>
/// <param name="element">
/// The <see cref="AppiumWebElement"/>.
/// </param>
/// <returns>
/// The <see cref="Button"/>.
/// </returns>
public static implicit operator Button(AppiumWebElement element)
{
return new Button(element as AndroidElement);
}
/// <summary>
/// Allows conversion of a <see cref="AppiumWebElement"/> to the <see cref="Button"/> without direct casting.
/// </summary>
/// <param name="element">
/// The <see cref="AppiumWebElement"/>.
/// </param>
/// <returns>
/// The <see cref="Button"/>.
/// </returns>
public static implicit operator Button(AppiumWebElement element)
{
return new Button(element as AndroidElement);
}

/// <summary>
/// Allows conversion of a <see cref="RemoteWebElement"/> to the <see cref="Button"/> without direct casting.
/// </summary>
/// <param name="element">
/// The <see cref="RemoteWebElement"/>.
/// </param>
/// <returns>
/// The <see cref="Button"/>.
/// </returns>
public static implicit operator Button(RemoteWebElement element)
{
return new Button(element as AndroidElement);
}
/// <summary>
/// Allows conversion of a <see cref="RemoteWebElement"/> to the <see cref="Button"/> without direct casting.
/// </summary>
/// <param name="element">
/// The <see cref="RemoteWebElement"/>.
/// </param>
/// <returns>
/// The <see cref="Button"/>.
/// </returns>
public static implicit operator Button(RemoteWebElement element)
{
return new Button(element as AndroidElement);
}
}
Loading

0 comments on commit 1cca7cd

Please sign in to comment.