173 lines
6.7 KiB
Python
173 lines
6.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Selenium test for production materials page styling
|
|
Tests tilbudsgiveren.alw.dk for Excel-style CSS
|
|
"""
|
|
|
|
from selenium import webdriver
|
|
from selenium.webdriver.common.by import By
|
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
from selenium.webdriver.support import expected_conditions as EC
|
|
from selenium.webdriver.chrome.options import Options
|
|
import time
|
|
|
|
def test_production_materials_styling():
|
|
"""Test that production site has correct Excel styling"""
|
|
|
|
# Setup Chrome with headless option
|
|
chrome_options = Options()
|
|
chrome_options.add_argument('--headless')
|
|
chrome_options.add_argument('--no-sandbox')
|
|
chrome_options.add_argument('--disable-dev-shm-usage')
|
|
chrome_options.add_argument('--disable-gpu')
|
|
chrome_options.add_argument('--window-size=1920,1080')
|
|
|
|
driver = webdriver.Chrome(options=chrome_options)
|
|
|
|
try:
|
|
print("=" * 60)
|
|
print("🔍 Testing Production Site: tilbudsgiveren.alw.dk")
|
|
print("=" * 60)
|
|
|
|
# Navigate to production materials page
|
|
prod_url = "http://tilbudsgiveren.alw.dk/materialer"
|
|
print(f"\n📍 Navigating to: {prod_url}")
|
|
driver.get(prod_url)
|
|
|
|
# Wait for page to load
|
|
time.sleep(3)
|
|
|
|
print("\n✅ Page loaded successfully")
|
|
print(f" Current URL: {driver.current_url}")
|
|
print(f" Page Title: {driver.title}")
|
|
|
|
# Check for materials table
|
|
print("\n🔍 Looking for materials table...")
|
|
try:
|
|
table = WebDriverWait(driver, 10).until(
|
|
EC.presence_of_element_located((By.CSS_SELECTOR, "table.materials-table"))
|
|
)
|
|
print("✅ Found table.materials-table")
|
|
except:
|
|
print("❌ Could not find table.materials-table")
|
|
print(" Available tables:")
|
|
tables = driver.find_elements(By.TAG_NAME, "table")
|
|
for i, t in enumerate(tables):
|
|
classes = t.get_attribute("class")
|
|
print(f" Table {i+1}: {classes if classes else '(no class)'}")
|
|
return False
|
|
|
|
# Get table header styling
|
|
print("\n🎨 Checking header styling...")
|
|
try:
|
|
headers = table.find_elements(By.TAG_NAME, "th")
|
|
if headers:
|
|
first_header = headers[0]
|
|
bg_color = driver.execute_script(
|
|
"return window.getComputedStyle(arguments[0]).backgroundColor;",
|
|
first_header
|
|
)
|
|
border = driver.execute_script(
|
|
"return window.getComputedStyle(arguments[0]).border;",
|
|
first_header
|
|
)
|
|
|
|
print(f" Header background: {bg_color}")
|
|
print(f" Header border: {border}")
|
|
|
|
# Check if it's gray (Excel style) or purple (old style)
|
|
if "242, 242, 242" in bg_color or "rgb(242, 242, 242)" in bg_color:
|
|
print(" ✅ Correct Excel gray header (#f2f2f2)")
|
|
elif "102, 126, 234" in bg_color or "118, 75, 162" in bg_color:
|
|
print(" ❌ WRONG: Still has purple gradient header")
|
|
print(" ⚠️ Old CSS is being served!")
|
|
return False
|
|
else:
|
|
print(f" ⚠️ Unexpected color: {bg_color}")
|
|
else:
|
|
print(" ❌ No headers found")
|
|
return False
|
|
except Exception as e:
|
|
print(f" ❌ Error checking headers: {e}")
|
|
return False
|
|
|
|
# Check cell styling
|
|
print("\n🔍 Checking cell styling...")
|
|
try:
|
|
cells = table.find_elements(By.TAG_NAME, "td")
|
|
if cells:
|
|
first_cell = cells[0]
|
|
bg_color = driver.execute_script(
|
|
"return window.getComputedStyle(arguments[0]).backgroundColor;",
|
|
first_cell
|
|
)
|
|
border = driver.execute_script(
|
|
"return window.getComputedStyle(arguments[0]).border;",
|
|
first_cell
|
|
)
|
|
|
|
print(f" Cell background: {bg_color}")
|
|
print(f" Cell border: {border}")
|
|
|
|
# Check for white background
|
|
if "255, 255, 255" in bg_color or "rgb(255, 255, 255)" in bg_color:
|
|
print(" ✅ Correct white cell background")
|
|
elif "rgba" in bg_color and "102, 126, 234" in bg_color:
|
|
print(" ❌ WRONG: Still has colored cell backgrounds")
|
|
print(" ⚠️ Old CSS is being served!")
|
|
return False
|
|
else:
|
|
print(f" Cell color: {bg_color}")
|
|
else:
|
|
print(" ❌ No cells found")
|
|
return False
|
|
except Exception as e:
|
|
print(f" ❌ Error checking cells: {e}")
|
|
return False
|
|
|
|
# Check for loaded CSS file
|
|
print("\n📄 Checking loaded CSS files...")
|
|
try:
|
|
css_links = driver.find_elements(By.CSS_SELECTOR, "link[rel='stylesheet']")
|
|
print(f" Found {len(css_links)} CSS files:")
|
|
for link in css_links:
|
|
href = link.get_attribute("href")
|
|
print(f" - {href}")
|
|
|
|
# Check for the new CSS file
|
|
if "main.c2326ed4.css" in href:
|
|
print(" ✅ NEW CSS FILE DETECTED (main.c2326ed4.css)")
|
|
print(" ✅ Production is serving the updated build!")
|
|
return True
|
|
elif "main." in href and ".css" in href:
|
|
print(f" ⚠️ Different CSS file: {href}")
|
|
print(" ⚠️ This is not the latest build!")
|
|
return False
|
|
except Exception as e:
|
|
print(f" ❌ Error checking CSS: {e}")
|
|
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"\n❌ Test failed with error: {e}")
|
|
return False
|
|
|
|
finally:
|
|
driver.quit()
|
|
print("\n" + "=" * 60)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
success = test_production_materials_styling()
|
|
|
|
if success:
|
|
print("\n✅ SUCCESS: Production site has correct Excel styling!")
|
|
exit(0)
|
|
else:
|
|
print("\n❌ FAILURE: Production site still shows old styling")
|
|
print("\n💡 Next steps:")
|
|
print(" 1. Check if production server needs restart")
|
|
print(" 2. Check if build folder needs to be copied to production")
|
|
print(" 3. Check if browser cache needs clearing")
|
|
exit(1)
|