title: How to find specific text on webpage using python and selenium webdriver
body: <p>I'm using Python 3.4 with Selenium Webdriver. At the point in the program that I'm working on, I'm ultimately trying to get Python to find a specific text, then move the mouse to a certain position above said text to click on an image link above it.</p>
  
  <p>My problem is that I can't figure out how to do that first bit, locating specific text and having my mouse go to. I've tried using XPath to locate the element containing the text, which works, but it doesn't bring the mouse location to the text; rather to the entire element the text is located in instead.</p>
  
  <p>I've also tried finding the element by a certain tag, which also works, but I can't specify WHICH tag (i.e. 1st, 2nd, 3rd, etc) since I'm unable to search for the inner text (if that's even possible) so I'm always finding the first  on the webpage. </p>
  
  <p>Could someone please help me out? I'm new to programming and this is my first project, so if you could please dumb things down for me, I'd greatly appreciate it.</p>
  
  <p>EDIT: Here's my code so far.</p>
  
  <pre><code>from selenium import webdriver
  
  browser = webdriver.Firefox()
  browser.get('http://www.websiteexample.com')
  linkElem = browser.find_element_by_link_text('Log in')
  type(linkElem)
  linkElem.click()
  
  usernameElem = browser.find_element_by_id('templateLoginPopupUsername')
  usernameElem.send_keys('blankusername') 
  passwordElem = browser.find_element_by_name('password')
  passwordElem.send_keys('123456')
  passwordElem.submit()
  
  import time
  time.sleep(10)
  
  browser.find_element_by_id('ssmenu').click()
  ssSearch = browser.find_element_by_id('searchstr')
  ssSearch.send_keys('Red Balloon')
  browser.find_element_by_id('button-search').click()
  
  time.sleep(10)
  
  topLink = browser.find_element_by_css_selector('a.plink')
  topLink.click()
  
  el = browser.find_element_by_xpath("//*[contains(text(), 'Red Balloon')]")
  
  actions = ActionChains(browser)
  actions.move_to_element_with_offset(el, 5, 5) 
  actions.click()
  actions.perform()
  </code></pre>
  
  <p>Here's the snippet from the source I'm trying to use (sorry it's a bit messy):</p>
  
  <pre><code>&lt;div style="text-align: center; margin: 10px;"&gt;&lt;table border="0" align="center"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td width="120" valign="top" align="center"&gt;&lt;a onclick="if ( !confirm ('Are you sure?') ) { return false; }" href="purchase_item.phtml?lower=0&amp;amp;owner=person&amp;amp;obj_info_id=194439&amp;amp;g=1&amp;amp;xhs=590ros30&amp;amp;old_price=4000&amp;amp;feat=199,4000,2&amp;amp;_ref_ck=2949e009700c3f5e2e2596405efb8f2c"&gt;&lt;img title="This is a red balloon" src="http://images.websiteexample.com/items/redballoon.gif" width="80" height="80" border="1"&gt;&lt;/a&gt; &lt;br&gt; &lt;b&gt;Red Balloon&lt;/b&gt;&lt;br&gt;2 in stock&lt;br&gt;Cost : 4 QQ&lt;br&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/tGWcg.png" rel="nofollow noreferrer">Here's an image of a neater version of the above source code</a></p>