automation

This commit is contained in:
Aryamol Jacob 2021-04-10 23:05:00 +05:30
parent f6b7fdda08
commit 31d255fc93
8 changed files with 180 additions and 193 deletions

View File

@ -57,8 +57,8 @@
<!--mandatory keys-->
<!-- URL Configuration-->
<add key="protocol" value="https" />
<add key="host" value="www.google.com" />
<add key="protocol" value="http" />
<add key="host" value="eshop.31d164c105ec415cb0bc.eastus.aksapp.io" />
<add key="url" value="/" />
<!--<add key="browser" value="Safari" />-->
<add key="SimulateMobileBrowser" value="false" />

View File

@ -38,7 +38,7 @@
<PackageReference Include="Pickles" Version="2.21.0" />
<PackageReference Include="Selenium.Support" Version="3.141.0" />
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="87.0.4280.8800" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="89.0.4389.2300" />
<PackageReference Include="Selenium.WebDriver.GeckoDriver" Version="0.28.0" />
<PackageReference Include="Selenium.WebDriver.GeckoDriver.Win64" Version="0.28.0" />
<PackageReference Include="Selenium.WebDriver.IEDriver" Version="3.150.1.2" />
@ -93,7 +93,6 @@
<Folder Include="Hooks\" />
<Folder Include="TestData\Before\" />
<Folder Include="TestData\After\" />
<Folder Include="TestData\Input\" />
<Folder Include="TestData\Output\" />
</ItemGroup>
@ -101,6 +100,9 @@
<None Update="EShopApplicationWebSolution.dev.runsettings">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestData\Input\Credentials.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>

View File

@ -4,24 +4,22 @@ Feature: Login_EShopApplication
@bvt @priority=1
Scenario: Verify that a registered user is able to login into EShop application
Given the user is registered to EShop application
When user launches EShop application
And user clicks on "Login" button
And user enters "email" and "password"
When user clicks on "Log in"
Then the user should be able to login to the application
And user clicks on "Login" option
And user enter Email and Password of "User1"
And user click on "LOG IN" button
Then verify if "User1" is logged-in
@priority=2
Scenario Outline: Verify that the user is unable to login to EShop Application if user is not registered already
Given the user is no registered to EShop application
Given the user is not registered to EShop application
When user launches EShop application
And user clicks on "Login" button
And user enters "email" and "password"
When user clicks on "Log in"
And user enter Email and Password of "<user>"
And user click on "LOG IN" button
Then the user should not be able to login to the application
Examples:
| username | password |
| user1 | password1 |
| user2 | password2 |
| user3 | password3 |
| user |
| InvalidUser1 |
| InvalidUser2 |
| InvalidUser3 |

View File

