Skip to content

Commit

Permalink
fix ExecuteScript and Actions to handle IWrapsElement appropriately
Browse files Browse the repository at this point in the history
Using EventFiringWebDriver, element targets and args throw exceptions
when calling ExecuteScript or Actions methods. Fix by casting as
IWrapsElement and checking for wrapped elements first.

Fixes issue #5810.

Signed-off-by: Jim Evans <james.h.evans.jr@gmail.com>
  • Loading branch information
cwood-panopto authored and jimevans committed Apr 23, 2018
1 parent ee93262 commit 54b37dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dotnet/src/support/Events/EventFiringWebDriver.cs
Expand Up @@ -727,7 +727,7 @@ private static object[] UnwrapElementArguments(object[] args)
List<object> unwrappedArgs = new List<object>();
foreach (object arg in args)
{
EventFiringWebElement eventElementArg = arg as EventFiringWebElement;
IWrapsElement eventElementArg = arg as IWrapsElement;
if (eventElementArg != null)
{
unwrappedArgs.Add(eventElementArg.WrappedElement);
Expand Down
21 changes: 9 additions & 12 deletions dotnet/src/webdriver/Interactions/Actions.cs
Expand Up @@ -457,20 +457,17 @@ protected static ILocatable GetLocatableFromElement(IWebElement element)
return null;
}

ILocatable target = element as ILocatable;
if (target == null)
ILocatable target = null;
IWrapsElement wrapper = element as IWrapsElement;
while (wrapper != null)
{
IWrapsElement wrapper = element as IWrapsElement;
while (wrapper != null)
{
target = wrapper.WrappedElement as ILocatable;
if (target != null)
{
break;
}
target = wrapper.WrappedElement as ILocatable;
wrapper = wrapper.WrappedElement as IWrapsElement;
}

wrapper = wrapper.WrappedElement as IWrapsElement;
}
if (target == null)
{
target = element as ILocatable;
}

if (target == null)
Expand Down

0 comments on commit 54b37dc

Please sign in to comment.