complete flow of shopping
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
service_obj = Service("C://Users//ancha//chromedriver_win32(4)//chromedriver.exe")
driver = webdriver.Chrome(service=service_obj, options=chrome_options)
driver.implicitly_wait(4)
driver.get("https://rahulshettyacademy.com/angularpractice")
driver.find_element(By.XPATH, "//a[contains(@href,'shop')]").click()
products = driver.find_elements(By.XPATH, "//div[@class= 'card h-100']")
for product in products:
product_name = product.find_element(By.XPATH, "div/h4/a").text
if product_name == "Blackberry":
product.find_element(By.XPATH, "div/button").click()
driver.find_element(By.CSS_SELECTOR, "a[class*='btn-primary']").click()
driver.find_element(By.XPATH, "//button[@class='btn btn-success']").click()
driver.find_element(By.ID, "country").send_keys("ind")
wait= WebDriverWait(driver, 10)
wait.until(expected_conditions.presence_of_element_located((By.LINK_TEXT, "India")))
driver.find_element(By.LINK_TEXT, "India").click()
driver.find_element(By.XPATH, "//div[@class='checkbox checkbox-primary']").click()
# driver.find_element(By.XPATH, "//input[@ class='btn btn-success btn-lg']").click()
driver.find_element(By.CSS_SELECTOR, "[type='submit']").click()
success_mesg = driver.find_element(By.CLASS_NAME, "alert-success").text
assert "Success! Thank you!" in success_mesg
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
service_obj = Service("C://Users//ancha//chromedriver_win32(4)//chromedriver.exe")
driver = webdriver.Chrome(service=service_obj, options=chrome_options)
driver.implicitly_wait(4)
driver.get("https://rahulshettyacademy.com/angularpractice")
driver.find_element(By.XPATH, "//a[contains(@href,'shop')]").click()
products = driver.find_elements(By.XPATH, "//div[@class= 'card h-100']")
for product in products:
product_name = product.find_element(By.XPATH, "div/h4/a").text
if product_name == "Blackberry":
product.find_element(By.XPATH, "div/button").click()
driver.find_element(By.CSS_SELECTOR, "a[class*='btn-primary']").click()
driver.find_element(By.XPATH, "//button[@class='btn btn-success']").click()
driver.find_element(By.ID, "country").send_keys("ind")
wait= WebDriverWait(driver, 10)
wait.until(expected_conditions.presence_of_element_located((By.LINK_TEXT, "India")))
driver.find_element(By.LINK_TEXT, "India").click()
driver.find_element(By.XPATH, "//div[@class='checkbox checkbox-primary']").click()
# driver.find_element(By.XPATH, "//input[@ class='btn btn-success btn-lg']").click()
driver.find_element(By.CSS_SELECTOR, "[type='submit']").click()
success_mesg = driver.find_element(By.CLASS_NAME, "alert-success").text
assert "Success! Thank you!" in success_mesg
Comments
Post a Comment