Im a selenium noob and have been struggling to get things done with python. Im trying to iterate over all user reviews("partial_entry" class) from this page https://www.tripadvisor.com/Airline_Review-d8729164-Reviews-Cheap-Flights-or560-TAP-Portugal#REVIEWS
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome("C:\Users\shalini\Downloads\chromedriver_win32\chromedriver.exe")
driver.maximize_window()
url="https://www.tripadvisor.com/Airline_Review-d8729164-Reviews-Cheap-Flights-or560-TAP-Portugal#REVIEWS"
driver.get(url)
for i in driver.find_elements_by_xpath("//div[@class='wrap']"):
print i.find_element(By.XPATH, '//p[@class="partial_entry"]')
print i.text
print "=============================================="
# THIS IF BLOCK IS NECESSARY, I CANT DO AWAY WITH THIS ONE
if i.find_elements(By.CSS_SELECTOR,"#REVIEWS .googleTranslation>.link"):
print "======YES TRANSLATION AVAILABLE========"
Even though Im selecting a different element each time in for loop, but its printing the same element over and over again. (I have to keep the last if block & cant do away with it, so whatever the solution be it has to include that if block also)
======EDIT===================
Even this isnt working (which should actually work, according to http://selenium-python.readthedocs.io/locating-elements.html ) . I dont know whats going on with selenium !!!!!
print i.find_element(By.CSS_SELECTOR, 'p.partial_entry')
Output:
NoSuchElementException: