1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- from selenium import webdriver
- from selenium.webdriver.chrome.service import Service as ChromeService
- from selenium.webdriver.chrome.options import Options
- from webdriver_manager.chrome import ChromeDriverManager
- import time
-
- # Function to prompt user for user ID
- def get_user_id():
- return input("Please enter your user ID: ")
-
- # Set up Chrome options
- chrome_options = Options()
- chrome_options.add_argument("--headless") # Run headless Chrome, comment out if you want to see the browser
-
- # Use WebDriverManager to automatically use the system's ChromeDriver
- service = ChromeService(ChromeDriverManager().install())
- driver = webdriver.Chrome(service=service, options=chrome_options)
-
- # Prompt user for user ID
- user_id = get_user_id()
-
- # List of paths to test
- paths = ['/', '/shop/', '/product/blue-sweater/', '/product/custom-tee/', '/product-category/clothing/dresses/']
-
- # Base URL
- base_url = f'http://{user_id}.cpr-akashop.com'
-
- # Function to measure load time
- def measure_load_time(url):
- start_time = time.time()
- driver.get(url)
- # Wait for the page to completely load (adjust as necessary)
- time.sleep(5) # Simple wait; use WebDriverWait for more precise control
- end_time = time.time()
- return end_time - start_time
-
- # Test each path
- for path in paths:
- full_url = base_url + path
- load_time = measure_load_time(full_url)
- print(f"Load time for {full_url}: {load_time:.2f} seconds")
-
- # Close the driver
- driver.quit()
|