Generation

generate functionMon, 29 May 2023

web page test automation

from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait driver = webdriver.Chrome('<path to chromedriver>') # Get the test url from a text file with open('test_urls.txt') as f: test_urls = f.readlines() # Get the API key from a text file with open('api_key.txt') as f: api_key = f.readlines()[0] base_url = "https://www.webpagetest.org/" url = base_url + "runtest.php?url=" + test_urls[0] + "&k=" + api_key + "&f=json" # Run the test driver.get(url) # Wait for the test to finish WebDriverWait(driver, 120).until(lambda driver: driver.find_element_by_id('LoadTime')) # Get the test results Id test

Want to kickstart your project?Use the new AI Studio to create your code