title: How to click on the Read more link from the first review within tripadvisor using Selenium and Python
body: <p>I am using selector gadget to get the xpath from the &quot;read more&quot; button from the first review on <a href="https://www.tripadvisor.com/Hotel_Review-g60982-d209422-Reviews-Hilton_Waikiki_Beach-Honolulu_Oahu_Hawaii.html" rel="nofollow noreferrer">this website</a></p>
  <p>This is the xpath it gave:</p>
  <pre><code>//*[contains(concat( &quot; &quot;, @class, &quot; &quot; ), concat( &quot; &quot;, &quot;Z&quot;, &quot; &quot; ))]
  </code></pre>
  <p>Here is the first part of the code I am using:</p>
  <pre><code>import selenium
  import csv #This package lets us save data to a csv file
  from selenium import webdriver #The Selenium package we'll need
  import time #This package lets us pause execution for a bit
  from selenium.webdriver.common.by import By
  
  path_to_file = &quot;/Users/user/Desktop/HotelReviews.csv&quot;
  
  pages_to_scrape = 3
  
  url = &quot;https://www.tripadvisor.com/Hotel_Review-g60982-d209422-Reviews-Hilton_Waikiki_Beach-Honolulu_Oahu_Hawaii.html&quot;
  
  # open the file to save the review
  csvFile = open(path_to_file, 'a', encoding=&quot;utf-8&quot;)
  csvWriter = csv.writer(csvFile)
  
  for i in range(0, pages_to_scrape):
      
      driver = webdriver.Chrome()
      driver.get(&quot;url&quot;)
      # give the DOM time to load
      time.sleep(2) 
      driver.find_element_by_xpath(&quot;//*[contains(concat( &quot; &quot;, @class, &quot; &quot; ), 
      concat( &quot; &quot;, &quot;Z&quot;, &quot; &quot; ))], 'Read more')]&quot;).click()
  </code></pre>
  <p>This is the error I get:</p>
  <pre><code>File &quot;/var/folders/6c/jpl964752rv_72zjclrp_8ym0000gn/T/ipykernel_24978/2812702568.py&quot;, line 8
      driver.find_element_by_xpath(&quot;//*[contains(concat( &quot; &quot;, @class, &quot; &quot; ), concat( &quot; &quot;, &quot;Z&quot;, &quot; &quot; ))], 'Read more')]&quot;).click()
                                                                                           ^
  SyntaxError: invalid syntax
  </code></pre>
  <p>Looks like it's the quotation marks that seems to be the issue.</p>
  <p>So I followed <a href="https://stackoverflow.com/questions/26236564/invalid-syntax-when-using-find-elemen-by-xpath">this advice</a>. I tried making the code a variable, but it spit out the same error. I tried removing the extra quotes, same error. I tried removing the space between the quotes, same error.</p>
  <p>I tried a different xpath, one for the whole review
  <code>//*[contains(concat( &quot; &quot;, @class, &quot; &quot; ), concat( &quot; &quot;, &quot;F1&quot;, &quot; &quot; ))]</code>
  Same error.</p>
  <p>Then I tried adjusting the quotation marks on the first xpath</p>
  <pre><code>driver.find_element_by_xpath(&quot;//*[contains(concat( &quot; &quot;, @class, &quot; &quot; ), 
      concat( &quot; &quot;, &quot;Z&quot;, &quot; &quot; ))]&quot;, &quot;Read more&quot;)]).click()
  </code></pre>
  <p>results to the same error.</p>