Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
DummySolution
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hasan.bahjat
DummySolution
Commits
d22657f8
Commit
d22657f8
authored
Oct 27, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lab 23 code
parent
0f0d5971
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
253 additions
and
0 deletions
+253
-0
SigninPage.cs
test/Dummy.SeleniumTests/SigninTets/Pages/SigninPage.cs
+42
-0
StorePage.cs
test/Dummy.SeleniumTests/SigninTets/Pages/StorePage.cs
+94
-0
SigninTest.cs
test/Dummy.SeleniumTests/SigninTets/Tests/SigninTest.cs
+51
-0
StoreTest.cs
test/Dummy.SeleniumTests/SigninTets/Tests/StoreTest.cs
+66
-0
No files found.
test/Dummy.SeleniumTests/SigninTets/Pages/SigninPage.cs
0 → 100644
View file @
d22657f8
using
OpenQA.Selenium
;
using
OpenQA.Selenium.Support.UI
;
using
System
;
namespace
Dummy.SeleniumTests.SigninTets.Pages
{
public
class
SigninPage
{
private
IWebDriver
_driver
;
private
WebDriverWait
_wait
;
//Locators ( UI Elements)
private
By
usernameField
=
By
.
Id
(
"email"
);
private
By
passwordField
=
By
.
Id
(
"password"
);
private
By
loginButton
=
By
.
Id
(
"login-btn"
);
public
SigninPage
(
IWebDriver
driver
)
{
_driver
=
driver
;
_wait
=
new
WebDriverWait
(
_driver
,
TimeSpan
.
FromSeconds
(
10
));
}
public
void
EnterUserName
(
string
username
)
{
var
usernameF
=
_wait
.
Until
(
d
=>
d
.
FindElement
(
usernameField
));
usernameF
.
SendKeys
(
username
);
}
public
void
EnterPassword
(
string
pass
)
{
var
passwordF
=
_wait
.
Until
(
d
=>
d
.
FindElement
(
passwordField
));
passwordF
.
SendKeys
(
pass
);
}
public
void
Submit
()
{
var
submitButton
=
_wait
.
Until
(
d
=>
d
.
FindElement
(
loginButton
));
submitButton
.
Click
();
}
}
}
test/Dummy.SeleniumTests/SigninTets/Pages/StorePage.cs
0 → 100644
View file @
d22657f8
using
OpenQA.Selenium
;
using
OpenQA.Selenium.Support.UI
;
using
System
;
namespace
Dummy.SeleniumTests.SigninTets.Pages
{
public
class
StorePage
{
private
IWebDriver
_driver
;
private
WebDriverWait
_wait
;
//Locators ( UI Elements)
private
By
totalCost
=
By
.
Id
(
"cart_total_price"
);
private
By
gst
=
By
.
Id
(
"cart_total_sales_tax"
);
public
String
firstItemFee
=
"//*[@id=\"store_cart_products\"]/tbody/tr[1]/td[3]"
;
public
String
secondItemFee
=
"//*[@id=\"store_cart_products\"]/tbody/tr[2]/td[3]"
;
private
String
itemQuantity
=
"quantity-"
;
private
String
itemAddButton
=
"add_service_"
;
public
int
FirstItemCode
()
{
return
41
;
}
public
int
SecondItemCode
()
{
return
33
;
}
public
StorePage
(
IWebDriver
driver
)
{
_driver
=
driver
;
_wait
=
new
WebDriverWait
(
_driver
,
TimeSpan
.
FromSeconds
(
10
));
}
public
void
SetItemQuantity
(
int
quantity
,
int
code
)
{
var
selectList
=
_wait
.
Until
(
d
=>
d
.
FindElement
(
By
.
Id
(
itemQuantity
+
code
)));
selectList
.
SendKeys
(
""
+
quantity
);
}
public
void
SetFirstItemQuantity
(
int
quantity
)
{
SetItemQuantity
(
quantity
,
SecondItemCode
());
}
public
void
SetSecondItemQuantity
(
int
quantity
)
{
SetItemQuantity
(
quantity
,
FirstItemCode
());
}
public
void
AddItem
(
int
code
)
{
var
addButton
=
_wait
.
Until
(
d
=>
d
.
FindElement
(
By
.
Id
(
itemAddButton
+
code
)));
addButton
.
Click
();
}
public
int
calculateFee
(
string
feeXPath
,
int
quantity
)
{
int
fee
=
GetFee
(
feeXPath
);
return
(
quantity
*
(
fee
))/
10
;
}
public
string
GetGSt
()
{
var
gstAmount
=
_wait
.
Until
(
d
=>
d
.
FindElement
(
gst
));
return
gstAmount
.
Text
;
}
public
int
GetFee
(
String
feeXPath
)
{
var
fee
=
_wait
.
Until
(
d
=>
d
.
FindElement
(
By
.
XPath
(
feeXPath
)));
return
Int32
.
Parse
(
fee
.
Text
.
Split
(
"$"
)[
2
])
;
}
public
string
GetTotal
()
{
var
totalAmount
=
_wait
.
Until
(
d
=>
d
.
FindElement
(
totalCost
));
return
totalAmount
.
Text
;
}
}
}
test/Dummy.SeleniumTests/SigninTets/Tests/SigninTest.cs
0 → 100644
View file @
d22657f8
using
Dummy.SeleniumTests.SigninTets.Pages
;
using
NUnit.Framework
;
using
OpenQA.Selenium
;
using
OpenQA.Selenium.Chrome
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Dummy.SeleniumTests.SigninTets.Tests
{
public
class
SigninTest
{
public
SigninPage
_siginPage
;
private
IWebDriver
_driver
;
//
public
String
HostName
=
"https://whenwise.agileway.net/sign-in"
;
[
SetUp
]
public
void
SetUp
()
{
_driver
=
new
ChromeDriver
();
_driver
.
Navigate
().
GoToUrl
(
HostName
);
_siginPage
=
new
SigninPage
(
_driver
);
}
[
Test
]
public
void
TestValidLogin
()
{
_siginPage
.
EnterUserName
(
"james@client.com"
);
_siginPage
.
EnterPassword
(
"test01"
);
_siginPage
.
Submit
();
Assert
.
IsTrue
(
_driver
.
Title
.
Contains
(
"WhenWise"
));
_driver
.
Quit
();
}
[
TearDown
]
public
void
TearDown
()
{
}
}
}
test/Dummy.SeleniumTests/SigninTets/Tests/StoreTest.cs
0 → 100644
View file @
d22657f8
using
Dummy.SeleniumTests.SigninTets.Pages
;
using
NUnit.Framework
;
using
OpenQA.Selenium
;
using
OpenQA.Selenium.Chrome
;
using
System
;
namespace
Dummy.SeleniumTests.SigninTets.Tests
{
public
class
StoreTest
{
public
StorePage
_storePage
;
public
SigninPage
_siginPage
;
private
IWebDriver
_driver
;
//
public
String
HostName
=
"https://whenwise.agileway.net/biz/wise-pool/store"
;
public
String
LoginHostName
=
"https://whenwise.agileway.net/sign-in"
;
[
SetUp
]
public
void
SetUp
()
{
_driver
=
new
ChromeDriver
();
_driver
.
Navigate
().
GoToUrl
(
LoginHostName
);
_siginPage
=
new
SigninPage
(
_driver
);
_siginPage
.
EnterUserName
(
"james@client.com"
);
_siginPage
.
EnterPassword
(
"test01"
);
_siginPage
.
Submit
();
_driver
.
Navigate
().
GoToUrl
(
HostName
);
_storePage
=
new
StorePage
(
_driver
);
}
[
Test
]
public
void
TestCartStore
()
{
int
qty
=
10
;
int
fcode
=
_storePage
.
FirstItemCode
();
_storePage
.
SetItemQuantity
(
qty
,
fcode
);
_storePage
.
AddItem
(
fcode
);
int
tfee
=
_storePage
.
calculateFee
(
_storePage
.
firstItemFee
,
10
);
int
itemPrice
=
_storePage
.
GetFee
(
_storePage
.
firstItemFee
);
string
actualTotal
=
_storePage
.
GetTotal
();
string
actualGST
=
_storePage
.
GetGSt
();
Assert
.
IsTrue
(
actualGST
.
Equals
(
"A$"
+
tfee
+
".00"
));
Assert
.
IsTrue
(
actualTotal
.
Equals
(
"A$"
+
tfee
+
qty
*
itemPrice
+
".00"
));
}
[
TearDown
]
public
void
TearDown
()
{
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment