'Select rating using selenium web driver
I am trying to select the 5 star user rating on this Website:
I have tried using actions but I've been unsuccessful.
element = driver.find_element(By.XPATH, '/html/body/div[1]/div/div/div[3]/div/div/article/div[3]/div[3]/div/div[5]/div[1]/span/span')
action = ActionChains(driver)
action.move_to_element(element).perform()
action.move_to_element(driver.find_element(By.XPATH, "//span[@data-user-rate='100']")).click()
Solution 1:[1]
It's hard to hover element to make the rating 100% with ActionChains (it's always about 100, but not 100).
Try with js, works for me.
rating = driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div[3]/div/div/article/div[3]/div[3]/div/div[5]/div[1]/span/span")
driver.execute_script('arguments[0].style="width:100%"; arguments[0].click()', rating)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
