Unable to click-iterate through elements using selenium
<p>Im trying to click-iterate through google-translate element but the code isnt working </p>

<pre><code>from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get("https://www.tripadvisor.com.br/ShowUserReviews-g1-d8729164-r425802060-TAP_Portugal-World.html")
for i in driver.find_elements_by_class_name("entry"):
wait = WebDriverWait(driver, 10)

google_translate = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, ".googleTranslation .link")))

actions = ActionChains(driver)
actions.move_to_element(google_translate).click().perform()
driver.find_element_by_class_name("ui_close_x").click()
driver.execute_script("window.scrollTo(0, 600);")
</code></pre>

<p>=======ISSUE======
Its itertaing through the very first element only</p>

<hr>

<p>Basically the code should show translation for each of the review in a popup, close that popup and then move to next review, translate etc</p>

<pre><code>from selenium import webdriver
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://www.tripadvisor.com.br/ShowUserReviews-g1-d8729164-r425802060-TAP_Portugal-World.html")
gt= driver.find_elements(By.CSS_SELECTOR,".googleTranslation&gt;.link")
for i in gt:
    i.click()
    time.sleep(2)
    driver.find_element_by_class_name("ui_close_x").click()
    time.sleep(2)
</code></pre>

<p>The above code will solve your purpose of clicking on each review google translate.
PS: in For loop i have placed the time.sleep() so that you can see the code action, if you want you can remote it</p>

python selenium web-scraping