Skip to content

Commit ead2f9f

Browse files
committed
add css locator for identifing all buttons at once
add a test counting the buttons using this method
1 parent e9debe1 commit ead2f9f

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

Ultimateqa/pages/SubPages/sub_page_buttons.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class SubPageButtons:
55
def __init__(self, page: Page):
66
self.page = page
77
self.some_element = self.page.locator("#subpage1_element")
8+
self.all_buttons= self.page.locator("[class^='et_pb_button_']")
89

910
def locate_button(self, index: int):
1011
return self.page.locator(f'.et_pb_button_{index}')
@@ -22,4 +23,6 @@ def count_buttons(self):
2223
while self.does_button_exist(count):
2324
count += 1
2425
return count
26+
def count_buttons_by_class(self):
27+
return self.all_buttons.count()
2528

Ultimateqa/ui_tests/test_fe.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1-
from dotenv import load_dotenv
2-
import os
31
import pytest
4-
5-
import sys
6-
7-
#from conftest import base_url
8-
9-
sys.path.append('/Users/amielpeled/PycharmProjects/test-force-point/ForcePoint/Ultimateqa')
10-
112
from playwright.sync_api import Page
123
from Ultimateqa.pages.SubPages.sub_page_buttons import SubPageButtons
13-
from Ultimateqa.pages.SubPages.sub_page_buttons import SubPageButtons
144
from Ultimateqa.pages.SubPages.sub_page_social_media import SubPageSocialMedia
155
from Ultimateqa.pages.SubPages.sub_page_forms import SubPageForms
166
import Ultimateqa.ui_tests.consts as consts
@@ -21,9 +11,22 @@ def test_count_buttons(page: Page, base_url_fe):
2111
sub_page_buttons = SubPageButtons(page)
2212

2313
count_of_buttons = sub_page_buttons.count_buttons()
14+
2415
assert count_of_buttons == consts.NUN_OF_BUTTONS_TO_FIND, \
2516
f"Found: {count_of_buttons} buttons, expected: {consts.NUN_OF_BUTTONS_TO_FIND}"
2617

18+
count_all_buttons_using_css = sub_page_buttons.all_buttons.count()
19+
assert count_all_buttons_using_css == consts.NUN_OF_BUTTONS_TO_FIND, \
20+
f"Found: {count_of_buttons} buttons, expected: {consts.NUN_OF_BUTTONS_TO_FIND}"
21+
22+
def test_count_buttons_using_css(page: Page, base_url_fe):
23+
page.goto(base_url_fe)
24+
sub_page_buttons = SubPageButtons(page)
25+
26+
count_all_buttons_using_css = sub_page_buttons.all_buttons.count()
27+
assert count_all_buttons_using_css == consts.NUN_OF_BUTTONS_TO_FIND, \
28+
f"Found: {count_all_buttons_using_css} buttons, expected: {consts.NUN_OF_BUTTONS_TO_FIND}"
29+
2730

2831
def test_verify_href_link(page: Page, base_url_fe):
2932
# load_dotenv()

0 commit comments

Comments
 (0)