@ -38,7 +38,7 @@ namespace EShopApplicationWebSolution.Features
"testplan=",
"testsuite="};
#line 1 "EShopApllication_Login.feature"
#line 1 "EShopApplication_Login.feature"
#line hidden
[NUnit.Framework.OneTimeSetUpAttribute()]
@ -89,16 +89,16 @@ namespace EShopApplicationWebSolution.Features
}
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("Verify that a registered user is able to login into EShop application")]
[NUnit.Framework.DescriptionAttribute("Test")]
[NUnit.Framework.CategoryAttribute("bvt")]
[NUnit.Framework.CategoryAttribute("priority=1")]
public virtual void VerifyThatARegisteredUserIsAbleToLoginIntoEShopApplication()
public virtual void Test()
{
string[] tagsOfScenario = new string[] {
"bvt",
"priority=1"};
System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary();
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Verify that a registered user is able to login into EShop application", null, tagsOfScenario, argumentsOfScenario);
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Test", null, tagsOfScenario, argumentsOfScenario);
#line 6
this.ScenarioInitialize(scenarioInfo);
#line hidden
@ -120,49 +120,35 @@ this.ScenarioInitialize(scenarioInfo);
{
this.ScenarioStart();
#line 7
testRunner.Given("the user is registered to EShop application", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line hidden
#line 8
testRunner.When("user launches EShop application", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
#line 8
testRunner.And("user clicks on \"Login\" option", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
#line 9
testRunner.And("user clicks on \"Login\" button", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.And("user enter Email and Password of \"User1\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
#line 10
testRunner.And("user enters \"email\" and \"password\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
testRunner.And("user click on \"LOG IN\" button", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
#line 11
testRunner.When("user clicks on \"Log in\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
#line 12
testRunner.Then("the user should be able to login to the application", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
testRunner.Then("verify if \"User1\" is logged-in", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
}
this.ScenarioCleanup();
}
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("Verify that the user is unable to login to EShop Application if he is not registe" +
"red already")]
[NUnit.Framework.CategoryAttribute("bddcore-ex")]
[NUnit.Framework.CategoryAttribute("priority=2")]
[NUnit.Framework.TestCaseAttribute("user1", "password1", null)]
[NUnit.Framework.TestCaseAttribute("user2", "password2", null)]
[NUnit.Framework.TestCaseAttribute("user3", "password3", null)]
public virtual void VerifyThatTheUserIsUnableToLoginToEShopApplicationIfHeIsNotRegisteredAlready(string username, string password, string[] exampleTags)
[NUnit.Framework.DescriptionAttribute("Verify that a registered user is able to login into EShop application")]
[NUnit.Framework.CategoryAttribute("bvt")]
[NUnit.Framework.CategoryAttribute("priority=1")]
public virtual void VerifyThatARegisteredUserIsAbleToLoginIntoEShopApplication()
{
string[] @__tags = new string[] {
"priority=2"};
if ((exampleTags != null))
{
@__tags = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Concat(@__tags, exampleTags));
}
string[] tagsOfScenario = @__tags;
string[] tagsOfScenario = new string[] {
"bvt",
"priority=1"};
System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary();
argumentsOfScenario.Add("username", username);
argumentsOfScenario.Add("password", password);
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Verify that the user is unable to login to EShop Application if he is not registe" +
"red already", null, tagsOfScenario, argumentsOfScenario);
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Verify that a registered user is able to login into EShop application", null, tagsOfScenario, argumentsOfScenario);
#line 15
this.ScenarioInitialize(scenarioInfo);
#line hidden
@ -184,7 +170,7 @@ this.ScenarioInitialize(scenarioInfo);
{
this.ScenarioStart();
#line 16
testRunner.Given("the user is no registered to EShop application", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
testRunner.Given("\"user 1\" is registered to EShop application", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line hidden
#line 17
testRunner.When("user launches EShop application", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
@ -199,6 +185,70 @@ this.ScenarioInitialize(scenarioInfo);
testRunner.When("user clicks on \"Log in\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
#line 21
testRunner.Then("the user should be able to login to the application", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
}
this.ScenarioCleanup();
}
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("Verify that the user is unable to login to EShop Application if user is not regis" +
"tered already")]
[NUnit.Framework.CategoryAttribute("bddcore-ex")]
[NUnit.Framework.CategoryAttribute("priority=2")]
[NUnit.Framework.TestCaseAttribute("user1", "password1", null)]
[NUnit.Framework.TestCaseAttribute("user2", "password2", null)]
[NUnit.Framework.TestCaseAttribute("user3", "password3", null)]
public virtual void VerifyThatTheUserIsUnableToLoginToEShopApplicationIfUserIsNotRegisteredAlready(string username, string password, string[] exampleTags)
{
string[] @__tags = new string[] {
"priority=2"};
if ((exampleTags != null))
{
@__tags = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Concat(@__tags, exampleTags));
}
string[] tagsOfScenario = @__tags;
System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary();
argumentsOfScenario.Add("username", username);
argumentsOfScenario.Add("password", password);
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Verify that the user is unable to login to EShop Application if user is not regis" +
"tered already", null, tagsOfScenario, argumentsOfScenario);
#line 24
this.ScenarioInitialize(scenarioInfo);
#line hidden
bool isScenarioIgnored = default(bool);
bool isFeatureIgnored = default(bool);
if ((tagsOfScenario != null))
{
isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any();
}
if ((this._featureTags != null))
{
isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any();
}
if ((isScenarioIgnored || isFeatureIgnored))
{
testRunner.SkipScenario();
}
else
{
this.ScenarioStart();
#line 25
testRunner.Given("the user is no registered to EShop application", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line hidden
#line 26
testRunner.When("user launches EShop application", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
#line 27
testRunner.And("user clicks on \"Login\" button", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
#line 28
testRunner.And("user enters \"email\" and \"password\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
#line 29
testRunner.When("user clicks on \"Log in\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
#line 30
testRunner.Then("the user should not be able to login to the application", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
}
@ -206,15 +256,15 @@ this.ScenarioInitialize(scenarioInfo);
}
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("Verify that the user is unable to login to EShop Application if he is not registe" +
"red already")]
[NUnit.Framework.DescriptionAttribute("Verify that the user is unable to login to EShop Application if user is not regis" +
"tered already")]
[NUnit.Framework.CategoryAttribute("priority=2")]
[NUnit.Framework.CategoryAttribute("bddcore-wrapper")]
public virtual void VerifyThatTheUserIsUnableToLoginToEShopApplicationIfHeIsNotRegisteredAlready()
public virtual void VerifyThatTheUserIsUnableToLoginToEShopApplicationIfUserIsNotRegisteredAlready()
{
this.VerifyThatTheUserIsUnableToLoginToEShopApplicationIfHeIsNotRegisteredAlready("user1", "password1", null);
this.VerifyThatTheUserIsUnableToLoginToEShopApplicationIfHeIsNotRegisteredAlready("user2", "password2", null);
this.VerifyThatTheUserIsUnableToLoginToEShopApplicationIfHeIsNotRegisteredAlready("user3", "password3", null);
this.VerifyThatTheUserIsUnableToLoginToEShopApplicationIfUserIsNotRegisteredAlready("user1", "password1", null);
this.VerifyThatTheUserIsUnableToLoginToEShopApplicationIfUserIsNotRegisteredAlready("user2", "password2", null);
this.VerifyThatTheUserIsUnableToLoginToEShopApplicationIfUserIsNotRegisteredAlready("user3", "password3", null);
}
}
}

View File

@ -61,92 +61,29 @@ namespace EShopApplicationWebSolution.Properties {
}
/// <summary>
/// Looks up a localized string similar to http://www.bing.com.
/// Looks up a localized string similar to xpath://button[contains(text(),&apos;{0}&apos;)].
/// </summary>
internal static string Bing {
internal static string ButtonByText {
get {
return ResourceManager.GetString("Bing", resourceCulture);
return ResourceManager.GetString("ButtonByText", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to xpath://*[@id=&apos;new-image&apos;].
/// Looks up a localized string similar to xpath://div[contains(text(),&apos;{0}&apos;)].
/// </summary>
internal static string browse {
internal static string DivLinks {
get {
return ResourceManager.GetString("browse", resourceCulture);
return ResourceManager.GetString("DivLinks", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to xpath:/html/body/table/tbody/tr/td[1]/a[1].
/// Looks up a localized string similar to xpath://*[@id=&apos;{0}&apos;].
/// </summary>
internal static string ClickHereToTest {
internal static string Id {
get {
return ResourceManager.GetString("ClickHereToTest", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to xpath://*[@id=&quot;main&quot;]/p[2]/a.
/// </summary>
internal static string download {
get {
return ResourceManager.GetString("download", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to https://unixpapa.com/js/testmouse.html.
/// </summary>
internal static string ElementClick {
get {
return ResourceManager.GetString("ElementClick", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to https://docs.microsoft.com/en-us/power-bi/sample-financial-download.
/// </summary>
internal static string FileDownload {
get {
return ResourceManager.GetString("FileDownload", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to https://ezgif.com/effects.
/// </summary>
internal static string FileUpload {
get {
return ResourceManager.GetString("FileUpload", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to http://www.google.com.
/// </summary>
internal static string Google {
get {
return ResourceManager.GetString("Google", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to xpath://*[@name=&apos;q&apos;].
/// </summary>
internal static string Query {
get {
return ResourceManager.GetString("Query", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to xpath://h1[contains(text(),&apos;Search Results&apos;)].
/// </summary>
internal static string SearchResults {
get {
return ResourceManager.GetString("SearchResults", resourceCulture);
return ResourceManager.GetString("Id", resourceCulture);
}
}
}

View File

@ -117,34 +117,13 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Bing" xml:space="preserve">
<value>http://www.bing.com</value>
<data name="ButtonByText" xml:space="preserve">
<value>xpath://button[contains(text(),'{0}')]</value>
</data>
<data name="browse" xml:space="preserve">
<value>xpath://*[@id='new-image']</value>
<data name="DivLinks" xml:space="preserve">
<value>xpath://div[contains(text(),'{0}')]</value>
</data>
<data name="ClickHereToTest" xml:space="preserve">
<value>xpath:/html/body/table/tbody/tr/td[1]/a[1]</value>
</data>
<data name="download" xml:space="preserve">
<value>xpath://*[@id="main"]/p[2]/a</value>
</data>
<data name="ElementClick" xml:space="preserve">
<value>https://unixpapa.com/js/testmouse.html</value>
</data>
<data name="FileDownload" xml:space="preserve">
<value>https://docs.microsoft.com/en-us/power-bi/sample-financial-download</value>
</data>
<data name="FileUpload" xml:space="preserve">
<value>https://ezgif.com/effects</value>
</data>
<data name="Google" xml:space="preserve">
<value>http://www.google.com</value>
</data>
<data name="Query" xml:space="preserve">
<value>xpath://*[@name='q']</value>
</data>
<data name="SearchResults" xml:space="preserve">
<value>xpath://h1[contains(text(),'Search Results')]</value>
<data name="Id" xml:space="preserve">
<value>xpath://*[@id='{0}']</value>
</data>
</root>

View File

@ -1,53 +1,74 @@
using System;
using TechTalk.SpecFlow;
using EShopApplicationWebSolution.Properties;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace EShopApplicationWebSolution.StepDefinitions
{
using Bdd.Core.Entities;
using Bdd.Core.Utils;
using Bdd.Core.Web.Executors;
using Bdd.Core.Web.StepDefinitions;
using Bdd.Core.Web.Utils;
using NUnit.Framework;
using Ocaramba;
using SmartFormat;
using TechTalk.SpecFlow;
[Binding]
public class Login_EShopApplicationSteps
public class Login_EShopApplicationSteps : WebStepDefinitionBase
{
[Given(@"the user is registered to EShop application")]
public void GivenTheUserIsRegisteredToEShopApplication()
[When(@"user launches EShop application")]
public void WhenUserLaunchesEShopApplication()
{
ScenarioContext.Current.Pending();
var url = Smart.Format(BaseConfiguration.GetUrlValue);
this.Get<UrlPage>().NavigateToUrl(url);
}
[When(@"user clicks on ""(.*)""")]
public async Task WhenUserClicksOnAsync(string linkText)
{
this.Get<ElementPage>().GetElement(nameof(Resources.DivLinks), linkText).Click();
}
[When(@"user clicks on ""(.*)"" option")]
public void WhenUserClicksOnOption(string linkText)
{
this.Get<ElementPage>().GetElement(nameof(Resources.DivLinks), linkText).Click();
}
[When(@"user enter Email and Password of ""(.*)""")]
public void WhenIEnterEmailAndPasswordOf(string user)
{
var userdata = this.ScenarioContext.GetCredential<Credentials>(this.FeatureContext, user, "input=Credentials.xlsx");
this.Get<ElementPage>().EnterText(nameof(Resources.Id), userdata.User, "Email");
this.Get<ElementPage>().EnterText(nameof(Resources.Id), userdata.Password, "Password");
this.ScenarioContext[user] = userdata.User;
}
[When(@"user click on ""(.*)"" button")]
public void WhenIClickOnButton(string buttonText)
{
this.Get<ElementPage>().GetElement(nameof(Resources.ButtonByText), buttonText).Click();
}
[Then(@"verify if ""(.*)"" is logged-in")]
public void ThenIVerifyIfIsLogged_In(string user)
{
var addToCartPresent = this.Get<ElementPage>().CheckIfElementIsPresent(nameof(Resources.ButtonByText), 30, "ADD TO CART");
var isloggedIn = this.Get<ElementPage>().CheckIfElementIsPresent(nameof(Resources.DivLinks), 30, this.ScenarioContext[user].ToString());
Assert.IsTrue(addToCartPresent&& isloggedIn, $"Login Falied");
}
[Given(@"the user is no registered to EShop application")]
public void GivenTheUserIsNoRegisteredToEShopApplication()
{
ScenarioContext.Current.Pending();
}
[When(@"user launches EShop application")]
public void WhenUserLaunchesEShopApplication()
{
ScenarioContext.Current.Pending();
}
[When(@"user clicks on ""(.*)"" button")]
public void WhenUserClicksOnButton(string p0)
{
ScenarioContext.Current.Pending();
}
[When(@"user enters ""(.*)"" and ""(.*)""")]
public void WhenUserEntersAnd(string p0, string p1)
{
ScenarioContext.Current.Pending();
}
[When(@"user clicks on ""(.*)""")]
public void WhenUserClicksOn(string p0)
{
ScenarioContext.Current.Pending();
}
[Then(@"the user should be able to login to the application")]
public void ThenTheUserShouldBeAbleToLoginToTheApplication()
{
ScenarioContext.Current.Pending();
}
[Then(@"the user should not be able to login to the application")]
public void ThenTheUserShouldNotBeAbleToLoginToTheApplication()
{