-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from zebraxxl/feature/switch-window
SwitchToWindow command implementation
- Loading branch information
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/Winium.Desktop.Driver/CommandExecutors/SwitchToWindowExecutor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
namespace Winium.Desktop.Driver.CommandExecutors | ||
{ | ||
#region using | ||
|
||
using System.Windows.Automation; | ||
using Winium.Cruciatus; | ||
using Winium.Cruciatus.Core; | ||
using Winium.StoreApps.Common; | ||
using Winium.StoreApps.Common.Exceptions; | ||
|
||
#endregion | ||
|
||
internal class SwitchToWindowExecutor : CommandExecutorBase | ||
{ | ||
#region Methods | ||
|
||
protected override string DoImpl() | ||
{ | ||
var windowHandle = int.Parse(this.ExecutedCommand.Parameters["name"].ToString()); | ||
|
||
var handleProperty = AutomationElement.NativeWindowHandleProperty; | ||
var window = CruciatusFactory.Root.FindElement(By.AutomationProperty(handleProperty, windowHandle)); | ||
if (window == null) | ||
{ | ||
throw new AutomationException("Window cannot be found", ResponseStatus.NoSuchElement); | ||
} | ||
|
||
window.SetFocus(); | ||
|
||
return this.JsonResponse(); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters