Commit 1852b850 authored by Bradon Ladd's avatar Bradon Ladd
Browse files

Merge branch 'laddbr/lab8' into 'master'

Laddbr/lab8

See merge request !8
parents 096655bc 6f7b7027
Pipeline #21046 passed with stages
in 2 minutes and 42 seconds
...@@ -2,4 +2,4 @@ area/area.exe ...@@ -2,4 +2,4 @@ area/area.exe
area/test.exe area/test.exe
.vscode/ .vscode/
msg.txt msg.txt
lab07/build.bat lab07/build.bat
\ No newline at end of file
{
"id": "04fd60a2-bea9-443e-a3ea-54b1073196cc",
"version": "2.0",
"name": "CPTR 245 Lab 08",
"url": "https://aswwu.com",
"tests": [{
"id": "90365155-0c0d-45d0-9cfc-b41c0810f382",
"name": "Update ASWWU Profile",
"commands": [{
"id": "96b54dc3-8710-4b73-ba4b-f81fdabce220",
"comment": "Open Chrome",
"command": "open",
"target": "/",
"targets": [],
"value": ""
}, {
"id": "2c4c6c58-f229-433f-b4f3-c31069791dd8",
"comment": "Set the window size to half-display",
"command": "setWindowSize",
"target": "974x1040",
"targets": [],
"value": ""
}, {
"id": "5b3ec723-c763-44d6-b56f-f2ea2e7f3bf7",
"comment": "Click on profile in top right",
"command": "click",
"target": "xpath=//img[contains(@src,'https://aswwu.com/media/img-sm/images/default_mask/default.jpg')]",
"targets": [
["css=.btn-circle", "css:finder"],
["xpath=//img[contains(@src,'https://aswwu.com/media/img-sm/images/default_mask/default.jpg')]", "xpath:img"],
["xpath=//button[@id='bubbleicon']/img", "xpath:idRelative"],
["xpath=//button/img", "xpath:position"]
],
"value": ""
}, {
"id": "c524124a-24ff-4d81-9238-3b1841786f3a",
"comment": "Log out",
"command": "click",
"target": "xpath=//button[contains(.,'Log Out')]",
"targets": [
["css=.btn-default:nth-child(4)", "css:finder"],
["xpath=//div[@id='bubble-popup']/div/button", "xpath:idRelative"],
["xpath=//div/div/div/button", "xpath:position"],
["xpath=//button[contains(.,'Log Out')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "69645bf7-2aae-4b19-80f2-9f145f9b2808",
"comment": "Navigate to the Mask tab",
"command": "click",
"target": "xpath=//a[contains(text(),'Mask')]",
"targets": [
["css=#nav-links > .nav-item:nth-child(1) > .smooth", "css:finder"],
["xpath=//a[contains(text(),'Mask')]", "xpath:link"],
["xpath=//ul[@id='nav-links']/li/a", "xpath:idRelative"],
["xpath=//a[contains(@href, 'https://aswwu.com/mask')]", "xpath:href"],
["xpath=//li/a", "xpath:position"]
],
"value": ""
}, {
"id": "dc190a89-d705-4245-a5cb-3c97197294f9",
"comment": "Activate search bar",
"command": "click",
"target": "xpath=//input[@id='mask-search-query']",
"targets": [
["id=mask-search-query", "id"],
["css=#mask-search-query", "css:finder"],
["xpath=//input[@id='mask-search-query']", "xpath:attributes"],
["xpath=//div[@id='content']/ng-component/div/div/div/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": ""
}, {
"id": "ee128886-8c18-4aab-a2ac-e5d66812232c",
"comment": "Type in \"bradon\"",
"command": "type",
"target": "xpath=//input[@id='mask-search-query']",
"targets": [
["id=mask-search-query", "id"],
["css=#mask-search-query", "css:finder"],
["xpath=//input[@id='mask-search-query']", "xpath:attributes"],
["xpath=//div[@id='content']/ng-component/div/div/div/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": "bradon"
}, {
"id": "6a11bafc-8e9f-4ad0-891e-0f28bb50bd5b",
"comment": "Send query",
"command": "sendKeys",
"target": "xpath=//input[@id='mask-search-query']",
"targets": [
["id=mask-search-query", "id"],
["css=#mask-search-query", "css:finder"],
["xpath=//input[@id='mask-search-query']", "xpath:attributes"],
["xpath=//div[@id='content']/ng-component/div/div/div/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": "${KEY_ENTER}"
}, {
"id": "9ff28c12-0df4-4bd1-a5eb-7f3b464ed015",
"comment": "Click on my profile",
"command": "click",
"target": "id=full-name",
"targets": [
["id=full-name", "id"],
["css=#full-name", "css:finder"],
["xpath=//h4[@id='full-name']", "xpath:attributes"],
["xpath=//div[@id='content']/ng-component/div/div[2]/search-results/div/div/div/profile-sm/a/h4", "xpath:idRelative"],
["xpath=//h4", "xpath:position"],
["xpath=//h4[contains(.,'removed')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "da06354e-927a-44cd-a865-ae1875326797",
"comment": "Exit out of profile page",
"command": "click",
"target": "css=.close",
"targets": [
["css=.close", "css:finder"],
["xpath=(//button[@type='button'])[2]", "xpath:attributes"],
["xpath=//body/div/button", "xpath:position"]
],
"value": ""
}, {
"id": "b02e935f-d976-4c56-9ec1-79f10eb815f8",
"comment": "Mouse over my profile",
"command": "mouseOver",
"target": "css=.btn-circle",
"targets": [
["css=.btn-circle", "css:finder"],
["xpath=//img[contains(@src,'https://aswwu.com/media/img-sm/images/default_mask/default.jpg')]", "xpath:img"],
["xpath=//button[@id='bubbleicon']/img", "xpath:idRelative"],
["xpath=//button/img", "xpath:position"]
],
"value": ""
}, {
"id": "8cff0f3a-62ad-4953-9d2e-46525bf8e4fd",
"comment": "Activate search bar",
"command": "click",
"target": "css=.justify-content-center",
"targets": [
["css=.justify-content-center", "css:finder"],
["xpath=//div[@id='content']/ng-component/div/div/div", "xpath:idRelative"],
["xpath=//ng-component/div/div/div", "xpath:position"]
],
"value": ""
}, {
"id": "f8bef1aa-c1b2-4b83-8919-30c8e64f401c",
"comment": "Type in random name, \"josh\"",
"command": "type",
"target": "id=mask-search-query",
"targets": [
["id=mask-search-query", "id"],
["css=#mask-search-query", "css:finder"],
["xpath=//input[@id='mask-search-query']", "xpath:attributes"],
["xpath=//div[@id='content']/ng-component/div/div/div/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": "josh"
}, {
"id": "12a27eb0-28c0-4763-b9a7-ece6602412b9",
"comment": "Send query",
"command": "sendKeys",
"target": "id=mask-search-query",
"targets": [
["id=mask-search-query", "id"],
["css=#mask-search-query", "css:finder"],
["xpath=//input[@id='mask-search-query']", "xpath:attributes"],
["xpath=//div[@id='content']/ng-component/div/div/div/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": "${KEY_ENTER}"
}, {
"id": "4273147e-5a0a-4f9d-be7a-bfaa08f858c8",
"comment": "Activate search bar",
"command": "click",
"target": "css=.justify-content-center",
"targets": [
["css=.justify-content-center", "css:finder"],
["xpath=//div[@id='content']/ng-component/div/div/div", "xpath:idRelative"],
["xpath=//ng-component/div/div/div", "xpath:position"]
],
"value": ""
}, {
"id": "47a4e6c3-dccf-45f5-a0f4-bfa1dfe845d7",
"comment": "Activate search bar",
"command": "click",
"target": "css=.justify-content-center",
"targets": [
["css=.justify-content-center", "css:finder"],
["xpath=//div[@id='content']/ng-component/div/div/div", "xpath:idRelative"],
["xpath=//ng-component/div/div/div", "xpath:position"]
],
"value": ""
}, {
"id": "440937f1-83c5-4332-a8fe-109db6a248ad",
"comment": "Type in my last name, \"ladd\"",
"command": "type",
"target": "id=mask-search-query",
"targets": [
["id=mask-search-query", "id"],
["css=#mask-search-query", "css:finder"],
["xpath=//input[@id='mask-search-query']", "xpath:attributes"],
["xpath=//div[@id='content']/ng-component/div/div/div/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": "ladd"
}, {
"id": "812d1953-bf05-4d62-abb4-fd4f771da4ec",
"comment": "Send query",
"command": "sendKeys",
"target": "id=mask-search-query",
"targets": [
["id=mask-search-query", "id"],
["css=#mask-search-query", "css:finder"],
["xpath=//input[@id='mask-search-query']", "xpath:attributes"],
["xpath=//div[@id='content']/ng-component/div/div/div/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": "${KEY_ENTER}"
}, {
"id": "0f045fe7-33a9-4233-9dd8-d4472f87d951",
"comment": "Click on my profile tab in the top right",
"command": "click",
"target": "css=.btn-circle",
"targets": [
["css=.btn-circle", "css:finder"],
["xpath=//img[contains(@src,'https://aswwu.com/media/img-sm/images/default_mask/default.jpg')]", "xpath:img"],
["xpath=//button[@id='bubbleicon']/img", "xpath:idRelative"],
["xpath=//button/img", "xpath:position"]
],
"value": ""
}, {
"id": "f694eb11-1914-4746-ae03-2bb2af999ca2",
"comment": "Click \"Update Profile\"",
"command": "click",
"target": "linkText=Update Profile",
"targets": [
["linkText=Update Profile", "linkText"],
["css=.btn:nth-child(2)", "css:finder"],
["xpath=//a[contains(text(),'Update Profile')]", "xpath:link"],
["xpath=//div[@id='bubble-popup']/div/a[2]", "xpath:idRelative"],
["xpath=//a[contains(@href, 'https://aswwu.com/mask/update')]", "xpath:href"],
["xpath=//div/div/div/a[2]", "xpath:position"],
["xpath=//a[contains(.,'Update Profile')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "e2e6a477-d2c1-461e-88e8-456971529b9b",
"comment": "Activate my favorite book tab",
"command": "click",
"target": "id=favorite_booksinput",
"targets": [
["id=favorite_booksinput", "id"],
["css=#favorite_booksinput", "css:finder"],
["xpath=//input[@id='favorite_booksinput']", "xpath:attributes"],
["xpath=//div[@id='edit-profile']/div[6]/div/div/div/input", "xpath:idRelative"],
["xpath=//div[6]/div/div/div/input", "xpath:position"]
],
"value": ""
}, {
"id": "ba31f354-bd0a-4920-b47f-ef75d59d466b",
"comment": "Enter \"Dune\"",
"command": "type",
"target": "id=favorite_booksinput",
"targets": [
["id=favorite_booksinput", "id"],
["css=#favorite_booksinput", "css:finder"],
["xpath=//input[@id='favorite_booksinput']", "xpath:attributes"],
["xpath=//div[@id='edit-profile']/div[6]/div/div/div/input", "xpath:idRelative"],
["xpath=//div[6]/div/div/div/input", "xpath:position"]
],
"value": "Dune"
}, {
"id": "0a8c3967-1c3c-4ebd-815f-07475b713f80",
"comment": "Activate my quote tab",
"command": "click",
"target": "id=quote_authorinput",
"targets": [
["id=quote_authorinput", "id"],
["css=#quote_authorinput", "css:finder"],
["xpath=//input[@id='quote_authorinput']", "xpath:attributes"],
["xpath=//div[@id='edit-profile']/div[6]/div/div[6]/div/input", "xpath:idRelative"],
["xpath=//div[6]/div/div[6]/div/input", "xpath:position"]
],
"value": ""
}, {
"id": "71bd614b-c5be-4e02-8a76-41fdf528b2f5",
"comment": "Enter \"Fear is the mindkiller\"",
"command": "type",
"target": "id=quote_authorinput",
"targets": [
["id=quote_authorinput", "id"],
["css=#quote_authorinput", "css:finder"],
["xpath=//input[@id='quote_authorinput']", "xpath:attributes"],
["xpath=//div[@id='edit-profile']/div[6]/div/div[6]/div/input", "xpath:idRelative"],
["xpath=//div[6]/div/div[6]/div/input", "xpath:position"]
],
"value": "\"Fear is the mindkiller\""
}, {
"id": "4c3e05f4-b3fd-4918-a39b-210b9bc673ea",
"comment": "Click \"Update Profile\"",
"command": "click",
"target": "css=.btn-primary",
"targets": [
["css=.btn-primary", "css:finder"],
["xpath=//div[@id='submit']/button", "xpath:idRelative"],
["xpath=//div[8]/button", "xpath:position"],
["xpath=//button[contains(.,'Update Profile')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "1703f459-6c19-42de-925c-1c367703eb76",
"comment": "Updates profile",
"command": "runScript",
"target": "window.scrollTo(0,0)",
"targets": [],
"value": ""
}, {
"id": "0239819c-9c19-46e4-a436-975d67b71897",
"comment": "Close Chrome",
"command": "close",
"target": "",
"targets": [],
"value": ""
}]
}],
"suites": [{
"id": "4d19d991-4bbc-4afa-b675-b43d6cec73fb",
"name": "Default Suite",
"persistSession": false,
"parallel": false,
"timeout": 300,
"tests": ["90365155-0c0d-45d0-9cfc-b41c0810f382"]
}],
"urls": ["https://aswwu.com/"],
"plugins": []
}
\ No newline at end of file
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import sys
# Command line arguments
if (sys.argv[1] == "-h"):
print('First argument is your username, second is your password, third is your book choice, fourth is your favorite quote')
sys.exit()
else:
username = sys.argv[1]
password = sys.argv[2]
book = sys.argv[3]
quote = sys.argv[4]
driver = webdriver.Firefox()
driver.implicitly_wait(5) # seconds
driver.get('https://aswwu.com/')
# search mask
driver.find_element_by_xpath("//a[contains(@href, 'https://aswwu.com/mask')]").click()
driver.find_element_by_id('mask-search-query').clear()
driver.find_element_by_id('mask-search-query').send_keys('ladd', Keys.ENTER)
driver.implicitly_wait(3) # wait for results to load
#login (default is logged out)
driver.find_element_by_xpath("//a[contains(@href, 'https://saml.aswwu.com/?sso&redirect=/mask/search')]").click()
driver.find_element_by_id('userNameInput').send_keys(username)
driver.find_element_by_id('passwordInput').send_keys(password)
driver.find_element_by_id('submitButton').click()
driver.implicitly_wait(3) # wait to be logged in
#update profile page
driver.find_element_by_id('bubbleicon').click()
driver.find_element_by_xpath("//a[contains(text(),'Update Profile')]").click()
driver.implicitly_wait(3)
#enter info to be updated
driver.find_element_by_id("favorite_booksinput").clear()
driver.find_element_by_id("quote_authorinput").clear()
driver.find_element_by_id("favorite_booksinput").send_keys(book)
driver.find_element_by_id("quote_authorinput").send_keys(quote)
#submit changes
driver.find_element_by_xpath("//div[@id='submit']/button").click()
driver.find_element_by_id('bubbleicon').click()
driver.find_element_by_xpath("//div[@class='dropdown-menu show']/button").click()
import sys
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class ASWWU:
def __init__(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(5) # seconds
self.driver.get('https://aswwu.com/')
def searchMask(self, name):
xpath = "//a[contains(@href, 'https://aswwu.com/mask')]"
self.driver.find_element_by_xpath(xpath).click()
self.driver.find_element_by_id('mask-search-query').send_keys(name, Keys.ENTER)
self.driver.implicitly_wait(5) # seconds
xpath = "//search-results[contains(@ng-reflect-query,'" + name + "')]"
self.driver.find_element_by_xpath(xpath)
xpath = "//h4[contains(text(),'" + name + "')]"
result = self.driver.find_elements_by_xpath(xpath)
return result
def login(self, username, password):
self.driver.find_element_by_xpath("//a[contains(@href, 'https://saml.aswwu.com/?sso&redirect=/mask/search')]").click()
self.driver.find_element_by_id('userNameInput').send_keys(username)
self.driver.find_element_by_id('passwordInput').send_keys(password)
self.driver.find_element_by_id('submitButton').click()
self.driver.implicitly_wait(3) # wait to be logged in
def updateProfile(self, parameters):
# Access the profile editing page
self.driver.find_element_by_id('bubbleicon').click()
self.driver.find_element_by_xpath("//a[contains(text(),'Update Profile')]").click()
self.driver.implicitly_wait(3)
# Find the correct input based on the key value and enter the dictionary entry for that key
for key, value in parameters.items():
self.driver.find_element_by_id(key).clear()
self.driver.find_element_by_id(key).send_keys(value)
# Submit the changes
self.driver.find_element_by_xpath("//div[@id='submit']/button").click()
# Logout code. I wasn't sure
def close(self):
self.driver.find_element_by_id('bubbleicon').click()
self.driver.find_element_by_xpath("//div[@class='dropdown-menu show']/button").click()
# add login() [x], updateProfile(), and close() to ASWWU
# iterate over a dictionary with `for key, value in dict.items():`
def main():
aswwu = ASWWU()
assert(len(aswwu.searchMask('Ladd')) == 1)
# provide the user email and password as command-line arguments (for security)
aswwu.login(sys.argv[1], sys.argv[2])
aswwu.updateProfile({
'favorite_booksinput': 'F.A. Hayek, The Road to Serfdom',
'quoteinput': 'The road to hell is paved with good intentions.' })
aswwu.updateProfile({
'favorite_booksinput': 'Dune',
'quoteinput': 'Fear is the mindkiller',
'quote_authorinput': 'Frank Herbert' })
aswwu.close()
if __name__ == "__main__":
main()
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment