Skip to content

Commit 72b61ca

Browse files
fixed the pylint issues in ui automation files
1 parent 1c5e596 commit 72b61ca

File tree

5 files changed

+48
-56
lines changed

5 files changed

+48
-56
lines changed

tests/e2e-test/base/base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def validate_response_status(self, question_api=""):
4545
"response code is " + str(response.status) + " " + str(response.json())
4646
)
4747

48-
4948
def validate_generate_response_status(self, question_api=""):
5049
load_dotenv() # Ensure environment variables are loaded
5150
# URL of the API endpoint
@@ -75,5 +74,3 @@ def validate_generate_response_status(self, question_api=""):
7574
assert response.status == 200, (
7675
"response code is " + str(response.status) + " " + str(response.json())
7776
)
78-
79-

tests/e2e-test/config/constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import json
32
from dotenv import load_dotenv
43

54
load_dotenv()

tests/e2e-test/pages/draftPage.py

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1+
import time
2+
import os
13
from base.base import BasePage
24
from pytest_check import check
3-
from config.constants import *
45
import logging
56
logger = logging.getLogger(__name__)
6-
import time
77

88

99
class DraftPage(BasePage):
1010
Draft_Sections = "//textarea"
1111
Draft_headings = "//span[@class='fui-Text ___nl2uoq0 fk6fouc f4ybsrx f1i3iumi f16wzh4i fpgzoln f1w7gpdv f6juhto f1gl81tg f2jf649 fepr9ql febqm8h']"
1212
invalid_response = "The requested information is not available in the retrieved data. Please try another query or topic."
1313
invalid_response1 = "There was an issue fetching your data. Please try again."
14-
1514

1615
def __init__(self, page):
1716
self.page = page
@@ -74,8 +73,8 @@ def validate_draft_sections_loaded(self):
7473
logger.info(f"✅ Section '{title_text}' loaded after Generate + Confirm.")
7574
content_loaded = True
7675
break
77-
except:
78-
pass
76+
except Exception as e:
77+
logger.info(f"⏳ Waiting for section '{title_text}' to load... {e}")
7978
time.sleep(1)
8079

8180
if not content_loaded:
@@ -90,8 +89,8 @@ def validate_draft_sections_loaded(self):
9089
logger.info(f"✅ Section '{title_text}' loaded successfully.")
9190
content_loaded = True
9291
break
93-
except:
94-
pass
92+
except Exception as e:
93+
logger.info(f"⏳ Waiting for section '{title_text}' to load... {e}")
9594
time.sleep(poll_interval)
9695

9796
# Step 2: If still not loaded, click Generate and retry
@@ -114,8 +113,8 @@ def validate_draft_sections_loaded(self):
114113
logger.info(f"✅ Section '{title_text}' loaded after clicking Generate.")
115114
content_loaded = True
116115
break
117-
except:
118-
pass
116+
except Exception as e:
117+
logger.info(f"⏳ Waiting for section '{title_text}' to load after Generate... {e}")
119118
time.sleep(poll_interval)
120119

121120
if not content_loaded:
@@ -133,42 +132,41 @@ def validate_draft_sections_loaded(self):
133132
continue
134133

