|
1 | | -from base.base import BasePage |
| 1 | +"""BIAB Page object for automating interactions with the Multi-Agent Planner UI.""" |
| 2 | + |
2 | 3 | from playwright.sync_api import expect |
| 4 | +from base.base import BasePage |
3 | 5 |
|
4 | 6 |
|
5 | 7 | class BIABPage(BasePage): |
6 | | - WELCOME_PAGE_TITLE = ( |
7 | | - "//span[normalize-space()='Multi-Agent-Custom-Automation-Engine']" |
8 | | - ) |
9 | | - NEW_TASK_PROMPT = "//textarea[@id='newTaskPrompt']" |
10 | | - SEND_BUTTON = "//button[@class='send-button']" |
| 8 | + """Page object model for BIAB/Multi-Agent Planner workflow automation.""" |
| 9 | + |
| 10 | + WELCOME_PAGE_TITLE = "//span[normalize-space()='Multi-Agent Planner']" |
| 11 | + NEW_TASK_PROMPT = "//textarea[@placeholder='Tell us what needs planning, building, or connecting—we'll handle the rest.']" |
| 12 | + SEND_BUTTON = "//button[@type='button']" |
| 13 | + CREATING_PLAN = "//span[normalize-space()='Creating a plan']" |
11 | 14 | TASK_LIST = "//span[contains(text(),'1.')]" |
12 | | - NEW_TASK = "//button[@id='newTaskButton']" |
13 | | - MOBILE_PLAN = "//div[@class='columns']//div[1]//div[1]//div[1]" |
| 15 | + NEW_TASK = "//span[normalize-space()='New task']" |
| 16 | + MOBILE_PLAN = ( |
| 17 | + "//span[normalize-space()='Ask about roaming plans prior to heading overseas.']" |
| 18 | + ) |
14 | 19 | MOBILE_TASK1 = "//span[contains(text(),'1.')]" |
15 | 20 | MOBILE_TASK2 = "//span[contains(text(),'2.')]" |
16 | 21 | MOBILE_APPROVE_TASK1 = "i[title='Approve']" |
17 | | - ADDITIONAL_INFO = "//textarea[@id='taskMessageTextarea']" |
18 | | - ADDITIONAL_INFO_SEND_BUTTON = "//button[@id='taskMessageAddButton']" |
19 | | - STAGES = "//i[@title='Approve']" |
| 22 | + ADDITIONAL_INFO = "//textarea[@placeholder='Add more info to this task...']" |
| 23 | + ADDITIONAL_INFO_SEND_BUTTON = ( |
| 24 | + "//div[@class='plan-chat-input-wrapper']//div//div//div//div[@role='toolbar']" |
| 25 | + ) |
| 26 | + STAGES = "//button[@aria-label='Approve']" |
| 27 | + RAI_PROMPT_VALIDATION = "//span[normalize-space()='Failed to create plan']" |
| 28 | + COMPLETED_TASK = "//span[@class='fui-Text ___13vod6f fk6fouc fy9rknc fwrc4pm figsok6 fpgzoln f1w7gpdv f6juhto f1gl81tg f2jf649']" |
20 | 29 |
|
21 | 30 | def __init__(self, page): |
| 31 | + """Initialize the BIABPage with a Playwright page instance.""" |
22 | 32 | super().__init__(page) |
23 | 33 | self.page = page |
24 | 34 |
|
25 | 35 | def click_my_task(self): |
26 | | - # self.page.locator(self.TASK_LIST).click() |
27 | | - # self.page.wait_for_timeout(2000) |
| 36 | + """Click on the 'My Task' item in the UI.""" |
28 | 37 | self.page.locator(self.TASK_LIST).click() |
29 | 38 | self.page.wait_for_timeout(10000) |
30 | 39 |
|
31 | 40 | def enter_aditional_info(self, text): |
32 | | - additional_info = self.page.frame("viewIframe").locator(self.ADDITIONAL_INFO) |
| 41 | + """Enter additional info and click the send button.""" |
| 42 | + additional_info = self.page.locator(self.ADDITIONAL_INFO) |
33 | 43 |
|
34 | | - if (additional_info).is_enabled(): |
| 44 | + if additional_info.is_enabled(): |
35 | 45 | additional_info.fill(text) |
36 | 46 | self.page.wait_for_timeout(5000) |
37 | | - # Click on send button in question area |
38 | | - self.page.frame("viewIframe").locator( |
39 | | - self.ADDITIONAL_INFO_SEND_BUTTON |
40 | | - ).click() |
| 47 | + self.page.locator(self.ADDITIONAL_INFO_SEND_BUTTON).click() |
41 | 48 | self.page.wait_for_timeout(5000) |
42 | 49 |
|
43 | 50 | def click_send_button(self): |
44 | | - # Click on send button in question area |
45 | | - self.page.frame("viewIframe").locator(self.SEND_BUTTON).click() |
46 | | - self.page.wait_for_timeout(25000) |
47 | | - # self.page.wait_for_load_state('networkidle') |
| 51 | + """Click the send button and wait for 'Creating a plan' to disappear.""" |
| 52 | + self.page.locator(self.SEND_BUTTON).click() |
| 53 | + expect(self.page.locator("span", has_text="Creating a plan")).to_be_visible() |
| 54 | + self.page.locator("span", has_text="Creating a plan").wait_for( |
| 55 | + state="hidden", timeout=30000 |
| 56 | + ) |
| 57 | + self.page.wait_for_timeout(2000) |
48 | 58 |
|
49 | 59 | def validate_rai_validation_message(self): |
50 | | - # Click on send button in question area |
51 | | - self.page.frame("viewIframe").locator(self.SEND_BUTTON).click() |
| 60 | + """Validate RAI prompt error message visibility.""" |
| 61 | + self.page.locator(self.SEND_BUTTON).click() |
52 | 62 | self.page.wait_for_timeout(1000) |
53 | | - expect( |
54 | | - self.page.frame("viewIframe").locator("//div[@class='notyf-announcer']") |
55 | | - ).to_have_text("Unable to create plan for this task.") |
| 63 | + expect(self.page.locator(self.RAI_PROMPT_VALIDATION)).to_be_visible( |
| 64 | + timeout=10000 |
| 65 | + ) |
56 | 66 | self.page.wait_for_timeout(3000) |
57 | 67 |
|
58 | 68 | def click_aditional_send_button(self): |
59 | | - # Click on send button in question area |
60 | | - self.page.frame("viewIframe").locator(self.ADDITIONAL_INFO_SEND_BUTTON).click() |
| 69 | + """Click the additional info send button.""" |
| 70 | + self.page.locator(self.ADDITIONAL_INFO_SEND_BUTTON).click() |
61 | 71 | self.page.wait_for_timeout(5000) |
62 | 72 |
|
63 | 73 | def click_new_task(self): |
| 74 | + """Click the 'New Task' button.""" |
64 | 75 | self.page.locator(self.NEW_TASK).click() |
65 | 76 | self.page.wait_for_timeout(5000) |
66 | 77 |
|
67 | 78 | def click_mobile_plan(self): |
68 | | - self.page.frame("viewIframe").locator(self.MOBILE_PLAN).click() |
| 79 | + """Click on a specific mobile plan in the task list.""" |
| 80 | + self.page.locator(self.MOBILE_PLAN).click() |
69 | 81 | self.page.wait_for_timeout(3000) |
70 | 82 |
|
71 | 83 | def validate_home_page(self): |
| 84 | + """Validate that the home page title is visible.""" |
72 | 85 | expect(self.page.locator(self.WELCOME_PAGE_TITLE)).to_be_visible() |
73 | 86 |
|
74 | 87 | def enter_a_question(self, text): |
75 | | - # Type a question in the text area |
76 | | - # self.page.pause() |
77 | | - self.page.frame("viewIframe").locator(self.NEW_TASK_PROMPT).fill(text) |
78 | | - self.page.wait_for_timeout(5000) |
| 88 | + """Enter a question in the prompt textbox.""" |
| 89 | + self.page.get_by_role("textbox", name="Tell us what needs planning,").fill(text) |
| 90 | + self.page.wait_for_timeout(4000) |
79 | 91 |
|
80 | 92 | def processing_different_stage(self): |
81 | | - if self.page.frame("viewIframe").locator(self.STAGES).count() >= 1: |
82 | | - for i in range(self.page.frame("viewIframe").locator(self.STAGES).count()): |
83 | | - approve_stages = ( |
84 | | - self.page.frame("viewIframe").locator(self.STAGES).nth(0) |
85 | | - ) |
| 93 | + """Process and approve each stage sequentially if present.""" |
| 94 | + self.page.wait_for_timeout(3000) |
| 95 | + if self.page.locator(self.STAGES).count() >= 1: |
| 96 | + for _ in range(self.page.locator(self.STAGES).count()): |
| 97 | + approve_stages = self.page.locator(self.STAGES).nth(0) |
86 | 98 | approve_stages.click() |
87 | | - self.page.wait_for_timeout(10000) |
88 | | - BasePage.validate_response_status(self) |
89 | | - self.page.wait_for_timeout(10000) |
90 | | - expect( |
91 | | - self.page.frame("viewIframe").locator("//tag[@id='taskStatusTag']") |
92 | | - ).to_have_text("Completed") |
93 | | - expect( |
94 | | - self.page.frame("viewIframe").locator("//div[@id='taskProgressPercentage']") |
95 | | - ).to_have_text("100%") |
| 99 | + self.page.wait_for_timeout(2000) |
| 100 | + self.page.locator( |
| 101 | + "//span[normalize-space()='Step approved successfully']" |
| 102 | + ).wait_for(state="visible", timeout=30000) |
| 103 | + |
| 104 | + plan_id = BasePage.get_first_plan_id(self) |
| 105 | + BasePage.approve_plan_by_id(self, plan_id) |
| 106 | + |
| 107 | + expect(self.page.locator(self.COMPLETED_TASK)).to_contain_text("completed") |
0 commit comments