Skip to content

Commit

Permalink
Merge pull request #164 from bayandin/the-merge
Browse files Browse the repository at this point in the history
Import WindowsPhoneDriver as Winium.Silverlight
  • Loading branch information
NickAb authored Oct 18, 2016
2 parents 5457ce4 + 09adafe commit 2f18645
Show file tree
Hide file tree
Showing 221 changed files with 4,109 additions and 437 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## vX.Y.Z
- Added Winium.Silverlight for Windows Phone 8.1 Silverlight apps (from https://github.com/2gis/winphonedriver) (kudos to [Badoo Development](https://github.com/badoo)) #164

<!--## Unreleased-->

## v1.6.2
Expand Down Expand Up @@ -47,7 +50,7 @@

## v1.3.0

- Add dynamic port assigment for InnerServer #39
- Add dynamic port assigment for InnerServer #39
- Add `autoLaunch` capability: whether to launch the app automatically. Default `true`
- Add `--version` option to a driver CLI. Fix exit codes
- Add `SetOrientation` command (Note that orientation is preserved between sessions)
Expand Down Expand Up @@ -93,4 +96,3 @@
## v1.0.0

- First official release.

20 changes: 13 additions & 7 deletions PrepareRelease.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Function Test()

if (!$proc.ExitCode.Equals(0))
{
Write-Host "Tests failed. See junit-result.xml" -ForegroundColor Red
Write-Host "Tests failed. See junit-result-*.xml" -ForegroundColor Red
Exit 2
}
}
Expand All @@ -40,24 +40,29 @@ Function PackNuGet ()

$nuget = Join-Path $solutionDir '.nuget\nuget.exe'

$innerServerProjectDir = Join-Path $solutionDir 'Winium.StoreApps.InnerServer'
$innerServerprojectPath = Join-Path $innerServerProjectDir 'Winium.StoreApps.InnerServer.csproj'
$storeappsInnerServerProjectDir = Join-Path $solutionDir 'Winium.StoreApps.InnerServer'
$storeappsInnerServerProjectPath = Join-Path $storeappsInnerServerProjectDir 'Winium.StoreApps.InnerServer.csproj'
&$nuget ('pack', $storeappsInnerServerProjectPath, '-IncludeReferencedProjects', '-Properties', 'Configuration=Release', '-OutputDirectory', $releaseDir)

&$nuget ('pack', $innerServerprojectPath, '-IncludeReferencedProjects', '-Properties', 'Configuration=Release', '-OutputDirectory', $releaseDir)
$silverlightInnerServerProjectDir = Join-Path $solutionDir 'Winium.Silverlight.InnerServer'
$silverlightInnerServerProjectPath = Join-Path $silverlightInnerServerProjectDir 'Winium.Silverlight.InnerServer.csproj'
&$nuget ('pack', $silverlightInnerServerProjectPath, '-IncludeReferencedProjects', '-Properties', 'Configuration=Release', '-OutputDirectory', $releaseDir)
}

Function PackRelease()
{
Add-Type -assembly "system.io.compression.filesystem"

$driverSourcePath = Join-Path $solutionDir "Winium.StoreApps.Driver\bin\x86\Release"
$innerServerSourcePath = Join-Path $solutionDir "Winium.StoreApps.InnerServer\bin\Release"
$storeappsInnerServerSourcePath = Join-Path $solutionDir "Winium.StoreApps.InnerServer\bin\Release"
$silverlightInnerServerSourcePath = Join-Path $solutionDir "Winium.Silverlight.InnerServer\bin\Release"
$inspectorSourcePath = Join-Path $solutionDir "Winium.StoreApps.Inspector\bin\Release"

Get-ChildItem -Path $releaseDir -Filter "*.zip" | foreach ($_) { Remove-Item $_.FullName }

[IO.Compression.ZipFile]::CreateFromDirectory($driverSourcePath, "$releaseDir/Winium.StoreApps.Driver.zip")
[IO.Compression.ZipFile]::CreateFromDirectory($innerServerSourcePath, "$releaseDir/Winium.StoreApps.InnerServer.zip")
[IO.Compression.ZipFile]::CreateFromDirectory($storeappsInnerServerSourcePath, "$releaseDir/Winium.StoreApps.InnerServer.zip")
[IO.Compression.ZipFile]::CreateFromDirectory($silverlightInnerServerSourcePath, "$releaseDir/Winium.Silverlight.InnerServer.zip")
[IO.Compression.ZipFile]::CreateFromDirectory($inspectorSourcePath, "$releaseDir/Winium.StoreApps.Inspector.zip")
}