135134
try:
136-
content = content_locator.text_content(timeout=2000).strip()
137-
with check:
138-
if content == self.invalid_response or content == self.invalid_response1:
139-
logger.warning(f"❌ Invalid response found in '{title_text}'. Retrying Generate + Confirm...")
140-
135+
content = content_locator.text_content(timeout=2000).strip()
136+
with check:
137+
if content == self.invalid_response or content == self.invalid_response1:
138+
logger.warning(f"❌ Invalid response found in '{title_text}'. Retrying Generate + Confirm...")
139+
140+
try:
141+
generate_btn.click()
142+
self.page.wait_for_timeout(3000)
143+
144+
confirm_btn = self.page.locator("//button[@class='fui-Button r1alrhcs ___zqkcn80 fd1o0ie fjxutwb fwiml72 fj8njcf fzcpov4 f1d2rq10 f1mk8lai ff3glw6']")
145+
if confirm_btn.is_visible(timeout=3000):
146+
confirm_btn.click()
147+
logger.info(f"🟢 Retried Confirm for section '{title_text}'")
148+
else:
149+
logger.warning(f"⚠️ Confirm button not visible during retry for '{title_text}'")
150+
except Exception as e:
151+
logger.error(f"❌ Retry Generate/Confirm failed: {e}")
152+
153+
retry_start = time.time()
154+
while time.time() - retry_start < short_wait:
141155
try:
142-
generate_btn.click()
143-
self.page.wait_for_timeout(3000)
144-
145-
confirm_btn = self.page.locator("//button[@class='fui-Button r1alrhcs ___zqkcn80 fd1o0ie fjxutwb fwiml72 fj8njcf fzcpov4 f1d2rq10 f1mk8lai ff3glw6']")
146-
if confirm_btn.is_visible(timeout=3000):
147-
confirm_btn.click()
148-
logger.info(f"🟢 Retried Confirm for section '{title_text}'")
149-
else:
150-
logger.warning(f"⚠️ Confirm button not visible during retry for '{title_text}'")
156+
content = content_locator.text_content(timeout=2000).strip()
157+
if content and content not in [self.invalid_response, self.invalid_response1]:
158+
logger.info(f"✅ Section '{title_text}' fixed after retry.")
159+
break
151160
except Exception as e:
152-
logger.error(f"❌ Retry Generate/Confirm failed: {e}")
153-
154-
retry_start = time.time()
155-
while time.time() - retry_start < short_wait:
156-
try:
157-
content = content_locator.text_content(timeout=2000).strip()
158-
if content and content not in [self.invalid_response, self.invalid_response1]:
159-
logger.info(f"✅ Section '{title_text}' fixed after retry.")
160-
break
161-
except:
162-
pass
163-
time.sleep(1)
164-
165-
with check:
166-
check.not_equal(content, self.invalid_response, f"❌ '{title_text}' still has invalid response after retry")
167-
check.not_equal(content, self.invalid_response1, f"❌ '{title_text}' still has invalid response after retry")
168-
169-
else:
170-
logger.info(f"🎯 Section '{title_text}' has valid content.")
171-
except Exception as e:
172-
logger.error(f"❌ Could not validate content for '{title_text}': {e}")
161+
logger.info(f"⏳ Retrying section '{title_text}'... {e}")
162+
time.sleep(1)
163+
164+
with check:
165+
check.not_equal(content, self.invalid_response, f"❌ '{title_text}' still has invalid response after retry")
166+
check.not_equal(content, self.invalid_response1, f"❌ '{title_text}' still has invalid response after retry")
173167

174-
logger.info(f"✔️ Completed section: '{title_text}'\n")
168+
else:
169+
logger.info(f"🎯 Section '{title_text}' has valid content.")
170+
except Exception as e:
171+
logger.error(f"❌ Could not validate content for '{title_text}': {e}")
172+
logger.info(f"✔️ Completed section: '{title_text}'\n")

tests/e2e-test/pages/generatePage.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from asyncio.log import logger
21
from base.base import BasePage
32
from playwright.sync_api import expect
43
import logging
@@ -41,7 +40,7 @@ def click_send_button(self):
4140
msg = "❌ TIMED-OUT: Not recieved response within 60 sec."
4241
logger.info(msg) # ✅ log to console/log file
4342
raise AssertionError(msg)
44-
43+
4544
finally:
4645
if stop_button.is_visible():
4746
stop_button.click()

tests/e2e-test/tests/test_gp_docgen.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ def test_generate_prompt(setup_pages, question, request):
126126
logger.info(f"Attempt {attempt}: Entering Generate Question: {question}")
127127
generate.enter_a_question(question)
128128
generate.click_send_button()
129-
#generate.validate_generate_response_status(question_api=question)
130-
129+
# generate.validate_generate_response_status(question_api=question)
131130

132131
time.sleep(2)
133132
response_text = page.locator("//p")
@@ -136,7 +135,7 @@ def test_generate_prompt(setup_pages, question, request):
136135
).text_content()
137136

138137
if latest_response not in [invalid_response, invalid_response1]:
139-
logger.info(f"Valid response received on attempt {attempt}")
138+
logger.info(f"Valid response received on attempt {attempt}")
140139
break
141140
else:
142141
logger.warning(f"Invalid response received on attempt {attempt}")
@@ -166,7 +165,7 @@ def test_add_section_prompt(setup_pages, question, request):
166165
logger.info(f"Entering Add Section Question: {question}")
167166
generate.enter_a_question(question)
168167
generate.click_send_button()
169-
#generate.validate_generate_response_status(question_api=question)
168+
# generate.validate_generate_response_status(question_api=question)
170169
except Exception as e:
171170
logger.error(f"FAILED while validating Add Section Prompt '{question}': {e}")
172171
raise
@@ -185,7 +184,7 @@ def test_generate_draft_from_section_prompt(setup_pages, request):
185184
try:
186185
logger.info("Clicking 'Generate Draft' and validating sections.")
187186
generate.click_generate_draft_button()
188-
#draft.validate_draft_sections()
187+
# draft.validate_draft_sections()
189188
draft.validate_draft_sections_loaded()
190189
except Exception as e:
191190
logger.error(f"FAILED while generating or validating draft sections: {e}")

0 commit comments

Comments
 (0)