I used the xpath, full xpath , using find text to click buttton nothing worked.
enter image description here
I got this error ERROR – An error occurred: Message: JavaScript error: Cannot read properties of null (reading ‘click’)
Product link for reference: https://amzn.in/d/dRHZb0H
def click_and_wait(driver, xpath):
try:
element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, xpath)))
driver.execute_script("arguments[0].scrollIntoView();", element)
driver.execute_script("arguments[0].click();", element)
except TimeoutException:
logging.error("Timeout occurred while waiting for element to be clickable: %s", xpath)
raise
except Exception as e:
logging.error("An error occurred while clicking on element: %s", str(e))
raise
def perform_automation_tasks(driver):
try:
driver.get("https://amzn.in/d/dRHZb0H")
time.sleep(3)
click_and_wait(driver, "//*[@id='buy-now-button']")
click_and_wait(driver, "/html/body/div[5]/div[1]/div/div[2]/div/div/div[1]/div[1]/div/div[6]/div/div[3]/div/div/div[2]/div/div[2]/div/div/form/div/div[2]/div/span/span/input")
time.sleep(3)
click_and_wait(driver, "//*[@id='bottomSubmitOrderButtonId']/span/input")
finally:
driver.quit()
I need help in clicking that button so that i can automate the buying process on amazon.in
New contributor
Lucky Rajput is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.