33import os .path
44
55from base .base import BasePage
6+ from config .constants import URL
67
78from playwright .sync_api import expect
89
@@ -48,10 +49,20 @@ class HomePage(BasePage):
4849
4950 # Harmful file validation message
5051 ERROR_MSG_UNABLE_TO_PROCESS = "//span[normalize-space()='Unable to process the file']"
52+ HARMFUL_FILE_2 = "//span[.='harmful_content_2 2.sql']"
53+
5154
5255 def __init__ (self , page ):
5356 self .page = page
5457
58+ def navigate_to_base_url (self ):
59+ """
60+ Navigate to the base URL and wait for page load.
61+ """
62+ self .page .goto (URL , wait_until = "domcontentloaded" )
63+ self .page .wait_for_timeout (2000 )
64+ logger .info (f"Navigated to base URL: { URL } " )
65+
5566 def validate_home_page (self ):
5667 expect (self .page .locator (self .TITLE_TEXT )).to_be_visible ()
5768
@@ -62,27 +73,27 @@ def upload_files(self):
6273 self .page .wait_for_load_state ("networkidle" )
6374 file_chooser = fc_info .value
6475 current_working_dir = os .getcwd ()
65- file_path1 = os .path .join (current_working_dir , "testdata/Valid_files /q1_informix.sql" )
66- file_path2 = os .path .join (current_working_dir , "testdata/Valid_files /f1.sql" )
67- file_path3 = os .path .join (current_working_dir , "testdata/Valid_files /f2.sql" )
76+ file_path1 = os .path .join (current_working_dir , "testdata/valid_files /q1_informix.sql" )
77+ file_path2 = os .path .join (current_working_dir , "testdata/valid_files /f1.sql" )
78+ file_path3 = os .path .join (current_working_dir , "testdata/valid_files /f2.sql" )
6879 file_chooser .set_files ([file_path1 , file_path2 , file_path3 ])
6980 self .page .wait_for_timeout (10000 )
7081 self .page .wait_for_load_state ("networkidle" )
7182 expect (self .page .locator (self .SUCCESS_MSG )).to_be_visible ()
7283
7384 def upload_all_files (self ):
7485 """
75- Upload all files present in the testdata/Valid_files folder.
86+ Upload all files present in the testdata/valid_files folder.
7687 """
7788 with self .page .expect_file_chooser () as fc_info :
7889 self .page .locator (self .BROWSE_FILES ).click ()
7990 self .page .wait_for_timeout (5000 )
8091 self .page .wait_for_load_state ("networkidle" )
8192 file_chooser = fc_info .value
8293 current_working_dir = os .getcwd ()
83- testdata_dir = os .path .join (current_working_dir , "testdata/Valid_files " )
84-
85- # Get all files from testdata/Valid_files folder
94+ testdata_dir = os .path .join (current_working_dir , "testdata/valid_files " )
95+
96+ # Get all files from testdata/valid_files folder
8697 all_files = []
8798 if os .path .exists (testdata_dir ) and os .path .isdir (testdata_dir ):
8899 for filename in os .listdir (testdata_dir ):
@@ -127,7 +138,7 @@ def remove_first_three_files_and_validate_count(self):
127138 remove_buttons = self .page .locator (self .REMOVE_FILE_BTN )
128139
129140 # Remove first three files
130- for _i in range (3 ):
141+ for i in range (3 ):
131142 remove_buttons .first .click ()
132143 self .page .wait_for_timeout (2000 )
133144
@@ -253,7 +264,12 @@ def upload_harmful_file_and_validate(self):
253264 self .page .wait_for_timeout (10000 )
254265 self .page .wait_for_load_state ("networkidle" )
255266 logger .info ("Translation process started" )
256-
267+
268+ # Click on harmful_content_2 2.sql file
269+ self .page .locator (self .HARMFUL_FILE_2 ).click ()
270+ self .page .wait_for_timeout (2000 )
271+ logger .info ("Clicked on harmful_content_2 2.sql file" )
272+
257273 # Validate error message is visible
258274 try :
259275 expect (self .page .locator (self .ERROR_MSG_UNABLE_TO_PROCESS )).to_be_visible (timeout = 200000 )
@@ -280,7 +296,7 @@ def upload_harmful_file_and_validate(self):
280296 def validate_translate (self ):
281297 self .page .locator (self .TRANSLATE_BTN ).click ()
282298 expect (self .page .locator (self .DOWNLOAD_FILES )).to_be_enabled (timeout = 200000 )
283- self .page .locator (self .SUMMARY ).click ()
299+ self .page .locator (self .SUMMARY ).first . click ()
284300 expect (self .page .locator (self .FILE_PROCESSED_MSG )).to_be_visible ()
285301 self .page .wait_for_timeout (3000 )
286302
0 commit comments