Expand All @@ -78,6 +83,7 @@ PackNuGet
PackRelease

Write-Host "Finished" -ForegroundColor Green
Write-Host "Publish NuGet package using nuget.exe push $releaseDir\Winium.StoreApps.InnerServer.*.nupkg"
Write-Host "Publish Winium.StoreApps NuGet package using nuget.exe push $releaseDir\Winium.StoreApps.InnerServer.*.nupkg"
Write-Host "Publish Winium.Silverlight NuGet package using nuget.exe push $releaseDir\Winium.Silverlight.InnerServer.*.nupkg"
Write-Host "Add and push tag using git tag -a v*.*.* -m 'Version *.*.*'"
Write-Host "Upload and attach $releaseDir\*.zip files to release"
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ English description | <a href="README_RU.md">Описание на русско
<img src="https://raw.githubusercontent.com/2gis/Winium.StoreApps/assets/winium.png" alt="Winium.StoreApps is Selenium Remote WebDriver implementation for automated testing of Windows Store apps">
</p>

Winium.StoreApps is an open source test automation tool for Windows Store apps, tested on emulators (currently it supports only testing of Windows Phone apps).
Winium.StoreApps is an open source test automation tool for both Windows Store apps and Windwos Silverlight apps tested on emulators.

## Supported Platforms
- Windows Phone 8.1
- Windows Phone 8.1 (StoreApps and Silverlight)
- Windows 10 Mobile

