Merge 9ab40486f4
into 236f68461b
commit
e7dfaae764
@ -0,0 +1,9 @@
|
||||
const { defineConfig } = require("cypress");
|
||||
|
||||
module.exports = defineConfig({
|
||||
e2e: {
|
||||
setupNodeEvents(on, config) {
|
||||
// implement node event listeners here
|
||||
},
|
||||
},
|
||||
});
|
@ -0,0 +1,150 @@
|
||||
describe('Project Theme Clock', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('http://127.0.0.1:5500/theme-clock/index.html')
|
||||
})
|
||||
|
||||
it('Opens the homepage', () => {
|
||||
|
||||
})
|
||||
|
||||
it('The screen is visible', () => {
|
||||
cy.get('body').should('be.visible')
|
||||
})
|
||||
|
||||
context('Body', () => {
|
||||
context('Background', () => {
|
||||
it('The background is visible', () => {
|
||||
cy.get('body').should('be.visible')
|
||||
})
|
||||
|
||||
it('The background has correct color', () => {
|
||||
cy.get('body').should('be.visible').should('have.css', 'background-color', 'rgba(0, 0, 0, 0)')
|
||||
})
|
||||
})
|
||||
|
||||
context('Content', () => {
|
||||
it('The clock container is visible', () => {
|
||||
cy.get('.clock-container').should('be.visible')
|
||||
})
|
||||
|
||||
context('Dark Mode button', () => {
|
||||
it('The button is visible', () => {
|
||||
cy.get('.toggle').should('be.visible')
|
||||
})
|
||||
|
||||
it('The button has correct background color', () => {
|
||||
cy.get('.toggle').should('be.visible').should('have.css', 'background-color', 'rgb(0, 0, 0)')
|
||||
})
|
||||
|
||||
it('The button should have correct text', () => {
|
||||
cy.get('.toggle').should('be.visible').should('have.text', 'Dark mode')
|
||||
})
|
||||
|
||||
it('The button is clickable', () => {
|
||||
cy.get('.toggle').should('be.visible').click()
|
||||
})
|
||||
|
||||
context('Dark mode button toggle', () => {
|
||||
it('The button is clickable', () => {
|
||||
cy.get('.toggle').should('be.visible').click()
|
||||
cy.get('.toggle').should('be.visible').should('have.text', 'Light mode')
|
||||
})
|
||||
|
||||
it('When the button is clicked, the background color turns black', () => {
|
||||
cy.get('.toggle').should('be.visible').click()
|
||||
cy.xpath('//html[@class="dark"]').should('be.visible')
|
||||
})
|
||||
|
||||
it('The color of the button is correct', () => {
|
||||
cy.get('.toggle').should('be.visible').click()
|
||||
cy.xpath('//html[@class="dark"]').should('be.visible')
|
||||
cy.get('.toggle').should('have.css', 'background-color', 'rgb(255, 255, 255)')
|
||||
})
|
||||
|
||||
it('The text time has white color', () => {
|
||||
cy.get('.toggle').should('be.visible').click()
|
||||
const currentTime = new Date()
|
||||
var hours = currentTime.getHours()
|
||||
const minutes = currentTime.getMinutes()
|
||||
const meridiem = hours >= 12 ? 'PM' : 'AM'
|
||||
hours = hours % 12 || 12
|
||||
const formattedMinutes = minutes < 10 ? `0${minutes}` : minutes
|
||||
const formattedTime = `${hours}:${formattedMinutes} ${meridiem}`
|
||||
cy.get('.time').should('have.text', formattedTime).should('have.css', 'color', 'rgb(255, 255, 255)')
|
||||
})
|
||||
|
||||
it('The span circle color is white', () => {
|
||||
cy.get('.toggle').should('be.visible').click()
|
||||
cy.get('.circle').should('have.css', 'background-color', 'rgb(255, 255, 255)')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
context('Clock', () => {
|
||||
it('The clock container has the clock displayed', () => {
|
||||
cy.get('.clock-container .clock').should('be.visible')
|
||||
})
|
||||
|
||||
context('Needles', () => {
|
||||
|
||||
it('The clock container has the hour needle', () => {
|
||||
cy.get('.clock-container .clock .needle.hour').should('be.visible')
|
||||
})
|
||||
|
||||
it('The clock container has the minute needle', () => {
|
||||
cy.get('.clock-container .clock .needle.minute').should('be.visible')
|
||||
})
|
||||
|
||||
it('The clock container has the second needle', () => {
|
||||
cy.get('.clock-container .clock .needle.second').should('be.visible')
|
||||
})
|
||||
|
||||
it('The clock container has the center point', () => {
|
||||
cy.get('.center-point').should('be.visible')
|
||||
})
|
||||
})
|
||||
|
||||
context('Text Time', () => {
|
||||
it('The time is being displayed in text format as well', () => {
|
||||
cy.get('.time').should('be.visible')
|
||||
})
|
||||
|
||||
it('The current time is being displayed', () => {
|
||||
const currentTime = new Date()
|
||||
var hours = currentTime.getHours()
|
||||
const minutes = currentTime.getMinutes()
|
||||
const meridiem = hours >= 12 ? 'PM' : 'AM'
|
||||
hours = hours % 12 || 12
|
||||
const formattedMinutes = minutes < 10 ? `0${minutes}` : minutes
|
||||
|
||||
const formattedTime = `${hours}:${formattedMinutes} ${meridiem}`
|
||||
|
||||
cy.get('.time').should('have.text', formattedTime)
|
||||
})
|
||||
})
|
||||
|
||||
context('Day, month, date', () => {
|
||||
it('The date is visible', () => {
|
||||
cy.get('.date').should('be.visible')
|
||||
})
|
||||
|
||||
it('The date, month and day is visible', () => {
|
||||
const currentDate = new Date();
|
||||
const day = currentDate.getDay();
|
||||
const month = currentDate.getMonth();
|
||||
const date = currentDate.getDate();
|
||||
|
||||
const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
||||
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
||||
|
||||
cy.get('.date').should('have.text', `${days[day]}, ${months[month]} ${date}`);
|
||||
})
|
||||
|
||||
it('The span circle color is black', () => {
|
||||
cy.get('.circle').should('have.css', 'background-color', 'rgb(0, 0, 0)')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add('login', (email, password) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||
|
||||
import 'cypress-xpath';
|
@ -0,0 +1,20 @@
|
||||
// ***********************************************************
|
||||
// This example support/e2e.js is processed and
|
||||
// loaded automatically before your test files.
|
||||
//
|
||||
// This is a great place to put global configuration and
|
||||
// behavior that modifies Cypress.
|
||||
//
|
||||
// You can change the location of this file or turn off
|
||||
// automatically serving support files with the
|
||||
// 'supportFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands'
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
@ -0,0 +1,38 @@
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
|
||||
# Define Chrome WebDriver options
|
||||
chrome_options = Options()
|
||||
service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver')
|
||||
|
||||
# Initialize Chrome WebDriver
|
||||
driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||
# Open the Flask application
|
||||
driver.get('http://127.0.0.1:5500/theme-clock/index.html')
|
||||
|
||||
# Find and click the button
|
||||
button = driver.find_element(By.XPATH, '/html/body/button')
|
||||
button.click()
|
||||
|
||||
try:
|
||||
|
||||
button = driver.find_element(By.XPATH, '/html/body/button')
|
||||
|
||||
# Retrieve properties
|
||||
text = button.text
|
||||
background_color = button.value_of_css_property('background-color')
|
||||
text_color = button.value_of_css_property('color')
|
||||
|
||||
print(f'The text in the button is {text}')
|
||||
print(f'The button background color is {background_color}')
|
||||
print(f'The text color is {text_color}')
|
||||
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
# Close the browser window
|
||||
driver.quit()
|
@ -0,0 +1,37 @@
|
||||
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()
|
||||
service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver')
|
||||
|
||||
# Initialize Chrome WebDriver
|
||||
driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||
# Open the Flask application
|
||||
driver.get('http://127.0.0.1:5500/theme-clock/index.html')
|
||||
|
||||
element = driver.find_element(By.XPATH, '/html/body/button')
|
||||
|
||||
text = element.text
|
||||
|
||||
background_color = element.value_of_css_property('background-color')
|
||||
|
||||
text_color = element.value_of_css_property('color')
|
||||
|
||||
if element:
|
||||
print('The button is found')
|
||||
else:
|
||||
print('The button has not been found')
|
||||
|
||||
print(f'The text in buton is {text}')
|
||||
|
||||
print(f'The button background color is {background_color}')
|
||||
|
||||
print(f'The text color is {text_color}')
|
||||
|
||||
# Close the browser window
|
||||
driver.quit()
|
@ -0,0 +1,44 @@
|
||||
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()
|
||||
service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver')
|
||||
|
||||
# Initialize Chrome WebDriver
|
||||
driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||
# Open the Flask application
|
||||
driver.get('http://127.0.0.1:5500/theme-clock/index.html')
|
||||
|
||||
element = driver.find_element(By.XPATH, '/html/body/div[1]/div[3]')
|
||||
|
||||
date_element = driver.find_element(By.XPATH, '/html/body/div[1]/div[3]/span')
|
||||
|
||||
text = element.text
|
||||
|
||||
background_color = element.value_of_css_property('background-color')
|
||||
|
||||
color = element.value_of_css_property('color')
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
if element:
|
||||
print('The complete date is found')
|
||||
else:
|
||||
print('The complete date is not found')
|
||||
|
||||
if date_element:
|
||||
print('The date has been found')
|
||||
else:
|
||||
print('The date hasn\'t been found')
|
||||
|
||||
print(f'Date is {text}')
|
||||
print(f'Background Color is {background_color}')
|
||||
print(f'Text color is {color}')
|
||||
|
||||
# Close the browser window
|
||||
driver.quit()
|
@ -0,0 +1,27 @@
|
||||
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()
|
||||
service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver')
|
||||
|
||||
# Initialize Chrome WebDriver
|
||||
driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||
# Open the Flask application
|
||||
driver.get('http://127.0.0.1:5500/theme-clock/index.html')
|
||||
|
||||
element = driver.find_element(By.XPATH, '//div[@class="clock-container"]')
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
if element:
|
||||
print('The clock is found.')
|
||||
else:
|
||||
print('The clock is not found.')
|
||||
|
||||
# Close the browser window
|
||||
driver.quit()
|
@ -0,0 +1,37 @@
|
||||
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()
|
||||
service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver')
|
||||
|
||||
# Initialize Chrome WebDriver
|
||||
driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||
# Open the Flask application
|
||||
driver.get('http://127.0.0.1:5500/theme-clock/index.html')
|
||||
|
||||
element = driver.find_element(By.XPATH, '/html/body/div[1]/div[2]')
|
||||
|
||||
text = element.text
|
||||
|
||||
background_color = element.value_of_css_property('background-color')
|
||||
|
||||
color = element.value_of_css_property('color')
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
if element:
|
||||
print('The time is found')
|
||||
else:
|
||||
print('The time is not found')
|
||||
|
||||
print(f'Time is {text}')
|
||||
print(f'Color is {background_color}')
|
||||
print(f'Text color is {color}')
|
||||
|
||||
# Close the browser window
|
||||
driver.quit()
|
@ -0,0 +1,31 @@
|
||||
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()
|
||||
service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver')
|
||||
|
||||
# Initialize Chrome WebDriver
|
||||
driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||
# Open the Flask application
|
||||
driver.get('http://127.0.0.1:5500/theme-clock/index.html')
|
||||
|
||||
element = driver.find_element(By.XPATH, '/html/body/div[1]/div[1]/div[1]')
|
||||
|
||||
color = element.value_of_css_property('background-color')
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
if element:
|
||||
print('The hour needle is found.')
|
||||
else:
|
||||
print('The hour needle is not found.')
|
||||
|
||||
print(f'The color of hour needle is: {color}')
|
||||
|
||||
# Close the browser window
|
||||
driver.quit()
|
@ -0,0 +1,31 @@
|
||||
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()
|
||||
service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver')
|
||||
|
||||
# Initialize Chrome WebDriver
|
||||
driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||
# Open the Flask application
|
||||
driver.get('http://127.0.0.1:5500/theme-clock/index.html')
|
||||
|
||||
element = driver.find_element(By.XPATH, '/html/body/div[1]/div[1]/div[2]')
|
||||
|
||||
color = element.value_of_css_property('background-color')
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
if element:
|
||||
print('The minute needle is found.')
|
||||
else:
|
||||
print('The minute needle is not found.')
|
||||
|
||||
print(f'The color of minute needle is: {color}')
|
||||
|
||||
# Close the browser window
|
||||
driver.quit()
|
@ -0,0 +1,31 @@
|
||||
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()
|
||||
service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver')
|
||||
|
||||
# Initialize Chrome WebDriver
|
||||
driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||
# Open the Flask application
|
||||
driver.get('http://127.0.0.1:5500/theme-clock/index.html')
|
||||
|
||||
element = driver.find_element(By.XPATH, '/html/body/div[1]/div[1]/div[3]')
|
||||
|
||||
color = element.value_of_css_property('background-color')
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
if element:
|
||||
print('The second needle is found.')
|
||||
else:
|
||||
print('The second needle is not found.')
|
||||
|
||||
print(f'The color of second needle is: {color}')
|
||||
|
||||
# Close the browser window
|
||||
driver.quit()
|
@ -0,0 +1,27 @@
|
||||
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()
|
||||
service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver')
|
||||
|
||||
# Initialize Chrome WebDriver
|
||||
driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||
# Open the Flask application
|
||||
driver.get('http://127.0.0.1:5500/theme-clock/index.html')
|
||||
|
||||
element = driver.find_element(By.XPATH, '//div[@class="clock"]')
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
if element:
|
||||
print('The clock is found.')
|
||||
else:
|
||||
print('The clock is not found.')
|
||||
|
||||
# Close the browser window
|
||||
driver.quit()
|
@ -0,0 +1,31 @@
|
||||
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()
|
||||
service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver')
|
||||
|
||||
# Initialize Chrome WebDriver
|
||||
driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||
# Open the Flask application
|
||||
driver.get('http://127.0.0.1:5500/theme-clock/index.html')
|
||||
|
||||
element = driver.find_element(By.TAG_NAME, 'body')
|
||||
|
||||
background_color = element.value_of_css_property('background-color')
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
if element:
|
||||
print('The body is found.')
|
||||
else:
|
||||
print('The body is not found.')
|
||||
|
||||
print(f'The background color is {background_color}')
|
||||
|
||||
# Close the browser window
|
||||
driver.quit()
|
@ -0,0 +1,27 @@
|
||||
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()
|
||||
service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver')
|
||||
|
||||
# Initialize Chrome WebDriver
|
||||
driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||
# Open the Flask application
|
||||
driver.get('http://127.0.0.1:5500/theme-clock/index.html')
|
||||
|
||||
element = driver.find_element(By.TAG_NAME, 'body')
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
if element:
|
||||
print('The body is found.')
|
||||
else:
|
||||
print('The body is not found.')
|
||||
|
||||
# Close the browser window
|
||||
driver.quit()
|
@ -0,0 +1,20 @@
|
||||
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()
|
||||
service = Service('/Users/mac005/Downloads/chromedriver-mac-arm64/chromedriver')
|
||||
|
||||
# Initialize Chrome WebDriver
|
||||
driver = webdriver.Chrome(service=service, options=chrome_options)
|
||||
# Open the Flask application
|
||||
driver.get('http://127.0.0.1:5500/theme-clock/index.html')
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
# Close the browser window
|
||||
driver.quit()
|
Loading…
Reference in new issue