Skip to content

Commit 34b4da2

Browse files
Merge pull request #685 from Brain-up/issue_402
Issue_402_GROUPS_PAGE_links
2 parents df245fa + ac817a0 commit 34b4da2

3 files changed

Lines changed: 43 additions & 22 deletions

File tree

locators/groups_page_locators.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class GroupsPageLocators:
1818
PAGE_TILES = (By.CSS_SELECTOR, ".list-item")
1919
PAGE_TITLE = (By.TAG_NAME, "h3")
2020
PAGE_SUBTITLES = (By.XPATH, "//button/h4")
21+
PAGE_SUBTITLE2 = (By.XPATH, "(//button/h4)[2]")
2122

2223

2324
class HeaderLocators:

pages/groups_page.py

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -171,49 +171,71 @@ def get_links_status_codes(self):
171171
@allure.step("Click on links on the 'ru' local and thereby open corresponding web pages in the same tab")
172172
def click_on_links_on_ru_local(self):
173173
opened_pages = []
174+
starting_url = self.driver.current_url
175+
print(starting_url)
174176

175177
link1 = self.element_is_present_and_clickable(self.locators.PAGE_LINK1)
176-
current_url = self.driver.current_url
178+
# current_url = self.driver.current_url
177179
link1.click()
178-
Wait(self.driver, 10).until(EC.url_changes(current_url))
180+
181+
# Waiting for the first URL change (intermediate page)
182+
Wait(self.driver, 10).until(EC.url_changes(starting_url))
183+
intermediate_url = self.driver.current_url
184+
print(intermediate_url)
185+
186+
# Waiting for the second URL change (aimed page)
187+
Wait(self.driver, 10).until(EC.url_changes(intermediate_url))
188+
current_url = self.driver.current_url
189+
print(current_url)
190+
179191
opened_pages.append(self.get_current_tab_url())
192+
180193
self.element_is_present_and_clickable(self.locators1.LOGO_LINK).click()
194+
starting_url = self.driver.current_url
195+
print(starting_url)
196+
197+
# Waiting for the starting page loading
198+
Wait(self.driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, "h3")))
199+
181200
link2 = self.element_is_present_and_clickable(self.locators.PAGE_LINK2)
182-
current_url = self.driver.current_url
201+
# current_url = self.driver.current_url
183202
link2.click()
184-
Wait(self.driver, 10).until(EC.url_changes(current_url))
203+
204+
# Waiting for the first URL change (intermediate page)
205+
Wait(self.driver, 10).until(EC.url_changes(starting_url))
206+
intermediate_url = self.driver.current_url
207+
print(intermediate_url)
208+
209+
# Waiting for the second URL change (aimed page)
210+
Wait(self.driver, 10).until(EC.url_changes(intermediate_url))
211+
current_url = self.driver.current_url
212+
print(current_url)
213+
214+
# Wait(self.driver, 10).until(EC.url_changes(current_url))
215+
185216
opened_pages.append(self.get_current_tab_url())
217+
print(opened_pages)
186218

187219
return opened_pages
188220

189221
@allure.step("Click on links on the 'en' local and thereby open corresponding web pages in the same tab")
190222
def click_on_links_on_en_local(self):
191223
opened_pages = []
192224
starting_url = self.driver.current_url
193-
print(starting_url)
194225

195226
link1 = self.element_is_present_and_clickable(self.locators.PAGE_LINK1)
196227
link1.click()
197228

198229
# Waiting for the first URL change (intermediate page)
199230
Wait(self.driver, 10).until(EC.url_changes(starting_url))
200231
intermediate_url = self.driver.current_url
201-
print(intermediate_url)
202232

203233
# Waiting for the second URL change (aimed page)
204234
Wait(self.driver, 10).until(EC.url_changes(intermediate_url))
205-
current_url = self.driver.current_url
206-
print(current_url)
207-
208235
opened_pages.append(self.get_current_tab_url())
209236

210237
self.driver.back()
211-
intermediate_url = self.driver.current_url
212-
print(intermediate_url)
213-
214238
self.driver.back()
215-
starting_url = self.driver.current_url
216-
print(starting_url)
217239

218240
# Waiting for the starting page loading
219241
Wait(self.driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, "h3")))
@@ -224,12 +246,9 @@ def click_on_links_on_en_local(self):
224246
# Waiting for the first URL change (intermediate page)
225247
Wait(self.driver, 10).until(EC.url_changes(starting_url))
226248
intermediate_url = self.driver.current_url
227-
print(intermediate_url)
228249

229250
# Waiting for the second URL change (aimed page)
230251
Wait(self.driver, 10).until(EC.url_changes(intermediate_url))
231-
current_url = self.driver.current_url
232-
print(current_url)
233252

234253
opened_pages.append(self.get_current_tab_url())
235254
print(opened_pages)

tests/conftest.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from pages.contributors_page import ContributorsPage
2222
from pages.groups_page import GroupsPage
2323
from pages.profile_page import ProfilePage
24+
from test_data.groups_page_data import GroupsPageData
2425
from test_data.links import MainPageLinks, ExercisesUrls
2526

2627
load_dotenv()
@@ -60,14 +61,14 @@ def description_page_open(driver):
6061
def groups_ru_page_open1(driver, auto_test_user_authorized):
6162
page = GroupsPage(driver)
6263
ru_button = page.element_is_present_and_clickable(huLocators.RU_BUTTON)
63-
subtitles_before = [el.text for el in page.elements_are_located(GroupsPageLocators.PAGE_SUBTITLES)]
6464
ru_button.click()
6565

66-
def subtitles_changed(driver):
67-
current_subtitles = [el.text for el in page.elements_are_located(GroupsPageLocators.PAGE_SUBTITLES)]
68-
return current_subtitles != subtitles_before and all(current_subtitles)
66+
def subtitle2(driver):
67+
subtitle2 = driver.find_element(*GroupsPageLocators.PAGE_SUBTITLE2).text
68+
print(subtitle2)
69+
return subtitle2 in GroupsPageData.page_subtitles_ru
6970

70-
Wait(driver, 20).until(subtitles_changed)
71+
Wait(driver, 20).until(subtitle2)
7172
page.elements_are_visible(GroupsPageLocators.PAGE_SUBTITLES)
7273

7374

0 commit comments

Comments
 (0)