For Windows Phone 8 Silverlight test automation tool see [Windows Phone Driver](https://github.com/2gis/winphonedriver).
For Windows Desktop (WPF, WinForms) test automation tool see [Winium Desktop](https://github.com/2gis/cruciatus).

## Why Winium?
Expand All @@ -36,36 +35,48 @@ You can get Visual Studio and SDK from Microsoft [here](https://dev.windows.com/
## Quick Start
**App under test (AUT)** is application that you would like to test.

1. Add reference to `Winium.StoreApps.InnerServer` in AUT project ([install NuGet package](https://www.nuget.org/packages/Winium.StoreApps.InnerServer/) or build project yourself)
1. Add reference to either `Winium.StoreApps.InnerServer` or `Winium.Silverlight.InnerServer` in AUT project ([install Winium.StoreApps.InnerServer NuGet package](https://www.nuget.org/packages/Winium.StoreApps.InnerServer/) / [install Winium.Silverlight.InnerServer NuGet package](https://www.nuget.org/packages/Winium.Silverlight.InnerServer/) or build project yourself)

2. In your AUT's source code add following lines to be called on UI thread after visual root is initialized (usually in `MainPageOnLoaded` for vanilla app or `PrepareApplication` if you use `Caliburn.Micro`)

```cs
// For StoreApps
AutomationServer.Instance.InitializeAndStart();

// For Silverlight apps
AutomationServer.Instance.InitializeAndStart(RootFrame);
```

or (will include driver only for debug build)

```cs
#if DEBUG
// For StoreApps
AutomationServer.Instance.InitializeAndStart();

// For Silverlight apps
AutomationServer.Instance.InitializeAndStart(RootFrame);
#endif // DEBUG
```
3. Assure that `Internet (Client & Server)` capability is enabled in package manifest of your AUT. It should be enabled by default for Windows 8.1 apps. In UWP (Windows Mobile 10) it is disabled by default (only `Internet (Client)` is enabled).

4. Write your tests using you favorite language. In your tests use `app` [desired capability](https://github.com/2gis/Winium.StoreApps/wiki/Capabilities) to set path to tested app's appx file. Here is python example:
```python
# put it in setUp
self.driver = webdriver.Remote(command_executor='http://localhost:9999',
desired_capabilities={'app': 'C:\\testApp.appx'})
app_path = 'C:\\path\\to\\testApp.appx' # For StoreApps
app_path = 'C:\\path\\to\\testApp.xap' # For Silverlight apps
self.driver = webdriver.Remote(
command_executor='http://localhost:9999',
desired_capabilities={'app': app_path}
)
# put it in test method body
element = self.driver.find_element_by_id('SetButton')
element.click()
assert 'CARAMBA' == self.driver.find_element_by_id('MyTextBox').text
```
> Make sure to set `deviceName` capability to `Emulator` if you are using the driver on a system where Visula Studio 2015 or Winodws 10 SDK is installed.

5. Start `Winium.StoreApps.Driver.exe` ([download release from github](https://github.com/2gis/Winium.StoreApps/releases) or build it yourself)
5. Start `Winium.Mobile.Driver.exe` ([download release from github](https://github.com/2gis/Winium.StoreApps/releases) or build it yourself)

6. Run your tests and watch the magic happening

Expand All @@ -79,9 +90,9 @@ For test samples look at [our functional tests](Winium/TestApp.Test/py-functiona
## How it works
Winium.StoreApps consists of two essential parts:

1. **Winium.StoreApps.Driver** implements Selenium Remote WebDriver and listens for JsonWireProtocol commands. It is responsible for launching emulator, deploying AUT, simulating input, forwarding commands to `Winium.StoreApps.InnerServer`, etc.
1. **Winium.Mobile.Driver** implements Selenium Remote WebDriver and listens for JsonWireProtocol commands. It is responsible for launching emulator, deploying AUT, simulating input, forwarding commands to `Winium.StoreApps.InnerServer`, etc.

2. **Winium.StoreApps.InnerServer** (the one that should be embedded into AUT) communicates with `Winium.StoreApps.Driver.exe` and executes different commands, like finding elements, getting or setting text values, properties, etc., inside your application.
2. **Winium.StoreApps.InnerServer** / **Winium.Silverlight.InnerServer** (the one that should be embedded into AUT) communicates with `Winium.Mobile.Driver.exe` and executes different commands, like finding elements, getting or setting text values, properties, etc., inside your application.

<p align="center">
<img src="https://raw.githubusercontent.com/2gis/Winium.StoreApps/assets/winium-storeapps-struct.png" alt="Winium.StoreApps structure">
Expand Down
33 changes: 22 additions & 11 deletions README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
<img src="https://raw.githubusercontent.com/2gis/Winium.StoreApps/assets/winium.png" alt="Winium.StoreApps это реализация Selenium Remote WebDriver для автоматизации тестирования Windows Store приложений">
</p>

Winium.StoreApps это open-source инструмент для автоматизации Windows Store приложений, тестируемых на эмуляторах (пока поддерживаются только Windows Phone приложения).
Winium.StoreApps это open-source инструмент для автоматизации как Windows Store, так и Silverlight приложений тестируемых на эмуляторах.

## Поддерживаемые платформы
- Windows Phone 8.1
- Windows Phone 8.1 (Windows Store и Silverlight)
- Windows 10 Mobile

Для автоматизации Windows Phone 8 Silverlight есть [Windows Phone Driver](https://github.com/2gis/winphonedriver).
Для автоматизации Windows Desktop (WPF, WinForms) есть [Winium Desktop](https://github.com/2gis/Winium.Desktop).

## Почему Winium?
Expand All @@ -34,19 +33,27 @@ Winium.StoreApps это open-source инструмент для автомати
Вы можете взять Visual Studio и SDK с сайта Microsoft [здесь](https://dev.windows.com/en-us/develop/download-phone-sdk).

## Быстрый старт
1. Добавить ссылку на `Winium.StoreApps.InnerServer` в проекте тестируемого приложения ([через NuGet пакет](https://www.nuget.org/packages/Winium.StoreApps.InnerServer/) или соберите проект у себя)
1. Добавить ссылку на `Winium.StoreApps.InnerServer` или на `Winium.Silverlight.InnerServer` в проекте тестируемого приложения ([через NuGet пакет для Windows Store](https://www.nuget.org/packages/Winium.StoreApps.InnerServer/) / [через NuGet пакет для Silverlight](https://www.nuget.org/packages/Winium.Silverlight.InnerServer/) или соберите проект у себя)

2. В тестовом приложении добавьте следующий код для исполнения на UI потоке после того, как был создан коде где корневой элемент визуального дерева (обычно в `MainPageOnLoaded` для чистых приложений или в `PrepareApplication`, если вы используете `Caliburn.Micro`)

```cs
AutomationServer.Instance.InitializeAndStart(Frame);
// Для Windows Store приложения
AutomationServer.Instance.InitializeAndStart();

// Для Silverlight приложения
AutomationServer.Instance.InitializeAndStart(RootFrame);
```

или (если вы хотите включить драйвер только при debug сборке)

```cs
#if DEBUG
AutomationServer.Instance.InitializeAndStart(Frame);
// Для Windows Store приложения
AutomationServer.Instance.InitializeAndStart();

// Для Silverlight приложения
AutomationServer.Instance.InitializeAndStart(RootFrame);
#endif // DEBUG
```

Expand All @@ -55,15 +62,19 @@ Winium.StoreApps это open-source инструмент для автомати
4. Пишите тесты на удобном языке. В тесте используйте `app` [desired capability](https://github.com/2gis/Winium.StoreApps/wiki/Capabilities) для задания пакета (appx) приложения. Это пример на python:
```python
# put it in setUp
self.driver = webdriver.Remote(command_executor='http://localhost:9999',
desired_capabilities={'app': 'C:\\testApp.appx'})
app_path = 'C:\\path\\to\\testApp.appx' # For StoreApps
app_path = 'C:\\path\\to\\testApp.xap' # For Silverlight apps
self.driver = webdriver.Remote(
command_executor='http://localhost:9999',
desired_capabilities={'app': app_path}
)
# put it in test method body
element = self.driver.find_element_by_id('SetButton')
element.click()
assert 'CARAMBA' == self.driver.find_element_by_id('MyTextBox').text
```

5. Запустите `Winium.StoreApps.Driver.exe` ([загрузить последнюю версию с github](https://github.com/2gis/Winium.StoreApps/releases) или соберите проект у себя)
5. Запустите `Winium.Mobile.Driver.exe` ([загрузить последнюю версию с github](https://github.com/2gis/Winium.StoreApps/releases) или соберите проект у себя)

6. Запустите тесты и балдейте от происходящей магии

Expand All @@ -74,9 +85,9 @@ Winium.StoreApps это open-source инструмент для автомати
## Как это работает
Winium.StoreApps состоит из двух основных частей:

1. **Winium.StoreApps.Driver** реализует Selenium Remote WebDriver и слушает команды в формате JsonWireProtocol. Он отвечает за запуск эмулятора, деплой тестируемого приложения, эмуляцию ввода, перенаправление команд в `Winium.StoreApps.InnerServer`, и т.д.
1. **Winium.Mobile.Driver** реализует Selenium Remote WebDriver и слушает команды в формате JsonWireProtocol. Он отвечает за запуск эмулятора, деплой тестируемого приложения, эмуляцию ввода, перенаправление команд в `Winium.StoreApps.InnerServer`, и т.д.

2. **Winium.StoreApps.InnerServer** (должен быть встроен в тестируемое приложение) взаимодействует с `Winium.StoreApps.Driver.exe` и исполняет различные команды, например поиск элементов, задание и установку текстовых значений, свойств, и т.д.
2. **Winium.StoreApps.InnerServer** / **Winium.Silverlight.InnerServer** (должен быть встроен в тестируемое приложение) взаимодействует с `Winium.Mobile.Driver.exe` и исполняет различные команды, например поиск элементов, задание и установку текстовых значений, свойств, и т.д.

<p align="center">
<img src="https://raw.githubusercontent.com/2gis/Winium.StoreApps/assets/winium-storeapps-struct.png" alt="Winium.StoreApps structure">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Microsoft.Phone.Tools.Deploy.Patched")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
3 changes: 2 additions & 1 deletion Winium/NugetPublish.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ REM delete existing nuget packages
del *.nupkg
set NUGET=.\.nuget\nuget.exe
%NUGET% pack .\Winium.StoreApps.InnerServer\Winium.StoreApps.InnerServer.csproj -IncludeReferencedProjects -Prop Configuration=Release
%NUGET% pack .\Winium.Silverlight.InnerServer\Winium.Silverlight.InnerServer.csproj -IncludeReferencedProjects -Prop Configuration=Release
pause
%NUGET% push *.nupkg
%NUGET% push *.nupkg
20 changes: 20 additions & 0 deletions Winium/TestApp.Silverlight/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Application
x:Class="TestApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">

<!--Application Resources-->
<Application.Resources>
<local:LocalizedStrings xmlns:local="clr-namespace:TestApp" x:Key="LocalizedStrings"/>
</Application.Resources>

<Application.ApplicationLifetimeObjects>
<!--Required object that handles lifetime events for the application-->
<shell:PhoneApplicationService
Launching="Application_Launching" Closing="Application_Closing"
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
</Application.ApplicationLifetimeObjects>

</Application>
Loading

0 comments on commit 2f18645

Please sign in to comment.