Skip to content

Commit

Permalink
Added code with Specflow FindInSet and FindAllInSet support
Browse files Browse the repository at this point in the history
Added code with Specflow FindInSet and FindAllInSet along with firefox
gecko driver
  • Loading branch information
executeautomation committed Jan 2, 2017
1 parent 64bed52 commit 62d1b65
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 28 deletions.
17 changes: 10 additions & 7 deletions SpecflowParallelTest/Features/UserForm.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@

@mytag
Scenario: User Details form entry verification
Given I navigate to application
And I enter username and password
| UserName | Password |
| admin | admin |
And I click login
And I start entering user form details like
#Given I navigate to application
#And I enter username and password
# | UserName | Password |
# | admin | admin |
#And I click login
#And I start entering user form details like
# | Initial | FirstName | MiddleName |
# | k | Karthik | k |
#And I click submit button
And I verify the entered user form details in the application database
| Initial | FirstName | MiddleName |
| k | Karthik | k |
And I click submit button
21 changes: 3 additions & 18 deletions SpecflowParallelTest/Features/UserForm.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion SpecflowParallelTest/Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using TechTalk.SpecFlow;
Expand All @@ -26,7 +27,12 @@ public Hooks(IObjectContainer objectContainer)
[BeforeScenario]
public void Initialize()
{
_driver = new FirefoxDriver();
var driverDir = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembl‌​y().Location);
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(driverDir, "geckodriver.exe");
service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
service.HideCommandPromptWindow = true;
service.SuppressInitialDiagnosticInformation = true;
_driver = new FirefoxDriver(service);
_objectContainer.RegisterInstanceAs<IWebDriver>(_driver);
}

Expand Down
7 changes: 6 additions & 1 deletion SpecflowParallelTest/SpecflowParallelTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="..\packages\WebDriver.GeckoDriver.0.11.1\content\geckodriver.exe">
<Link>geckodriver.exe</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand Down
44 changes: 43 additions & 1 deletion SpecflowParallelTest/Steps/UserFormSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public UserFormSteps(IWebDriver driver)
public void GivenIStartEnteringUserFormDetailsLike(Table table)
{
dynamic data = table.CreateDynamicInstance();

_driver.FindElement(By.Id("Initial")).SendKeys((string)data.Initial);
_driver.FindElement(By.Id("FirstName")).SendKeys((string)data.FirstName);
_driver.FindElement(By.Id("MiddleName")).SendKeys((string)data.MiddleName);
Expand All @@ -39,6 +38,49 @@ public void GivenIClickSubmitButton()
_driver.FindElement(By.Name("Save")).Click();
}

[Given(@"I verify the entered user form details in the application database")]
public void GivenIVerifyTheEnteredUserFormDetailsInTheApplicationDatabase(Table table)
{
//Mock data collection
List<AUTDatabase> mockAUTData = new List<AUTDatabase>()
{
new AUTDatabase()
{
FirstName = "Karthik",
Initial = "k",
MiddleName = "k"
},

new AUTDatabase()
{
FirstName = "Prashanth",
Initial = "k",
MiddleName = "k"
}
};

//For verification with single row data
var result = table.FindAllInSet(mockAUTData);

//For verification againt Multiple row data
var resultnew = table.FindAllInSet(mockAUTData);

}


}

public class AUTDatabase
{
public string Initial { get; set; }

public string FirstName { get; set; }

public string MiddleName { get; set; }

public string Gender { get; set; }
}



}
1 change: 1 addition & 0 deletions SpecflowParallelTest/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
<package id="Selenium.WebDriver" version="2.53.1" targetFramework="net452" />
<package id="SpecFlow" version="2.1.0" targetFramework="net452" />
<package id="SpecFlow.Assist.Dynamic" version="1.1.0" targetFramework="net452" />
<package id="WebDriver.GeckoDriver" version="0.11.1" targetFramework="net452" />
</packages>

0 comments on commit 62d1b65

Please sign in to comment.