Skip to content

Commit 27ca686

Browse files
author
Justin
committed
first commit
0 parents  commit 27ca686

File tree

103 files changed

+5125
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+5125
-0
lines changed

pythonSeleniumFramework/.DS_Store

8 KB
Binary file not shown.

pythonSeleniumFramework/.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pythonSeleniumFramework/.idea/inspectionProfiles/profiles_settings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pythonSeleniumFramework/.idea/misc.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pythonSeleniumFramework/.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pythonSeleniumFramework/.idea/pythonSeleniumFramework.iml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
6 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import openpyxl
2+
3+
4+
class HomePageData:
5+
6+
# dictionary --> key-value pair
7+
# when pass the key, then the data of the value will be extracted
8+
test_HomePage_Data = [
9+
{"email": "hello@gmail.com",
10+
"password": "123456",
11+
"name": "hi",
12+
"2-way data binding text": "bye",
13+
"gender": "Female"
14+
},
15+
{"email": "test@gmail.com",
16+
"password": "223456",
17+
"name": "hey",
18+
"2-way data binding text": "bruh",
19+
"gender": "Male"
20+
}
21+
]
22+
23+
24+
# static method --> to call the method by class.method(), avoid creating object
25+
@staticmethod
26+
def getTestData(test_case_name): # the "self" parameter is required only if the method is non-static
27+
28+
# load the complete excel file; workbook --> collection of sheets
29+
book = openpyxl.load_workbook("/Users/chunholuk/Downloads/PythonSelFramework/PythonDemo.xlsx")
30+
sheet = book.active # select a sheet which is active out of that workbook
31+
32+
# capture and store the excel data into a dictionary data type
33+
Dict = {}
34+
35+
# extract the data of "test_case_name"
36+
for each_row in range(1, sheet.max_row + 1): # the "sheet.max_row" is the upper cap, so have to +1 here
37+
38+
if sheet.cell(row=each_row, column=1).value == test_case_name: # scan for it in 1st column from each row
39+
40+
for each_column in range(2, sheet.max_column + 1): # start from column=2, so only fetch the test data
41+
42+
# Dict["key"] = value
43+
Dict[sheet.cell(row=1, column=each_column).value] = sheet.cell(row=each_row,
44+
column=each_column).value
45+
print(sheet.cell(row=1, column=each_column).value) # key
46+
print(sheet.cell(row=each_row, column=each_column).value) # value
47+
print(Dict)
48+
return [Dict] # return the dictionary data type within a list format, because "test_HomePage_Data" is in list

