Skip to content

Implemented JDISteps for UIElement. #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions JDI.Light/JDI.BDD/JDI.BDD.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EC89BF8B-AC29-4E27-A8F4-6E356BC17778}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>JDI.BDD</RootNamespace>
<AssemblyName>JDI.BDD</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BoDi, Version=1.4.1.0, Culture=neutral, PublicKeyToken=ff7cd5ea2744b496, processorArchitecture=MSIL">
<HintPath>..\packages\BoDi.1.4.1\lib\net45\BoDi.dll</HintPath>
</Reference>
<Reference Include="Cucumber.Messages, Version=6.0.1.0, Culture=neutral, PublicKeyToken=b10c5988214f940c, processorArchitecture=MSIL">
<HintPath>..\packages\Cucumber.Messages.6.0.1\lib\net45\Cucumber.Messages.dll</HintPath>
</Reference>
<Reference Include="Gherkin, Version=6.0.0.0, Culture=neutral, PublicKeyToken=86496cfa5b4a5851, processorArchitecture=MSIL">
<HintPath>..\packages\Gherkin.6.0.0\lib\net45\Gherkin.dll</HintPath>
</Reference>
<Reference Include="Google.Protobuf, Version=3.7.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.7.0\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.4.0\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="TechTalk.SpecFlow, Version=3.3.0.0, Culture=neutral, PublicKeyToken=0778194805d6db41, processorArchitecture=MSIL">
<HintPath>..\packages\SpecFlow.3.3.16-beta\lib\net45\TechTalk.SpecFlow.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StepDefs\JDISteps.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\JDI.Light\JDI.Light.csproj">
<Project>{abaf27b0-bfde-4fec-b93e-15b595fa77aa}</Project>
<Name>JDI.Light</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\SpecFlow.3.3.16-beta\build\SpecFlow.targets" Condition="Exists('..\packages\SpecFlow.3.3.16-beta\build\SpecFlow.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\SpecFlow.3.3.16-beta\build\SpecFlow.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SpecFlow.3.3.16-beta\build\SpecFlow.targets'))" />
</Target>
</Project>
36 changes: 36 additions & 0 deletions JDI.Light/JDI.BDD/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("JDI.BDD")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("EPAM Systems")]
[assembly: AssemblyProduct("JDI.BDD")]
[assembly: AssemblyCopyright("Copyright © EPAM Systems 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ec89bf8b-ac29-4e27-a8f4-6e356bc17778")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
46 changes: 46 additions & 0 deletions JDI.Light/JDI.BDD/StepDefs/CheckBoxSteps.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using JDI.Light.Elements.Init;
using TechTalk.SpecFlow;
using JDI.Light.Elements.Common;

namespace JDI.BDD.StepDefs
{
[Binding]
public class CheckBoxSteps
{
[When(@"I check (.*)")]
public void Check(string name)
{
EntitiesCollection.GetWebElement<CheckBox>(name).Check();
}

[When(@"I uncheck (.*)")]
public void Uncheck(string name)
{
EntitiesCollection.GetWebElement<CheckBox>(name).Uncheck();
}

[Then(@"the (.*) is checked")]
public void IsChecked(string name)
{
EntitiesCollection.GetWebElement<CheckBox>(name).Is.Selected();
}

[Then(@"the (.*) is not checked")]
public void IsNotChecked(string name)
{
EntitiesCollection.GetWebElement<CheckBox>(name).Is.Deselected();
}

[Then(@"the (.*) is enabled")]
public void IsEnabled(string name)
{
EntitiesCollection.GetWebElement<CheckBox>(name).Is.Enabled();
}

[Then(@"the (.*) is displayed")]
public void IsDisplayed(string name)
{
EntitiesCollection.GetWebElement<CheckBox>(name).Is.Displayed();
}
}
}
125 changes: 125 additions & 0 deletions JDI.Light/JDI.BDD/StepDefs/JDISteps.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
using JDI.Light.Elements.Base;
using JDI.Light.Elements.Init;
using TechTalk.SpecFlow;
using static JDI.Light.Jdi;
using static JDI.Light.Matchers.StringMatchers.EqualToMatcher;
using static JDI.Light.Matchers.StringMatchers.ContainsStringMatcher;

namespace JDI.BDD.StepDefs
{
[Binding]
public class JDISteps
{

#region WHEN
[When(@"I send keys (.*) to (.*)")]
public void SendKeys(string value, string name)
{
EntitiesCollection.GetWebElement<UIElement>(name).SendKeys(value);
}

[When(@"I click on (.*)")]
public void Click(string name)
{
EntitiesCollection.GetWebElement<UIElement>(name).Click();
}

[When(@"I highlight (.*)")]
public void Highlight(string name)
{
EntitiesCollection.GetWebElement<UIElement>(name).Highlight();
}

[When(@"I set (.*) attribute (.*) with value (.*) element")]
public void SetAttribute(string name, string attrName, string attrValue)
{
EntitiesCollection.GetWebElement<UIElement>(name).SetAttribute(attrName, attrValue);
}

[When(@"I clear (.*)")]
public void Clear(string name)
{
EntitiesCollection.GetWebElement<UIElement>(name).Clear();
}

[When(@"I submit (.*)")]
public void Submit(string name)
{
EntitiesCollection.GetWebElement<UIElement>(name).Submit();
}

[When(@"I show (.*)")]
public void Show(string name)
{
EntitiesCollection.GetWebElement<UIElement>(name).Show();
}

#endregion

[Then(@"the (.*) is disabled")]
public void IsDisabled(string name)
{
Assert.IsTrue(EntitiesCollection.GetWebElement<UIElement>(name).Disabled);
}

[Then(@"the (.*) is enabled")]
public void IsEnabled(string name)
{
Assert.IsTrue(EntitiesCollection.GetWebElement<UIElement>(name).Enabled);
}

[Then(@"the (.*) is enabled")]
public void IsDisplayed(string name)
{
Assert.IsTrue(EntitiesCollection.GetWebElement<UIElement>(name).Displayed);
}

[Then(@"the (.*) is hidden")]
public void IsHidden(string name)
{
Assert.IsTrue(EntitiesCollection.GetWebElement<UIElement>(name).Hidden);
}

[Then(@"the (.*) is selected")]
public void IsSelected(string name)
{
Assert.IsTrue(EntitiesCollection.GetWebElement<UIElement>(name).Selected);
}

[Then(@"the (.*) text equals to (.*)")]
public void TextEquals(string name, string value)
{
EntitiesCollection.GetWebElement<UIElement>(name).Is.Text(EqualTo(value));
}

[Then(@"the (.*) text contains (.*)")]
public void TextContains(string name, string value)
{
EntitiesCollection.GetWebElement<UIElement>(name).Is.Text(ContainsString(value));
}

[Then(@"the (.*) attribute (.*) equals to (.*)")]
public void AttributeEquals(string name, string attrName, string attrValue)
{
EntitiesCollection.GetWebElement<UIElement>(name).Is.Attr(attrName, EqualTo(attrValue));
}

[Then(@"the (.*) attribute (.*) contains (.*)")]
public void AttributeContains(string name, string attrName, string attrValue)
{
EntitiesCollection.GetWebElement<UIElement>(name).Is.Attr(attrName, ContainsString(attrValue));
}

[Then(@"the (.*) css (.*) equals to (.*)")]
public void CssEquals(string name, string css, string cssValue)
{
EntitiesCollection.GetWebElement<UIElement>(name).Is.Css(css, EqualTo(cssValue));
}

[Then(@"the (.*) css (.*) contains (.*)")]
public void CssContains(string name, string css, string cssValue)
{
EntitiesCollection.GetWebElement<UIElement>(name).Is.Css(css, ContainsString(cssValue));
}
}
}
19 changes: 19 additions & 0 deletions JDI.Light/JDI.BDD/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BoDi" version="1.4.1" targetFramework="net472" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be it's better to use one .net version?

<package id="Cucumber.Messages" version="6.0.1" targetFramework="net472" />
<package id="Gherkin" version="6.0.0" targetFramework="net472" />
<package id="Google.Protobuf" version="3.7.0" targetFramework="net472" />
<package id="SpecFlow" version="3.3.16-beta" targetFramework="net472" />
<package id="System.IO" version="4.3.0" targetFramework="net472" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net472" />
<package id="System.Reflection.Emit" version="4.3.0" targetFramework="net472" />
<package id="System.Reflection.Emit.Lightweight" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.4.0" targetFramework="net472" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net472" />
</packages>
10 changes: 8 additions & 2 deletions JDI.Light/JDI.Light.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2016
# Visual Studio Version 16
VisualStudioVersion = 16.0.29418.71
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JDI.Light", "JDI.Light\JDI.Light.csproj", "{ABAF27B0-BFDE-4FEC-B93E-15B595FA77AA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JDI.Light.Tests", "JDI.Light.Tests\JDI.Light.Tests.csproj", "{73E43896-6A55-45B2-B831-0D9E48ED4031}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JDI.BDD", "JDI.BDD\JDI.BDD.csproj", "{EC89BF8B-AC29-4E27-A8F4-6E356BC17778}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +23,10 @@ Global
{73E43896-6A55-45B2-B831-0D9E48ED4031}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73E43896-6A55-45B2-B831-0D9E48ED4031}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73E43896-6A55-45B2-B831-0D9E48ED4031}.Release|Any CPU.Build.0 = Release|Any CPU
{EC89BF8B-AC29-4E27-A8F4-6E356BC17778}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC89BF8B-AC29-4E27-A8F4-6E356BC17778}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC89BF8B-AC29-4E27-A8F4-6E356BC17778}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC89BF8B-AC29-4E27-A8F4-6E356BC17778}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading