0

I am trying to make a movie quote making bot and i have already made the random quote scraper from IMDB. But when I try to make the quote from www.quotescover.com, my selenium is giving errors

I have tried a lot to click implicitly, with time.sleep and even tried to use action chains as I have mentioned in my code

qt,mv = getQuote() #basically the quote and the movie name, it can be just any string like qt = 'foo';mv = 'bar'
url = 'https://quotescover.com/designs/wording?res=WTBTQ3FyR01aMEVOdTVCRVJxRFUwdz09'
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument("--test-type")
# options.add_argument("--headless")
options.add_experimental_option('excludeSwitches', ['enable-logging'])
prefs = {'download.default_directory' : os.getcwd()+'images\\'}
options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(options=options)
driver.get(url)
quote = driver.find_element_by_id('quotes')
quote.clear()
quote.send_keys(qt)
movie = driver.find_element_by_id('author')
movie.clear()
movie.send_keys(mv)
submit = driver.find_element_by_id('template-contactform-submit')
submit.click()

download = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, 'button  buttonDownload')))
for item in download:
    ActionChains(driver).move_to_element(item).click().perform()

I thought it would work after using actionchains but it gives me the error element not intractable...also one time it didn't give me ANY error, just a blank exception :(

Pankaj Devrani
  • 510
  • 1
  • 10
  • 28
Boidushya
  • 38
  • 2
  • 5

2 Answers2

2

I think the problem is, there are other elements in the page that are not going to be visible or clickable. maybe this code helps:

download = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='appBody']//button[@class='button  buttonDownload' and contains(text(),'DOWNLOAD')]")))
0xM4x
  • 460
  • 1
  • 8
  • 19
0

By.CLASS_NAME only accept single classname Not multiple classname. Use CssSelector instead classname.

download = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, '.button.buttonDownload')))
download.location_once_scrolled_into_view
download.click()

OR

download = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, '.button.buttonDownload')))
ActionChains(driver).move_to_element(download).click().perform()

OR

download = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, '.button.buttonDownload')))
driver.execute_script("arguments[0].click();", download)
KunduK
  • 32,888
  • 5
  • 17
  • 41