Skip to content

Commit 54b37dc

Browse files
cwood-panoptojimevans
authored andcommitted
fix ExecuteScript and Actions to handle IWrapsElement appropriately
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 <[email protected]>
1 parent ee93262 commit 54b37dc

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

dotnet/src/support/Events/EventFiringWebDriver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ private static object[] UnwrapElementArguments(object[] args)
727727
List<object> unwrappedArgs = new List<object>();
728728
foreach (object arg in args)
729729
{
730-
EventFiringWebElement eventElementArg = arg as EventFiringWebElement;
730+
IWrapsElement eventElementArg = arg as IWrapsElement;
731731
if (eventElementArg != null)
732732
{
733733
unwrappedArgs.Add(eventElementArg.WrappedElement);

dotnet/src/webdriver/Interactions/Actions.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -457,20 +457,17 @@ protected static ILocatable GetLocatableFromElement(IWebElement element)
457457
return null;
458458
}
459459

460-
ILocatable target = element as ILocatable;
461-
if (target == null)
460+
ILocatable target = null;
461+
IWrapsElement wrapper = element as IWrapsElement;
462+
while (wrapper != null)
462463
{
463-
IWrapsElement wrapper = element as IWrapsElement;
464-
while (wrapper != null)
465-
{
466-
target = wrapper.WrappedElement as ILocatable;
467-
if (target != null)
468-
{
469-
break;
470-
}
464+
target = wrapper.WrappedElement as ILocatable;
465+
wrapper = wrapper.WrappedElement as IWrapsElement;
466+
}
471467

472-
wrapper = wrapper.WrappedElement as IWrapsElement;
473-
}
468+
if (target == null)
469+
{
470+
target = element as ILocatable;
474471
}
475472

476473
if (target == null)

0 commit comments

Comments
 (0)