This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParallelSpecRunFeatureSteps.cs
executable file
·124 lines (98 loc) · 4.58 KB
/
ParallelSpecRunFeatureSteps.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using System;
using TechTalk.SpecFlow;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using NUnit.Framework;
namespace ParallelSpecFlowPlusRunner
{
[Binding]
public class FeatureSteps
{
public string username = "Enter your username";
RemoteWebDriver driverChrome;
RemoteWebDriver driverFirefox;
public string authkey = "Enter your authkey";
[Given(@"I navigate to the page ""(.*)""")]
public void GivenINavigateToThePage(string p0)
{
var caps = new OpenQA.Selenium.RemoteSessionSettings();
caps.AddMetadataSetting("name", "Parallel Chrome Test Example");
caps.AddMetadataSetting("build", "1.0");
caps.AddMetadataSetting("browserName", "Chrome");
caps.AddMetadataSetting("version", "78x64");
caps.AddMetadataSetting("platform", "Windows 10");
caps.AddMetadataSetting("screenResolution", "1366x768");
caps.AddMetadataSetting("record_video", "true");
caps.AddMetadataSetting("username", username);
caps.AddMetadataSetting("password", authkey);
// Start the remote webdriver
driverChrome = new RemoteWebDriver(new Uri("http://hub.crossbrowsertesting.com:80/wd/hub"), caps, TimeSpan.FromSeconds(180));
// Navigate to site
driverChrome.Manage().Window.Maximize();
driverChrome.Navigate().GoToUrl(p0);
}
[Given(@"I see the page is loaded")]
public void GivenISeeThePageIsLoaded()
{
Assert.AreEqual("Google", driverChrome.Title);
}
[When(@"I enter Search Keyword in the Search Text box")]
public void WhenIEnterSearchKeywordInTheSearchTextBox()
{
string searchText = "Specflow";
driverChrome.FindElement(By.Name("q")).SendKeys(searchText);
}
[When(@"I click on Search Button")]
public void WhenIClickOnSearchButton()
{
driverChrome.FindElement(By.Name("btnK")).Click();
}
[Then(@"Search items shows the items related to SpecFlow")]
public void ThenSearchItemsShowsTheItemsRelatedToSpecFlow()
{
Assert.AreEqual("SpecFlow - Binding Business Requirements to .NET Code", driverChrome.FindElement(By.XPath("//a/h3")).Text);
driverChrome.Quit();
}
[Given(@"I navigate to the page ""(.*)"" with Firefox")]
public void GivenINavigateToThePageWithFirefox(string p0)
{
var caps = new OpenQA.Selenium.RemoteSessionSettings();
caps.AddMetadataSetting("name", "Parallel Firefox Test Example");
caps.AddMetadataSetting("build", "1.0");
caps.AddMetadataSetting("browserName", "Firefox");
caps.AddMetadataSetting("version", "72x64");
caps.AddMetadataSetting("platform", "Windows 10");
caps.AddMetadataSetting("screenResolution", "1366x768");
caps.AddMetadataSetting("record_video", "true");
caps.AddMetadataSetting("username", username);
caps.AddMetadataSetting("password", authkey);
// Start the remote webdriver
driverFirefox = new RemoteWebDriver(new Uri("http://hub.crossbrowsertesting.com:80/wd/hub"), caps, TimeSpan.FromSeconds(180));
// Navigate to site
driverFirefox.Manage().Window.Maximize();
driverFirefox.Navigate().GoToUrl(p0);
}
[Given(@"I see the page is loaded with Firefox")]
public void GivenISeeThePageIsLoadedWithFirefox()
{
Assert.AreEqual("Google", driverFirefox.Title);
}
[When(@"I enter Search Keyword in the Search Text box with Firefox")]
public void WhenIEnterSearchKeywordInTheSearchTextBoxWithFirefox()
{
string searchText = "Specflow";
driverFirefox.FindElement(By.Name("q")).SendKeys(searchText);
}
[When(@"I click on Search Button with Firefox")]
public void WhenIClickOnSearchButtonWithFirefox()
{
driverFirefox.FindElement(By.Name("btnK")).Click();
}
[Then(@"Search items shows the items related to SpecFlow with Firefox")]
public void ThenSearchItemsShowsTheItemsRelatedToSpecFlowWithFirefox()
{
Assert.AreEqual("SpecFlow - Binding Business Requirements to .NET Code", driverFirefox.FindElement(By.XPath("//a/h3")).Text);
driverFirefox.Quit();
}
}
}