This error message...
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element {"method":"link text","selector":"Cart"}
...implies that the ChromeDriver was unable to locate the desired element as per the line:
GotoCart = browser.find_element_by_link_text("Cart").click()
Solution
You need to induce WebDriverWait for the desired element to be clickable and you can use either of the following solutions:
Using LINK_TEXT
:
WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.LINK_TEXT, "Cart"))).click()
Using CSS_SELECTOR
:
WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "section#header a.cart-heading[href='/cart']"))).click()
Using XPATH
:
WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//section[@id='header']//a[@class='cart-heading' and @href='/cart']"))).click()
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
PS: You can find a detailed discussion in Selenium “selenium.common.exceptions.NoSuchElementException” when using Chrome