Issue
I am able to add single and all available items, but not sure how to add multiple items
Solution
Your question isn't clear, please the next time provide more details and please just don't share the code with a screenshot.....
Anyway,
To click all the buttons:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.get("https://rahulshettyacademy.com/seleniumPractise/#/")
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, "[class='product-action']")))
for i in driver.find_elements(by=By.CSS_SELECTOR, value="[class='product-action']"):
i.click()
To click just the first two buttons (again, not sure what you really want):
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.get("https://rahulshettyacademy.com/seleniumPractise/#/")
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, "[class='product-action']")))
for i in driver.find_elements(by=By.CSS_SELECTOR, value="[class='product-action']")[0:2]:
i.click()
Answered By - Finch
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.