pythonSeleniumFramework/TestData/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from selenium.webdriver.common.by import By
2+
3+
from pageObjects.ConfirmPage import ConfirmPage
4+
5+
6+
class CheckOutPage:
7+
8+
def __init__(self, driver):
9+
self.driver = driver
10+
11+
productTitles = (By.XPATH, "//div[@class='card h-100']")
12+
proceedCheckOutButton = (By.CSS_SELECTOR, "a[class*='btn-primary']")
13+
clickCheckOutButton = (By.XPATH, "//button[@class='btn btn-success']")
14+
15+
def getProductTitles(self):
16+
return self.driver.find_elements(*CheckOutPage.productTitles)
17+
# driver.find_elements(By.XPATH, "//div[@class='card h-100']")
18+
19+
def proceedCheckOut(self):
20+
return self.driver.find_element(*CheckOutPage.proceedCheckOutButton)
21+
# driver.find_element(By.CSS_SELECTOR, "a[class*='btn-primary']")
22+
23+
def checkOutItems(self):
24+
self.driver.find_element(*CheckOutPage.clickCheckOutButton).click()
25+
# confirmPage = ConfirmPage(self.driver)
26+
# return confirmPage
27+
# self.driver.find_element(By.XPATH, "//button[@class='btn btn-success']").click()
28+
# Regular Expression
29+
# driver.find_element(By.XPATH, "//button[contains(@class,'btn-success')]").click()
30+
confirmPage = ConfirmPage(self.driver)
31+
return confirmPage
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from selenium.webdriver.common.by import By
2+
3+
4+
class ConfirmPage:
5+
6+
def __init__(self, driver):
7+
self.driver = driver
8+
9+
deliveryLocation = (By.ID, "country")
10+
locationOption = (By.LINK_TEXT, "Russia")
11+
checkbox = (By.XPATH, "//div[@class='checkbox checkbox-primary']")
12+
purchaseButton = (By.CSS_SELECTOR, "[type='submit']")
13+
successMessage = (By.CLASS_NAME, "alert-success")
14+
15+
def enterDeliveryLocation(self):
16+
return self.driver.find_element(*ConfirmPage.deliveryLocation)
17+
# self.driver.find_element(By.ID, "country")
18+
19+
def selectDeliveryLocation(self):
20+
return self.driver.find_element(*ConfirmPage.locationOption)
21+
# self.driver.find_element(By.LINK_TEXT, "Russia")
22+
23+
def checkCheckbox(self):
24+
return self.driver.find_element(*ConfirmPage.checkbox)
25+
# self.driver.find_element(By.XPATH, "//div[@class='checkbox checkbox-primary']")
26+
27+
def clickPurchaseButton(self):
28+
return self.driver.find_element(*ConfirmPage.purchaseButton)
29+
# self.driver.find_element(By.CSS_SELECTOR, "[type='submit']") # tag name is optional, if it's not shared
30+
# driver.find_element(By.XPATH, "//*[@type='submit']").click() # XPATH
31+
32+
def verifySuccessMessage(self):
33+
return self.driver.find_element(*ConfirmPage.successMessage)
34+
# self.driver.find_element(By.CLASS_NAME, "alert-success")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
from selenium.webdriver.common.by import By
2+
3+
from pageObjects.CheckoutPage import CheckOutPage
4+
5+
6+
class HomePage:
7+
8+
# create a local constructor for this particular class
9+
# a constructor which accepts "driver" as an argument
10+
# so, whenever create an object for this class, have to pass "driver" as an argument
11+
# the "driver" from the test case will be assigned to this local class "driver"
12+
def __init__(self, driver):
13+
self.driver = driver
14+
15+
# declared a page object
16+
shop = (By.CSS_SELECTOR, "a[href*='shop']") # argument --> (type of locator, actual locator)
17+
# Regular Expression -- "*=" --> target the partial value
18+
19+
###
20+
# test_HomePage.py
21+
email = (By.NAME, "email")
22+
password = (By.ID, "exampleInputPassword1")
23+
checkbox = (By.ID, "exampleCheck1")
24+
submitButton = (By.XPATH, "//input[@type='submit']")
25+
twoWayDataBindingExample = (By.XPATH, "(//input[@type='text'])[3]")
26+
name = (By.CSS_SELECTOR, "input[name='name']")
27+
radioButton = (By.CSS_SELECTOR, "#inlineRadio1")
28+
staticDropDown = (By.ID, "exampleFormControlSelect1")
29+
successMessage = (By.CLASS_NAME, "alert-success")
30+
31+
def shopItems(self):
32+
# after this method, the web would jump into next page
33+
# shop is a class variable --> "HomePage.shop"
34+
# return --> send back to the call self. --> access instance variable * --> de-serialize the tuple variable
35+
self.driver.find_element(*HomePage.shop).click()
36+
# driver.find_element(By.CSS_SELECTOR, "a[href*='shop']")
37+
# driver.find_element(By.XPATH, "//a[contains(@href,'shop')]").click() # XPATH
38+
checkoutPage = CheckOutPage(self.driver) # creating object for the next page; class = "CheckOutPage"
39+
return checkoutPage
40+
41+
###
42+
# test_HomePage.py
43+
def enterEmail(self):
44+
return self.driver.find_element(*HomePage.email)
45+
# driver.find_element(By.NAME, "email")
46+
47+
def enterPassword(self):
48+
return self.driver.find_element(*HomePage.password)
49+
# driver.find_element(By.ID, "exampleInputPassword1")
50+
51+
def clickCheckbox(self):
52+
return self.driver.find_element(*HomePage.checkbox)
53+
# driver.find_element(By.ID, "exampleCheck1")
54+
55+
def clickSubmitButton(self):
56+
return self.driver.find_element(*HomePage.submitButton)
57+
# driver.find_element(By.XPATH, "//input[@type='submit']")
58+
59+
def enterTwoWayDataBindingText(self):
60+
return self.driver.find_element(*HomePage.twoWayDataBindingExample)
61+
# driver.find_element(By.XPATH, "(//input[@type='text'])[3]") # identify the 3rd element
62+
63+
def enterName(self):
64+
return self.driver.find_element(*HomePage.name)
65+
# driver.find_element(By.CSS_SELECTOR, "input[name='name']")
66+
67+
def clickRadioButton(self):
68+
return self.driver.find_element(*HomePage.radioButton)
69+
# driver.find_element(By.CSS_SELECTOR, "#inlineRadio1")
70+
71+
def expandStaticDropDown(self):
72+
return self.driver.find_element(*HomePage.staticDropDown)
73+
# driver.find_element(By.ID, "exampleFormControlSelect1")
74+
75+
def verifySuccessMessage(self):
76+
return self.driver.find_element(*HomePage.successMessage)
77+
# driver.find_element(By.CLASS_NAME, "alert-success")

pythonSeleniumFramework/pageObjects/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

pythonSeleniumFramework/reports/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)