-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathTodoAppSteps.cs
108 lines (84 loc) · 3.23 KB
/
TodoAppSteps.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using TechTalk.SpecFlow;
using NUnit.Framework;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;
/* For using Remote Selenium WebDriver */
using OpenQA.Selenium.Remote;
namespace SpecFlowLambdaSample
{
[Binding]
public sealed class ToDoApp
{
private IWebDriver _driver;
private LambdaTestDriver LTDriver = null;
String itemName = "MI";
String test_url = "https://lambdatest.github.io/sample-todo-app/";
// For additional details on SpecFlow step definitions see https://go.specflow.org/doc-stepdef
public ToDoApp(ScenarioContext ScenarioContext)
{
LTDriver = (LambdaTestDriver)ScenarioContext["LTDriver"];
}
[Given(@"that I am on the LambdaTest Sample app (.*) and (.*)")]
public void GivenThatIAmOnTheLambdaTestSampleAppAnd(string profile, string environment)
{
_driver = LTDriver.Init(profile, environment);
_driver.Url = test_url;
_driver.Manage().Window.Maximize();
System.Threading.Thread.Sleep(2000);
}
[Then(@"select the first item")]
public void ThenSelectTheFirstItem()
{
// Click on First Check box
_driver.FindElement(By.Name("li1")).Click();
}
[Then(@"select the second item")]
public void ThenSelectTheSecondItem()
{
// Click on Second Check box
IWebElement secondCheckBox = _driver.FindElement(By.Name("li2"));
secondCheckBox.Click();
}
[Then(@"find the text box to enter the new value")]
public void ThenFindTheTextBoxToEnterTheNewValue()
{
// Enter Item name
IWebElement textfield = _driver.FindElement(By.Id("sampletodotext"));
textfield.SendKeys(itemName);
}
[Then(@"click the Submit button")]
public void ThenClickTheSubmitButton()
{
// Click on Add button
IWebElement addButton = _driver.FindElement(By.Id("addbutton"));
addButton.Click();
}
[Then(@"verify whether the item is added to the list")]
public void ThenVerifyWhetherTheItemIsAddedToTheList()
{
// Verified Added Item name
IWebElement itemtext = _driver.FindElement(By.XPath("/html/body/div/div/div/form/input[1]"));
String getText = itemtext.Text;
// Check if the newly added item is present or not using
// Condition constraint (Boolean)
Assert.That((itemName.Contains(getText)), Is.True);
/* Perform wait to check the output */
System.Threading.Thread.Sleep(2000);
Console.WriteLine("Firefox - Test Passed");
}
[Then(@"close the browser instance")]
public void ThenCloseTheBrowserInstance()
{
_driver.Quit();
}
}
}