title: Selenium(WebDriver) Cannot find and click element: <a class="page-next" href="javascript:gotoPage(2)"></a>
body: <p>-Hello, thank you for reading my post. I have spent all day trying to figure this out. Just trying to click the above element to iterate to the next page of product reviews (this doesn't change the URL). The element corresponds to the "next" button on the product feedback section of the page. </p>
  
  <p>Here is My code:</p>
  
  <pre><code>using OpenQA;
  using OpenQA.Selenium;
  using OpenQA.Selenium.Support;
  using OpenQA.Selenium.Firefox;
  using OpenQA.Selenium.Support.UI;
  using OpenQA.Selenium.IE;
  </code></pre>
  
  <p>....</p>
  
  <pre><code>IWebDriver driver = new FirefoxDriver();
  
  driver.Navigate().GoToUrl("http://www.aliexpress.com/item/Wholesale-DIY-Cardboard-Hang-tag-Retro-Gift-Hang-tag-500pcs-lot-Free-shipping-Thank-you/538222647.html");
  
  driver.FindElement(By.XPath("/html/body/div[3]/div[10]/div[2]/div[2]/div/div/ul/li[2]/a")).Click();
  </code></pre>
  
  <p>The above click command is just to open the product feedback section of the webpage (it works). Next I just want to select the next page of the product feedback but haven't been successful.Below are some commands that I've tried to click the next button and move to the next page of the product feedback listings. I'm new to programming, as you can probably see. </p>
  
  <pre><code>driver.FindElement(By.XPath("/html/body/div/div[2]/div/div[2]/div/a[3]")).Click();
  NoSuchElementException was unhandled: Unable to locate element: "method":"xpath","selector":"/html/body/div/div[2]/div/div[2]/div/a[3]"}"
  
  driver.FindElement(By.XPath("//a[contains(@class,'page-next')]")).Click();
  NoSuchElementException was unhandled:Unable to locate element: {"method":"xpath","selector":"//a[contains(@class,'page-next')]"}
  
         driver.FindElement(By.XPath("/html/body/div/div[2]/div/div[2]/div/a[@href='javascript:gotoPage(2)]")).Click(); 
  InvalidSelectorException was unhandled: The given selector /html/body/div/div[2]/div/div[2]/div/a[@href='javascript:gotoPage(2)] is either invalid or does not result in a WebElement. The following error occurred:
  
  InvalidSelectorError: Unable to locate an element with the xpath expression /html/body/div/div[2]/div/div[2]/div/a[@href='javascript:gotoPage(2)] because of the following error:
  
  [Exception... "The expression is not a legal expression."  code: "12" nsresult: "0x805b0033 (SyntaxError)"  location: "file:///C:/Users/Danny/AppData/Local/Temp/anonymous695678260.webdriver-profile/extensions/fxdriver@googlecode.com/components/driver_component.js Line: 5773"]
  
      driver.FindElement(By.XPath("//a[@href='javascript:gotoPage(2)]")).Click(); 
  InvalidSelectorException was unhandled: The given selector //a[@href='javascript:gotoPage(2)] is either invalid or does not result in a WebElement. The following error occurred:
  
  InvalidSelectorError: Unable to locate an element with the xpath expression //a[@href='javascript:gotoPage(2)] because of the following error:  
  
  [Exception... "The expression is not a legal expression."  code: "12" nsresult: "0x805b0033 (SyntaxError)"  location: "file:///C:/Users/Danny/AppData/Local/Temp/anonymous2137829175.webdriver-profile/extensions/fxdriver@googlecode.com/components/driver_component.js Line: 5773"]         
  
  driver.FindElement(By.LinkText("2")).Click();
  </code></pre>
  
  <p><code>No error</code> here, but this code clicks the wrong button on the page.</p>
  
  <pre><code>driver.FindElement(By.LinkText("javascript:gotoPage(2)")).Click();   
  NoSuchElementException was unhandled: Unable to locate element: {"method":"link text","selector":"javascript:gotoPage(2)"}
  
  driver.FindElement(By.TagName("a")).FindElement(By.LinkText("Next")).Click();
  NoSuchElementException was unhandled: Unable to locate element: {"method":"link text","selector":"Next"}
  
  driver.FindElement(By.CssSelector("html body.product-evaluation div#transction-feedback div.rating-detail div.topnav div#pagination-top.pagination div.pos-right a.page-next")).Click();
  NoSuchElementException was unhandled: Unable to locate element: {"method":"css selector","selector":"html body.product-evaluation div#transction-feedback div.rating-detail div.topnav div#pagination-top.pagination div.pos-right a.page-next"}
  
  IJavaScriptExecutor JavascriptExecutor = driver as IJavaScriptExecutor;
  
  JavascriptExecutor.ExecuteScript("gotoPage(2)");
  "Unexpected error. ReferenceError: gotoPage is not defined"
  
  driver.FindElement(By.XPath("//a[contains(text(),'Next')]")).Click();
  </code></pre>
  
  <p>No error, nothing happens</p>
  
  <pre><code>driver.FindElement(By.CssSelector("css=a.page-next")).Click(); 
  
  InvalidSelectorException was unhandeled:The given selector css=a.page-next is either invalid or does not result in a WebElement. The following error occurred:[Exception... "An invalid or illegal string was specified"  code: "12" nsresult: "0x8053000c (NS_ERROR_DOM_SYNTAX_ERR)"  location: "file:///C:/Users/Danny/AppData/Local/Temp/anonymous797491401.webdriver-profile/extensions/fxdriver@googlecode.com/components/driver_component.js Line: 7717"]
  
  driver.FindElement(By.XPath("//div[@id='pagination-top']/div/a[2]"));
  
  NoSuchElementException was unhandled:Unable to locate element: {"method":"xpath","selector":"//div[@id='pagination-top']/div/a[2]"}
  </code></pre>
  
  <p>I've also tried:automation in Internet Explorer, and waiting for the page to load fully before proceeding.</p>