Skip to content

Commit b620272

Browse files
authored
Merge pull request gunesmes#1 from mkopr/patch-1
Add init in child classes
2 parents 66da7d7 + 2e278a9 commit b620272

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

pages.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,41 @@
1010
# Depends on the page functionality we can have more functions for new classes
1111

1212
class MainPage(Page):
13+
def __init__(self, driver):
14+
self.locator = MainPageLocatars
15+
super().__init__(driver) # Python3 version
16+
1317
def check_page_loaded(self):
14-
return True if self.find_element(*MainPageLocatars.LOGO) else False
18+
return True if self.find_element(*self.locator.LOGO) else False
1519

1620
def search_item(self, item):
17-
self.find_element(*MainPageLocatars.SEARCH).send_keys(item)
18-
self.find_element(*MainPageLocatars.SEARCH).send_keys(Keys.ENTER)
19-
return self.find_element(*MainPageLocatars.SEARCH_LIST).text
21+
self.find_element(*self.locator.SEARCH).send_keys(item)
22+
self.find_element(*self.locator.SEARCH).send_keys(Keys.ENTER)
23+
return self.find_element(*self.locator.SEARCH_LIST).text
2024

2125
def click_sign_up_button(self):
22-
self.hover(*MainPageLocatars.ACCOUNT)
23-
self.find_element(*MainPageLocatars.SIGNUP).click()
26+
self.hover(*self.locator.ACCOUNT)
27+
self.find_element(*self.locator.SIGNUP).click()
2428
return SignUpPage(self.driver)
2529

2630
def click_sign_in_button(self):
27-
self.hover(*MainPageLocatars.ACCOUNT)
28-
self.find_element(*MainPageLocatars.LOGIN).click()
31+
self.hover(*self.locator.ACCOUNT)
32+
self.find_element(*self.locator.LOGIN).click()
2933
return LoginPage(self.driver)
3034

3135
class LoginPage(Page):
36+
def __init__(self, driver):
37+
self.locator = LoginPageLocatars
38+
super(LoginPage, self).__init__(driver) # Python2 version
39+
3240
def enter_email(self, user):
33-
self.find_element(*LoginPageLocatars.EMAIL).send_keys(users.get_user(user)["email"])
41+
self.find_element(*self.locator.EMAIL).send_keys(users.get_user(user)["email"])
3442

3543
def enter_password(self, user):
36-
self.find_element(*LoginPageLocatars.PASSWORD).send_keys(users.get_user(user)["password"])
44+
self.find_element(*self.locator.PASSWORD).send_keys(users.get_user(user)["password"])
3745

3846
def click_login_button(self):
39-
self.find_element(*LoginPageLocatars.SUBMIT).click()
47+
self.find_element(*self.locator.SUBMIT).click()
4048

4149
def login(self, user):
4250
self.enter_email(user)
@@ -49,7 +57,7 @@ def login_with_valid_user(self, user):
4957

5058
def login_with_in_valid_user(self, user):
5159
self.login(user)
52-
return self.find_element(*LoginPageLocatars.ERROR_MESSAGE).text
60+
return self.find_element(*self.locator.ERROR_MESSAGE).text
5361

5462
class HomePage(Page):
5563
pass

0 commit comments

Comments
 (0)