diff --git a/BryanFields.txt b/BryanFields.txt new file mode 100644 index 000000000..9c9162e53 --- /dev/null +++ b/BryanFields.txt @@ -0,0 +1 @@ +Bryan Fields this is my commit diff --git a/Homework Lesson 2 complete.py b/Homework Lesson 2 complete.py new file mode 100644 index 000000000..1ca6e9db6 --- /dev/null +++ b/Homework Lesson 2 complete.py @@ -0,0 +1,50 @@ +#Amazon logo +#Search Strategy by class name +//img[@alt='Amazon'] + + +#Email field +#Search Strategy: by ID +//input[@id='ap_email'] + + +#Continue button +#Search Strategy: by name and id or I could find it by the button text +//input[@id='continue'] + + +#Conditions of use link +#Search Strategy: by locating the link text +//a[text()='Conditions of Use'] + + +#Privacy Notice link +#Search Strategy: by text link +//a[text()='Privacy Notice'] + + +#Need help link +#Search Strategy: by link text +//a[text()='Need help?'] + + +#Forgot your password link +#Search Strategy: by locating the link text +//a[text()='Forgot your password?'] + + +#Other issues with Sign-In link +#Search Strategy: by locating the link text +//a[text()='Other issues with Sign-In'] + + +#Create your Amazon account button +#Search Strategy: by locating the link text +//a[text()='Create your Amazon account'] + + + + + + + diff --git a/Homework Lesson 2.py b/Homework Lesson 2.py new file mode 100644 index 000000000..1ca6e9db6 --- /dev/null +++ b/Homework Lesson 2.py @@ -0,0 +1,50 @@ +#Amazon logo +#Search Strategy by class name +//img[@alt='Amazon'] + + +#Email field +#Search Strategy: by ID +//input[@id='ap_email'] + + +#Continue button +#Search Strategy: by name and id or I could find it by the button text +//input[@id='continue'] + + +#Conditions of use link +#Search Strategy: by locating the link text +//a[text()='Conditions of Use'] + + +#Privacy Notice link +#Search Strategy: by text link +//a[text()='Privacy Notice'] + + +#Need help link +#Search Strategy: by link text +//a[text()='Need help?'] + + +#Forgot your password link +#Search Strategy: by locating the link text +//a[text()='Forgot your password?'] + + +#Other issues with Sign-In link +#Search Strategy: by locating the link text +//a[text()='Other issues with Sign-In'] + + +#Create your Amazon account button +#Search Strategy: by locating the link text +//a[text()='Create your Amazon account'] + + + + + + + diff --git a/locator.py b/locator.py new file mode 100644 index 000000000..f10386fc3 --- /dev/null +++ b/locator.py @@ -0,0 +1,23 @@ +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.chrome.service import Service +from webdriver_manager.chrome import ChromeDriverManager +from time import sleep +## +# get the path to the ChromeDriver executable +driver_path = ChromeDriverManager().install() + +# create a new Chrome browser instancegit +service = Service(driver_path) +driver = webdriver.Chrome(service=service) +driver.maximize_window() + +# open the url +driver.get('https://www.amazon.com/') + +# By ID +driver.find_element(By.ID, 'twotabsearchtextbox') +driver.find_element(By.ID, 'nav-search-submit-button') + + + diff --git a/sample_script.py b/sample_script.py index 3925e9462..8610692ef 100755 --- a/sample_script.py +++ b/sample_script.py @@ -7,7 +7,7 @@ # get the path to the ChromeDriver executable driver_path = ChromeDriverManager().install() -# create a new Chrome browser instance +# create a new Chrome browser instancegit service = Service(driver_path) driver = webdriver.Chrome(service=service) driver.maximize_window() @@ -18,7 +18,7 @@ # populate search field search = driver.find_element(By.NAME, 'q') search.clear() -search.send_keys('Car') +search.send_keys('Bryan') # wait for 4 sec sleep(4) @@ -27,7 +27,7 @@ driver.find_element(By.NAME, 'btnK').click() # verify search results -assert 'car'.lower() in driver.current_url.lower(), f"Expected query not in {driver.current_url.lower()}" +assert 'Bryan'.lower() in driver.current_url.lower(), f"Expected query not in {driver.current_url.lower()}" print('Test Passed') driver.quit()