From e9eefef1a08b756986ab25e5450b6d7dc2826280 Mon Sep 17 00:00:00 2001 From: Hammad1007 Date: Fri, 29 Dec 2023 16:05:42 +0500 Subject: [PATCH] Update the tests in selenium --- .../selenium/backgroundcolor.py | 28 ++++++++++++++++ 3d-boxes-background/selenium/homepage.py | 21 ++++++++++++ 3d-boxes-background/selenium/magicbutton.py | 32 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 3d-boxes-background/selenium/backgroundcolor.py create mode 100644 3d-boxes-background/selenium/homepage.py create mode 100644 3d-boxes-background/selenium/magicbutton.py diff --git a/3d-boxes-background/selenium/backgroundcolor.py b/3d-boxes-background/selenium/backgroundcolor.py new file mode 100644 index 0000000..e5232a1 --- /dev/null +++ b/3d-boxes-background/selenium/backgroundcolor.py @@ -0,0 +1,28 @@ +from selenium import webdriver +import time +from selenium.webdriver.chrome.service import Service +from selenium.webdriver.common.by import By +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.chrome.options import Options + +# Define Chrome WebDriver options +chrome_options = Options() +# chrome_options.add_argument("--headless") # Run headless if needed +service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver') + +# Initialize Chrome WebDriver +driver = webdriver.Chrome(service=service, options=chrome_options) + +# Open Google +driver.get('http://127.0.0.1:5500/3d-boxes-background') + +element = driver.find_element(By.TAG_NAME, 'body') + +# Get the CSS value for the 'background-color' property of the element +background_color = element.value_of_css_property('background-color') + +time.sleep(5) + +print('The color is: ', background_color) + +driver.quit() \ No newline at end of file diff --git a/3d-boxes-background/selenium/homepage.py b/3d-boxes-background/selenium/homepage.py new file mode 100644 index 0000000..2ea8828 --- /dev/null +++ b/3d-boxes-background/selenium/homepage.py @@ -0,0 +1,21 @@ +from selenium import webdriver +import time +from selenium.webdriver.chrome.service import Service +from selenium.webdriver.common.by import By +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.chrome.options import Options + +# Define Chrome WebDriver options +chrome_options = Options() +# chrome_options.add_argument("--headless") # Run headless if needed +service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver') + +# Initialize Chrome WebDriver +driver = webdriver.Chrome(service=service, options=chrome_options) + +# Open Google +driver.get('http://127.0.0.1:5500/3d-boxes-background') + +time.sleep(5) + +driver.quit() \ No newline at end of file diff --git a/3d-boxes-background/selenium/magicbutton.py b/3d-boxes-background/selenium/magicbutton.py new file mode 100644 index 0000000..53f9b99 --- /dev/null +++ b/3d-boxes-background/selenium/magicbutton.py @@ -0,0 +1,32 @@ +from selenium import webdriver +import time +from selenium.webdriver.chrome.service import Service +from selenium.webdriver.common.by import By +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.chrome.options import Options + +# Define Chrome WebDriver options +chrome_options = Options() +# chrome_options.add_argument("--headless") # Run headless if needed +service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver') + +# Initialize Chrome WebDriver +driver = webdriver.Chrome(service=service, options=chrome_options) + +# Open Google +driver.get('http://127.0.0.1:5500/3d-boxes-background') + +element = driver.find_element(By.CLASS_NAME, 'magic').click() + +bigbox = driver.find_element(By.CLASS_NAME, 'box') + +time.sleep(2) + +element = driver.find_element(By.CLASS_NAME, 'magic').click() + +bigbox = driver.find_element(By.ID, 'boxes') + +time.sleep(5) + +print('The button has been clicked successfully.') +driver.quit() \ No newline at end of file