Home > Back-end >  How to click 5 star in Google ratings with Selenium python
How to click 5 star in Google ratings with Selenium python

Time:01-04

I'm trying to write a review for a place on google maps and give it 5 stars. I've done the comment part, but I can't click on the stars.

the part of code i wrote to send comment and give 5 stars:

WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"/html/body/div[18]/iframe")))

driver.find_element(By.XPATH,("/html/body/div[1]/c-wiz/div/div/div/div/div[1]/div[3]/div[2]/div[3]/div[1]/textarea")).send_keys("Comment")

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"#yDmH0d > c-wiz > div > div > div > div > div.O51MUd > div.l5dc7b > div.DTDhxc.eqAW0b > div.euWHWd.aUVumf > div > div:nth-child(5)"))).click()

the error message i got:

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <div  role="radio" aria-label="Five star" aria-checked="false" tabindex="0" jsaction="click:uOnRTe; keydown:g6LwHf" data-rating="5">...</div> is not clickable at point (281, 158). Other element would receive the click: <div >...</div>

the place I used as an example: empire state building

I tried all kinds of ways but I couldn't. Can you help me?

CodePudding user response:

This means there is an overlapping element. Try closing the element or the below.

elem=WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"#yDmH0d > c-wiz > div > div > div > div > div.O51MUd > div.l5dc7b > div.DTDhxc.eqAW0b > div.euWHWd.aUVumf > div > div:nth-child(5)")))
driver.execute_script("arguments[0].click();", elem)
  • Related