I am trying to click on the rate button to set the rating for the movie Mona Lisa and the Blood Moon on the IMDB website as illustrated by the image further below.
I have tried various combinations of selenium xpath values and have googled various links to attempt to achieve this, but can’t remember which now. My current python is below less logging onto the IMDB website to be able to effect this new rating.
driver.get('https://www.imdb.com/title/tt8760670/?ref_=nv_sr_srsg_0') wait = WebDriverWait(driver, 20) xpath = "(//div[@data-testid='hero-rating-bar__user-rating'])//button" wait.until(EC.element_to_be_clickable((By.XPATH, xpath))).click() xpath = "//button[@aria-label='Rate 1']//svg" wait.until(EC.element_to_be_clickable((By.XPATH, xpath))).click()
The first click works as I want; but the second fails. The HTML I’m trying to scrape is below:
<div class="ipc-starbar"> <div class="ipc-starbar__touch"></div> <div class="ipc-starbar__rating"> <button class="ipc-starbar__rating__button" role="button" aria-label="Rate 1" tabindex="0"> <svg >question before; but that was pertaining to an episode of a series, which has a completely different setup of HTML
I tried clicking the button above to set the rating to one; but my python crashed complaining that the button was unclickable.
stars = driver.find_element(By.XPATH,"(//*[@class='ipc-starbar__rating']/button)") driver.execute_script("arguments.click();", stars)
If you want to give more ratings change in number '1' in the xpath to whatever you want up to '10'