-
Notifications
You must be signed in to change notification settings - Fork 0
/
WeatherSampleSteps.cs
102 lines (80 loc) · 3.19 KB
/
WeatherSampleSteps.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using NUnit.Framework;
using System;
using TechTalk.SpecFlow;
using System.Net;
using System.Xml;
using System.IO;
using System.Collections;
using System.Data;
using System.Collections.Generic;
using OpenQA.Selenium;
namespace SoapWebService.SampleTest
{
[Binding]
public class WeatherSampleSteps
{
// IWebDriver driver = BaseDriver.getDriver();
String serviceEndpoint =Properties.Settings.Default.ServiceEndpoint;
String path = System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory().ToString()).ToString();
// String sampleXMLRequestPath = "r:\\My Documents\\Visual Studio 2013\\Projects\\SpecFlowSample\\SpecFlowSample\\SoapRequest.xml";
String sampleXMLRequestPath ="";
String soapResult;
SoapUtil soapUtil = new SoapUtil();
XmlDocument soapRequestXML;
[Given(@"I have valid weather request")]
public void IHaveValidWeatherRequest()
{
sampleXMLRequestPath = path + "\\SpecFlowSample\\SoapRequest.xml";
soapRequestXML = new XmlDocument();
soapRequestXML.Load(sampleXMLRequestPath);
}
[Given(@"I have ""(.*)"" as ""(.*)""")]
public void GivenIHaveAs(string p0, string p1)
{
soapRequestXML = soapUtil.updateXMLSoapRequest(soapRequestXML, p0, p1);
}
[When(@"I request for weather report")]
public void WhenIRequestForWeatherReport()
{
soapResult = soapUtil.sendAndGetSoapResponse(serviceEndpoint, soapRequestXML);
}
[Then(@"I verify the Status as ""(.*)""")]
public void ThenIVerifyTheStatusAs(string status)
{
soapUtil.verifyStatus(status);
}
[Then(@"I Login to ""(.*)""")]
public void ThenINavigateTo(string p0)
{
BaseDriver.getDriver().Navigate().GoToUrl(p0);
LoginPage loginPage = new LoginPage(BaseDriver.getDriver());
loginPage.signIn("BumbleBee", "Autobats");
}
[AfterScenario]
public void closeBrowser()
{
if (BaseDriver.driver != null)
{
ITakesScreenshot screenShotDriver = (ITakesScreenshot)BaseDriver.driver;
Screenshot sc = screenShotDriver.GetScreenshot();
sc.SaveAsFile("abc.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
Console.WriteLine(System.IO.Directory.GetCurrentDirectory() + "\\abc.jpg");
BaseDriver.driver.Close();
BaseDriver.setDriver(null);
}
}
[Then(@"I get the values from xls")]
public void IGetTheValuesFromXls()
{
WorkbookUtil util = new WorkbookUtil();
DataTable str = util.GetDataTableFromExcelFile("R:\\My Documents\\Visual Studio 2013\\Projects\\SpecFlowSample\\SpecFlowSample\\Sample.xlsx", "Sheet1");
foreach (DataRow dataRow in str.Rows)
{
foreach (var i in dataRow.ItemArray)
{
Console.WriteLine(i);
}
}
}
}
}