Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit b2c85d50 authored by Harald Martini's avatar Harald Martini
Browse files

removed Coded UI tests

parent 06bbd3ba
No related branches found
No related tags found
No related merge requests found
using System;
using System.Diagnostics;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;
namespace Vecto3GUI2020Test
{
public class DesktopSession
{
private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723/";
WindowsDriver<WindowsElement> desktopSession;
public DesktopSession()
{
var process = Process.Start(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe");
var appCapabilities = new AppiumOptions();
appCapabilities.AddAdditionalCapability("app", "Root");
appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC");
desktopSession = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
}
~DesktopSession()
{
desktopSession.Quit();
}
public WindowsDriver<WindowsElement> DesktopSessionElement
{
get { return desktopSession; }
}
public WindowsElement FindElementByAbsoluteXPath(string xPath, int nTryCount = 15)
{
WindowsElement uiTarget = null;
while (nTryCount-- > 0) {
try {
uiTarget = desktopSession.FindElementByXPath(xPath);
} catch {
}
if (uiTarget != null) {
break;
} else {
System.Threading.Thread.Sleep(200);
}
}
return uiTarget;
}
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Appium.Windows;
using OpenQA.Selenium.Interactions;
using Vecto3GUI2020Test.UI;
namespace Vecto3GUI2020Test
{/// <summary>
/// The Application under Test has to run on a Windows 10 Machine on a Desktop called "VE
/// </summary>
///
[Ignore("GUI tests are not working that good")]
[TestFixture]
public class UITests : VECTO3GUI2020Session
{
[SetUp]
public void Setup()
{
Setup(TestContext.CurrentContext);
}
[Ignore("ignored UI test")]
[Test]
public void LoadFileSession()
{
session.FindElementByXPath(
"//Button[@Name=\"New Multistage File\"][@AutomationId=\"JobListViewNewManufacturingStageFileButton\"]").Click(); //open new multistageWindow
session.SwitchTo().Window(session.WindowHandles.Last());
Assert.AreEqual(2, session.WindowHandles.Count);
session.FindElementByXPath(
".//Custom[@AutomationId=\"NewMultistageJobView\"]/Custom[@AutomationId=\"NewMultistageFilePicker\"]/Button[@AutomationId=\"button\"]").Click();
Assert.AreEqual(3, session.WindowHandles);
Thread.Sleep(100000);
}
#region DesktopSessionTests
//[Ignore("disabled Desktop Session tests")]
//[Test]
//public void LoadFile()
//{
// LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_multiple_stages.xml");
//}
//[Ignore("disabled Desktop Session tests")]
//[Test]
//public void LoadFileAirdrag()
//{
// LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_multiple_stages_airdrag.xml");
//}
//[Ignore("disabled Desktop Session tests")]
//[Test]
//public void LoadFileheatPump()
//{
// LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_multiple_stages_heatPump.xml");
//}
//[Ignore("disabled Desktop Session tests")]
//[Test]
//public void LoadFilehev()
//{
// LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_multiple_stages_hev.xml");
//}
//[Ignore("disabled Desktop Session tests")]
//[Test]
//public void LoadFileNGTankSystem()
//{
// LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_multiple_stages_NGTankSystem.xml");
//}
//[Ignore("disabled Desktop Session tests")]
//[Test]
//public void LoadFileConsolidatedOneStage()
//{
// LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_one_stage.xml");
//}
//[Ignore("disabled Desktop Session tests")]
//[Test]
//public void LoadFileConsolidatedTwoStages()
//{
// LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_two_stages.xml");
//}
//[Ignore("disabled Desktop Session tests")]
//[Test]
//public void LoadFilePrimaryVehicleOnly()
//{
// LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_primary_vehicle_only.xml");
//}
//[Ignore("disabled Desktop Session tests")]
//[Test]
//public void LoadFilePrimaryVehicleStage_2_3()
//{
// LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_consolidated_one_stage.xml");
//}
//[Ignore("disabled Desktop Session tests")]
//[Test]
//public void LoadFilePrimaryVehicleOnlyAndCheckFields()
//{
// LoadFileThroughUIWithDesktopSession(fileName: "vecto_multistage_primary_vehicle_only.xml");
// //Check vehicle fields
// SelectVehicleTab();
// focusToActiveWindow();
// //var element = session.FindElementByXPath()
//}
//private void LoadFileThroughUIWithDesktopSession(string fileName)
//{
// // LeftClick on Button "New Multistage File" at (65,28)
// // LeftClick on Button "New Multistage File" at (87,25)
// Console.WriteLine("LeftClick on Button \"New Multistage File\" at (87,25)");
// string xpath_LeftClickButtonNewMultist_87_25 = "/Pane[@ClassName=\"#32769\"][@Name=\"Vecto\"]/Window[@ClassName=\"Window\"][@Name=\"Vecto\"]/Custom[@ClassName=\"JobListView\"]/Button[@Name=\"New Multistage File\"][@AutomationId=\"JobListViewNewManufacturingStageFileButton\"]";
// var winElem_LeftClickButtonNewMultist_87_25 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickButtonNewMultist_87_25);
// if (winElem_LeftClickButtonNewMultist_87_25 != null)
// {
// winElem_LeftClickButtonNewMultist_87_25.Click();
// }
// else
// {
// Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickButtonNewMultist_87_25}");
// }
// Assert.NotNull(winElem_LeftClickButtonNewMultist_87_25);
// // LeftDblClick on Button "" at (11,11)
// Console.WriteLine("LeftDblClick on Button \"\" at (11,11)");
// string xpath_LeftDblClickButton_11_11 = "/Pane[@ClassName=\"#32769\"][@Name=\"Vecto\"]/Window[@ClassName=\"Window\"][starts-with(@Name,\"VECTO3GUI2020.ViewModel.MultiStage.Implementation.NewMultiStageJ\")]/Custom[@AutomationId=\"NewMultistageJobView\"]/Custom[@AutomationId=\"NewMultistageFilePicker\"]/Button[@AutomationId=\"button\"]";
// var winElem_LeftDblClickButton_11_11 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftDblClickButton_11_11);
// if (winElem_LeftDblClickButton_11_11 != null) {
// desktopSession.DesktopSessionElement.Mouse.MouseMove(winElem_LeftDblClickButton_11_11.Coordinates);
// desktopSession.DesktopSessionElement.Mouse.DoubleClick(null);
// }
// else
// {
// Console.WriteLine($"Failed to find element using xpath: {xpath_LeftDblClickButton_11_11}");
// }
// Assert.NotNull(winElem_LeftDblClickButton_11_11);
// // LeftDblClick on Edit "Name" at (284,8)
// Console.WriteLine("LeftDblClick on Edit \"Name\" at (284,8)");
// string xpath_LeftDblClickEditName_284_8 = $"/Pane[@ClassName=\"#32769\"][@Name=\"Vecto\"]/Window[@ClassName=\"Window\"][starts-with(@Name,\"VECTO3GUI2020.ViewModel.MultiStage.Implementation.NewMultiStageJ\")]/Window[@ClassName=\"#32770\"][@Name=\"Öffnen\"]/Pane[@ClassName=\"DUIViewWndClassName\"]/Pane[@Name=\"Shellordneransicht\"][@AutomationId=\"listview\"]/List[@ClassName=\"UIItemsView\"][@Name=\"Elementansicht\"]/ListItem[@ClassName=\"UIItem\"][@Name={fileName}]/Edit[@Name=\"Name\"][@AutomationId=\"System.ItemNameDisplay\"]";
// var winElem_LeftDblClickEditName_284_8 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftDblClickEditName_284_8);
// if (winElem_LeftDblClickEditName_284_8 != null)
// {
// desktopSession.DesktopSessionElement.Mouse.MouseMove(winElem_LeftDblClickEditName_284_8.Coordinates);
// desktopSession.DesktopSessionElement.Mouse.DoubleClick(null);
// }
// else
// {
// Console.WriteLine($"Failed to find element using xpath: {xpath_LeftDblClickEditName_284_8}");
// }
// Assert.NotNull(winElem_LeftDblClickEditName_284_8);
// SelectAirdragTab();
// SelectAuxiliariesTab();
// SelectVehicleTab();
// SelectAuxiliariesTab();
// SelectAirdragTab();
//}
//private void SelectVehicleTab()
//{
// // LeftClick on Text "Vehicle" at (13,14)
// Console.WriteLine("LeftClick on Text \"Vehicle\" at (13,14)");
// string xpath_LeftClickTextVehicle_13_14 = "/Pane[@ClassName=\"#32769\"][@Name=\"Vecto\"]/Window[@ClassName=\"Window\"][starts-with(@Name,\"VECTO3GUI2020.ViewModel.MultiStage.Implementation.NewMultiStageJ\")]/Custom[@AutomationId=\"NewMultistageJobView\"]/Custom[@ClassName=\"MultiStageView\"]/Custom[@ClassName=\"ManufacturingStageView\"]/Button[@ClassName=\"Button\"][@Name=\"Vehicle\"]/Text[@ClassName=\"TextBlock\"][@Name=\"Vehicle\"]";
// var winElem_LeftClickTextVehicle_13_14 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickTextVehicle_13_14);
// if (winElem_LeftClickTextVehicle_13_14 != null)
// {
// winElem_LeftClickTextVehicle_13_14.Click();
// }
// else
// {
// Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickTextVehicle_13_14}");
// }
// Assert.NotNull(winElem_LeftClickTextVehicle_13_14);
//}
//private void SelectAirdragTab()
//{
// // LeftClick on Text "Airdrag" at (21,13)
// Console.WriteLine("LeftClick on Text \"Airdrag\" at (21,13)");
// string xpath_LeftClickTextAirdrag_21_13 = "/Pane[@ClassName=\"#32769\"][@Name=\"Vecto\"]/Window[@ClassName=\"Window\"][starts-with(@Name,\"VECTO3GUI2020.ViewModel.MultiStage.Implementation.NewMultiStageJ\")]/Custom[@AutomationId=\"NewMultistageJobView\"]/Custom[@ClassName=\"MultiStageView\"]/Custom[@ClassName=\"ManufacturingStageView\"]/Button[@ClassName=\"Button\"][@Name=\"Airdrag\"]/Text[@ClassName=\"TextBlock\"][@Name=\"Airdrag\"]";
// var winElem_LeftClickTextAirdrag_21_13 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickTextAirdrag_21_13);
// if (winElem_LeftClickTextAirdrag_21_13 != null)
// {
// winElem_LeftClickTextAirdrag_21_13.Click();
// }
// else
// {
// Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickTextAirdrag_21_13}");
// return;
// }
// Assert.NotNull(winElem_LeftClickTextAirdrag_21_13);
//}
//private void SelectAuxiliariesTab()
//{
// // LeftClick on Button "Auxiliaries" at (9,13)
// Console.WriteLine("LeftClick on Button \"Auxiliaries\" at (9,13)");
// string xpath_LeftClickButtonAuxiliarie_9_13 = "/Pane[@ClassName=\"#32769\"][@Name=\"Vecto\"]/Window[@ClassName=\"Window\"][starts-with(@Name,\"VECTO3GUI2020.ViewModel.MultiStage.Implementation.NewMultiStageJ\")]/Custom[@AutomationId=\"NewMultistageJobView\"]/Custom[@ClassName=\"MultiStageView\"]/Custom[@ClassName=\"ManufacturingStageView\"]/Button[@ClassName=\"Button\"][@Name=\"Auxiliaries\"]";
// var winElem_LeftClickButtonAuxiliarie_9_13 = desktopSession.FindElementByAbsoluteXPath(xpath_LeftClickButtonAuxiliarie_9_13);
// if (winElem_LeftClickButtonAuxiliarie_9_13 != null)
// {
// winElem_LeftClickButtonAuxiliarie_9_13.Click();
// }
// else
// {
// Console.WriteLine($"Failed to find element using xpath: {xpath_LeftClickButtonAuxiliarie_9_13}");
// }
// Assert.NotNull(winElem_LeftClickButtonAuxiliarie_9_13);
//}
#endregion
[TearDown]
public void OneTimeTeardown()
{
TearDown();
Thread.Sleep(0);
}
private void focusToActiveWindow()
{
session.SwitchTo().ActiveElement();
}
}
}
using System;
using System.Diagnostics;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.Windows;
using System.Reflection;
using VECTO3GUI2020.Properties;
namespace Vecto3GUI2020Test.UI
{
[TestFixture]
public class VECTO3GUI2020Session
{
protected const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
private const string NotepadAppId = @"C:\Windows\System32\notepad.exe";
private static Process winappDriverProcess;
internal static WindowsDriver<WindowsElement> session;
internal static DesktopSession desktopSession;
public WindowsDriver<WindowsElement> DesktopSessionElement
{
get { return session; }
}
public static void Setup(TestContext context)
{
// Launch a new instance of VECTO application
if (session == null) {
winappDriverProcess = Process.Start(@"C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe");
// Create a new session to launch Notepad application
var appiumOptions = new OpenQA.Selenium.Appium.AppiumOptions();
appiumOptions.AddAdditionalCapability("app", @"C:\Users\Harry\source\repos\vecto-dev\VECTO3GUI2020\bin\Debug\VECTO3GUI2020.exe");
appiumOptions.AddAdditionalCapability("deviceName", "WindowsPC");
session = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appiumOptions);
session.ActivateApp(Assembly.GetExecutingAssembly().Location);
// Use the session to control the app
Assert.IsNotNull(session);
Assert.IsNotNull(session.SessionId);
// Set implicit timeout to 1.5 seconds to make element search to retry every 500 ms for at most three times
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
}
desktopSession = new DesktopSession();
}
public static void TearDown()
{
// Close the application and delete the session
if (session != null)
{
session.CloseApp();
winappDriverProcess.Kill();
session = null;
}
}
public void TestInitialize()
{
// Select all text and delete to clear the edit box
}
protected static string SanitizeBackslashes(string input) => input.Replace("\\", Keys.Alt + Keys.NumberPad9 + Keys.NumberPad2 + Keys.Alt);
}
public static class SessionExtensions{
public static void DoubleCLick(this WindowsElement element)
{
element.Click();
element.Click();
}
}
}
......@@ -7,6 +7,8 @@
<ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="4.3.1" />
<PackageReference Include="AutoBogus.Moq" Version="2.13.1" />
<PackageReference Include="Bogus" Version="34.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="Moq" Version="4.18.2" />
......@@ -30,11 +32,29 @@
<ItemGroup>
<Folder Include="HelperTests\" />
<Folder Include="Testdata\bugreports\" />
<Folder Include="TestData\bugreports\" />
<Folder Include="TestData\output\" />
<Folder Include="XML\XMLInput\" />
<Folder Include="XML\XMLWritingTest\TestDataCreator\" />
</ItemGroup>
<ItemGroup>
<Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\**\*.*">
<Link>TestData\XML\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\VectoCore\VectoCoreTest\TestData\Integration\Multistage\**\*.*">
<Link>TestData\Integration\Multistage\%(RecursiveDir)%(FileName)%(Extension)</Link>
<!--<TargetPath>TestData\Integration\Multistage</TargetPath>-->
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<!--<Content Remove="..\VectoCore\VectoCoreTest\TestData\Integration\Multistage\newVifCompletedConventional.vecto" />
<Content Remove="..\VectoCore\VectoCoreTest\TestData\Integration\Multistage\newVifExempted.vecto" />
<Content Remove="..\VectoCore\VectoCoreTest\TestData\Integration\Multistage\newVifExemptedIncomplete.vecto" />
<Content Remove="..\VectoCore\VectoCoreTest\TestData\Integration\Multistage\newVifInterimDiesel.vecto" />-->
<Content Include="..\VectoCore\VectoCoreTest\TestData\XML\XMLReaderDeclaration\SchemaVersionMultistage.0.1\AidragComponent.xml" Link="Testdata\AidragComponent.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
......@@ -95,34 +115,49 @@
<None Update="TestData\bugreports\PrimaryDecimal\primary_heavyBus group41_nonSmart_rounded_decimals.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\exempted_primary_heavyBus.VIF.xml">
<None Update="TestData\Case1\newVifExemptedIncomplete.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\exempted_vif_mandatory.xml">
<None Update="TestData\Case1\newVifInterimDiesel.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\final.VIF_Report_4.xml">
<None Update="TestData\Case1\special_case_1.vecto">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\Case1\vecto_vehicle-primary_heavyBus-sample.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\Case1\vecto_vehicle-stage_input_only_certain_entries01-sample.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\Case2\newVifCompletedConventional-noADAS.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\interim2.VIF_Report_3.xml">
<None Update="TestData\Case2\newVifCompletedConventional.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\vecto_multistage_conventional_final_vif.VIF_Report_1.xml">
<None Update="TestData\Case2\newVifExempted.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\vecto_vehicle-completed_heavyBus_31b.xml">
<None Update="TestData\Case2\special_case_2.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\Case2\vecto_vehicle-stage_input_full-sample.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\exempted_primary_heavyBus.VIF.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\VectoCore\VectoCoreTest\TestData\Integration\Multistage\newVifCompletedConventional.vecto" Link="TestData\newVifCompletedConventional.vecto">
<None Update="TestData\exempted_vif_mandatory.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\VectoCore\VectoCoreTest\TestData\Integration\Multistage\newVifExempted.vecto" Link="TestData\newVifExempted.vecto">
<None Update="TestData\final.VIF_Report_4.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\VectoCore\VectoCoreTest\TestData\Integration\Multistage\newVifExemptedIncomplete.vecto" Link="TestData\newVifExemptedIncomplete.vecto">
<None Update="TestData\interim2.VIF_Report_3.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\VectoCore\VectoCoreTest\TestData\Integration\Multistage\newVifInterimDiesel.vecto" Link="TestData\newVifInterimDiesel.vecto">
<None Update="TestData\vecto_vehicle-completed_heavyBus_31b.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment