Skip to content

Commit

Permalink
Merge pull request #57 from zebraxxl/feature/switch-window
Browse files Browse the repository at this point in the history
SwitchToWindow command implementation
  • Loading branch information
skyline-gleb committed Oct 20, 2015
2 parents 985acd5 + 005e905 commit 1858a1e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
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
}
}
3 changes: 2 additions & 1 deletion src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Winium.Cruciatus, Version=2.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Winium.Cruciatus.2.8.0\lib\net45\Winium.Cruciatus.dll</HintPath>
<HintPath>..\packages\Winium.Cruciatus.2.9.1\lib\net45\Winium.Cruciatus.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand Down Expand Up @@ -112,6 +112,7 @@
<Compile Include="CommandExecutors\FindElementExecutor.cs" />
<Compile Include="CommandExecutors\NewSessionExecutor.cs" />
<Compile Include="CommandExecutors\NotImplementedExecutor.cs" />
<Compile Include="CommandExecutors\SwitchToWindowExecutor.cs" />
<Compile Include="CommandLineOptions.cs" />
<Compile Include="ElementsRegistry.cs" />
<Compile Include="Extensions\AutomationPropertyHelper.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/Winium.Desktop.Driver/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" userInstalled="true" />
<package id="NLog" version="3.1.0.0" targetFramework="net451" />
<package id="Selenium.WebDriver" version="2.46.0" targetFramework="net451" userInstalled="true" />
<package id="Winium.Cruciatus" version="2.8.0" targetFramework="net451" />
<package id="Winium.Cruciatus" version="2.9.1" targetFramework="net451" />
</packages>

0 comments on commit 1858a1e

Please sign in to comment.