From 4724a77f32ff01649140fbde1bc593bde3d66971 Mon Sep 17 00:00:00 2001 From: Anna Belemenko Date: Tue, 26 May 2020 14:23:49 +0300 Subject: [PATCH 1/3] Implemented JDISteps for UIElement. --- JDI.Light/JDI.BDD/JDI.BDD.csproj | 125 ++++++++++++++++++ JDI.Light/JDI.BDD/Properties/AssemblyInfo.cs | 36 +++++ JDI.Light/JDI.BDD/StepDefs/JDISteps.cs | 121 +++++++++++++++++ JDI.Light/JDI.BDD/packages.config | 20 +++ JDI.Light/JDI.Light.sln | 10 +- .../Elements/Init/EntitiesCollection.cs | 8 +- 6 files changed, 314 insertions(+), 6 deletions(-) create mode 100644 JDI.Light/JDI.BDD/JDI.BDD.csproj create mode 100644 JDI.Light/JDI.BDD/Properties/AssemblyInfo.cs create mode 100644 JDI.Light/JDI.BDD/StepDefs/JDISteps.cs create mode 100644 JDI.Light/JDI.BDD/packages.config diff --git a/JDI.Light/JDI.BDD/JDI.BDD.csproj b/JDI.Light/JDI.BDD/JDI.BDD.csproj new file mode 100644 index 00000000..6a8d4135 --- /dev/null +++ b/JDI.Light/JDI.BDD/JDI.BDD.csproj @@ -0,0 +1,125 @@ + + + + + Debug + AnyCPU + {EC89BF8B-AC29-4E27-A8F4-6E356BC17778} + Library + Properties + JDI.BDD + JDI.BDD + v4.7.2 + 512 + true + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\BoDi.1.4.1\lib\net45\BoDi.dll + + + ..\packages\Cucumber.Messages.6.0.1\lib\net45\Cucumber.Messages.dll + + + ..\packages\Gherkin.6.0.0\lib\net45\Gherkin.dll + + + ..\packages\Google.Protobuf.3.7.0\lib\net45\Google.Protobuf.dll + + + + + + ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll + True + True + + + ..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll + True + True + + + ..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll + True + True + + + ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll + True + True + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + True + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + True + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + True + + + ..\packages\System.Threading.Tasks.Extensions.4.4.0\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.ValueTuple.4.4.0\lib\net47\System.ValueTuple.dll + + + + + + + + ..\packages\SpecFlow.3.3.16-beta\lib\net45\TechTalk.SpecFlow.dll + + + ..\packages\Utf8Json.1.3.7\lib\net47\Utf8Json.dll + + + + + + + + + {abaf27b0-bfde-4fec-b93e-15b595fa77aa} + JDI.Light + + + + + + + + + + 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}. + + + + \ No newline at end of file diff --git a/JDI.Light/JDI.BDD/Properties/AssemblyInfo.cs b/JDI.Light/JDI.BDD/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..3273f618 --- /dev/null +++ b/JDI.Light/JDI.BDD/Properties/AssemblyInfo.cs @@ -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")] diff --git a/JDI.Light/JDI.BDD/StepDefs/JDISteps.cs b/JDI.Light/JDI.BDD/StepDefs/JDISteps.cs new file mode 100644 index 00000000..eaf6f2ea --- /dev/null +++ b/JDI.Light/JDI.BDD/StepDefs/JDISteps.cs @@ -0,0 +1,121 @@ +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 + { + [Then(@"the (.*) is disabled")] + public void IsDisabled(string name) + { + Assert.IsTrue(EntitiesCollection.GetWebElement(name).Disabled); + } + + [Then(@"the (.*) is enabled")] + public void IsEnabled(string name) + { + Assert.IsTrue(EntitiesCollection.GetWebElement(name).Enabled); + } + + [Then(@"the (.*) is enabled")] + public void IsDisplayed(string name) + { + Assert.IsTrue(EntitiesCollection.GetWebElement(name).Displayed); + } + + [Then(@"the (.*) is hidden")] + public void IsHidden(string name) + { + Assert.IsTrue(EntitiesCollection.GetWebElement(name).Hidden); + } + + [Then(@"the (.*) is selected")] + public void IsSelected(string name) + { + Assert.IsTrue(EntitiesCollection.GetWebElement(name).Selected); + } + + [When(@"I send keys (.*) to (.*)")] + public void SendKeys(string value, string name) + { + EntitiesCollection.GetWebElement(name).SendKeys(value); + } + + [When(@"I click on (.*)")] + public void Click(string name) + { + EntitiesCollection.GetWebElement(name).Click(); + } + + [When(@"I highlight (.*)")] + public void Highlight(string name) + { + EntitiesCollection.GetWebElement(name).Highlight(); + } + + [When(@"I set (.*) attribute (.*) with value (.*) element")] + public void SetAttribute(string name, string attrName, string attrValue) + { + EntitiesCollection.GetWebElement(name).SetAttribute(attrName, attrValue); + } + + [When(@"I clear (.*)")] + public void Clear(string name) + { + EntitiesCollection.GetWebElement(name).Clear(); + } + + [When(@"I submit (.*)")] + public void Submit(string name) + { + EntitiesCollection.GetWebElement(name).Submit(); + } + + [When(@"I show (.*)")] + public void Show(string name) + { + EntitiesCollection.GetWebElement(name).Show(); + } + + [Then(@"the (.*) text equals to (.*)")] + public void TextEquals(string name, string value) + { + EntitiesCollection.GetWebElement(name).Is.Text(EqualTo(value)); + } + + [Then(@"the (.*) text contains (.*)")] + public void TextContains(string name, string value) + { + EntitiesCollection.GetWebElement(name).Is.Text(ContainsString(value)); + } + + [Then(@"the (.*) attribute (.*) equals to (.*)")] + public void AttributeEquals(string name, string attrName, string attrValue) + { + EntitiesCollection.GetWebElement(name).Is.Attr(attrName, EqualTo(attrValue)); + } + + [Then(@"the (.*) attribute (.*) contains (.*)")] + public void AttributeContains(string name, string attrName, string attrValue) + { + EntitiesCollection.GetWebElement(name).Is.Attr(attrName, ContainsString(attrValue)); + } + + [Then(@"the (.*) css (.*) equals to (.*)")] + public void CssEquals(string name, string css, string cssValue) + { + EntitiesCollection.GetWebElement(name).Is.Css(css, EqualTo(cssValue)); + } + + [Then(@"the (.*) css (.*) contains (.*)")] + public void CssContains(string name, string css, string cssValue) + { + EntitiesCollection.GetWebElement(name).Is.Css(css, ContainsString(cssValue)); + } + } +} diff --git a/JDI.Light/JDI.BDD/packages.config b/JDI.Light/JDI.BDD/packages.config new file mode 100644 index 00000000..3af7b1f8 --- /dev/null +++ b/JDI.Light/JDI.BDD/packages.config @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/JDI.Light/JDI.Light.sln b/JDI.Light/JDI.Light.sln index dcc51e47..0e347191 100644 --- a/JDI.Light/JDI.Light.sln +++ b/JDI.Light/JDI.Light.sln @@ -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 @@ -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 diff --git a/JDI.Light/JDI.Light/Elements/Init/EntitiesCollection.cs b/JDI.Light/JDI.Light/Elements/Init/EntitiesCollection.cs index 0a2bdefb..d350d885 100644 --- a/JDI.Light/JDI.Light/Elements/Init/EntitiesCollection.cs +++ b/JDI.Light/JDI.Light/Elements/Init/EntitiesCollection.cs @@ -17,7 +17,7 @@ protected EntitiesCollection() public static Dictionary Pages { get; set; } = new Dictionary(); public static Dictionary> Elements { get; set; } = new Dictionary>(); - public static T GetPage(string pageName, T type) + public static T GetPage(string pageName) { var page = GetPage(pageName); if (page != null) @@ -28,7 +28,7 @@ public static T GetPage(string pageName, T type) } else { - throw new InvalidCastException($"Can't cast element {page.GetType()} to {type}"); + throw new InvalidCastException($"Can't cast element {page.GetType()} to {nameof(T)}"); } } throw new ElementNotFoundException($"No page found with name {pageName}"); @@ -72,7 +72,7 @@ public static IBaseElement GetWebElement(string elementName) } } - public static T GetWebElement(string elementName, T type) + public static T GetWebElement(string elementName) { var foundElement = GetWebElement(elementName); if (foundElement != null) @@ -83,7 +83,7 @@ public static T GetWebElement(string elementName, T type) } else { - throw new InvalidCastException($"Can't cast element {foundElement.GetType()} to {type}"); + throw new InvalidCastException($"Can't cast element {foundElement.GetType()} to {nameof(T)}"); } } throw new ElementNotFoundException($"No entity were found with name {elementName}"); From ffccca2a0a16c8a4af37836b80ab6d0c7aae0c74 Mon Sep 17 00:00:00 2001 From: Vladimir Vdovichenko Date: Tue, 2 Jun 2020 15:04:29 +0300 Subject: [PATCH 2/3] remove unlicensed dependency - Utf8Json --- JDI.Light/JDI.BDD/JDI.BDD.csproj | 3 --- JDI.Light/JDI.BDD/packages.config | 1 - 2 files changed, 4 deletions(-) diff --git a/JDI.Light/JDI.BDD/JDI.BDD.csproj b/JDI.Light/JDI.BDD/JDI.BDD.csproj index 6a8d4135..ebe075cb 100644 --- a/JDI.Light/JDI.BDD/JDI.BDD.csproj +++ b/JDI.Light/JDI.BDD/JDI.BDD.csproj @@ -97,9 +97,6 @@ ..\packages\SpecFlow.3.3.16-beta\lib\net45\TechTalk.SpecFlow.dll - - ..\packages\Utf8Json.1.3.7\lib\net47\Utf8Json.dll - diff --git a/JDI.Light/JDI.BDD/packages.config b/JDI.Light/JDI.BDD/packages.config index 3af7b1f8..e27ef0ac 100644 --- a/JDI.Light/JDI.BDD/packages.config +++ b/JDI.Light/JDI.BDD/packages.config @@ -16,5 +16,4 @@ - \ No newline at end of file From 172ed2b9e8899bf95a09127682d7da0779e563af Mon Sep 17 00:00:00 2001 From: Vladimir Vdovichenko Date: Fri, 5 Jun 2020 15:14:13 +0300 Subject: [PATCH 3/3] BDD CheckBoxSteps --- JDI.Light/JDI.BDD/StepDefs/CheckBoxSteps.cs | 46 +++++++++++++++ JDI.Light/JDI.BDD/StepDefs/JDISteps.cs | 62 +++++++++++---------- 2 files changed, 79 insertions(+), 29 deletions(-) create mode 100644 JDI.Light/JDI.BDD/StepDefs/CheckBoxSteps.cs diff --git a/JDI.Light/JDI.BDD/StepDefs/CheckBoxSteps.cs b/JDI.Light/JDI.BDD/StepDefs/CheckBoxSteps.cs new file mode 100644 index 00000000..5d4908ac --- /dev/null +++ b/JDI.Light/JDI.BDD/StepDefs/CheckBoxSteps.cs @@ -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(name).Check(); + } + + [When(@"I uncheck (.*)")] + public void Uncheck(string name) + { + EntitiesCollection.GetWebElement(name).Uncheck(); + } + + [Then(@"the (.*) is checked")] + public void IsChecked(string name) + { + EntitiesCollection.GetWebElement(name).Is.Selected(); + } + + [Then(@"the (.*) is not checked")] + public void IsNotChecked(string name) + { + EntitiesCollection.GetWebElement(name).Is.Deselected(); + } + + [Then(@"the (.*) is enabled")] + public void IsEnabled(string name) + { + EntitiesCollection.GetWebElement(name).Is.Enabled(); + } + + [Then(@"the (.*) is displayed")] + public void IsDisplayed(string name) + { + EntitiesCollection.GetWebElement(name).Is.Displayed(); + } + } +} diff --git a/JDI.Light/JDI.BDD/StepDefs/JDISteps.cs b/JDI.Light/JDI.BDD/StepDefs/JDISteps.cs index eaf6f2ea..e4d2838a 100644 --- a/JDI.Light/JDI.BDD/StepDefs/JDISteps.cs +++ b/JDI.Light/JDI.BDD/StepDefs/JDISteps.cs @@ -10,36 +10,8 @@ namespace JDI.BDD.StepDefs [Binding] public class JDISteps { - [Then(@"the (.*) is disabled")] - public void IsDisabled(string name) - { - Assert.IsTrue(EntitiesCollection.GetWebElement(name).Disabled); - } - - [Then(@"the (.*) is enabled")] - public void IsEnabled(string name) - { - Assert.IsTrue(EntitiesCollection.GetWebElement(name).Enabled); - } - - [Then(@"the (.*) is enabled")] - public void IsDisplayed(string name) - { - Assert.IsTrue(EntitiesCollection.GetWebElement(name).Displayed); - } - - [Then(@"the (.*) is hidden")] - public void IsHidden(string name) - { - Assert.IsTrue(EntitiesCollection.GetWebElement(name).Hidden); - } - - [Then(@"the (.*) is selected")] - public void IsSelected(string name) - { - Assert.IsTrue(EntitiesCollection.GetWebElement(name).Selected); - } + #region WHEN [When(@"I send keys (.*) to (.*)")] public void SendKeys(string value, string name) { @@ -82,6 +54,38 @@ public void Show(string name) EntitiesCollection.GetWebElement(name).Show(); } + #endregion + + [Then(@"the (.*) is disabled")] + public void IsDisabled(string name) + { + Assert.IsTrue(EntitiesCollection.GetWebElement(name).Disabled); + } + + [Then(@"the (.*) is enabled")] + public void IsEnabled(string name) + { + Assert.IsTrue(EntitiesCollection.GetWebElement(name).Enabled); + } + + [Then(@"the (.*) is enabled")] + public void IsDisplayed(string name) + { + Assert.IsTrue(EntitiesCollection.GetWebElement(name).Displayed); + } + + [Then(@"the (.*) is hidden")] + public void IsHidden(string name) + { + Assert.IsTrue(EntitiesCollection.GetWebElement(name).Hidden); + } + + [Then(@"the (.*) is selected")] + public void IsSelected(string name) + { + Assert.IsTrue(EntitiesCollection.GetWebElement(name).Selected); + } + [Then(@"the (.*) text equals to (.*)")] public void TextEquals(string name, string value) {