title: How to click on the element with Selenium Webdriver
body: <p>I am automating a web module in google chrome browser by using selenium web driver. I have created a relative XPath of a web element to whom I want to click that but unfortunately, it is not working and giving me an exception that this XPath is not located on a web page. Dynamic XPath was not working as I have captured that one first, that's why I have created relative XPath.</p>
  
  <p><strong>Selenium code:</strong></p>
  
  <pre><code>//Dashboard:
  WebElement ele = driver.findElement(By.xpath("//*[@id=\"sidebar\"]/section/ul/li[1]/a"));
  Actions action = new Actions(driver);
  action.moveToElement(ele).perform(); // Mover Hover     
  WebElement ele2 = driver.findElement(By.xpath("//*[@id=\"sidebar\"]/section/ul/li[1]/ul/li[1]/a"));
  ele2.click(); // Click onto Weather
  driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
  WebElement ele4 = driver.findElement(By.xpath("//*[contains(@id, 'pvExplorationHost')]//li[1]/div"));
  ele4.click();
  </code></pre>
  
  <p><strong>HTML Code on Web page:</strong></p>
  
  <pre><code>&lt;div class="textLabel" ng-click="disableClick || makeEditable()" title="Waffle Charts - All Variables"&gt;Waffle Charts - All Variables&lt;/div&gt;
  </code></pre>
  
  <p>[enter image description here][1]</p>
  
  <p><strong>Exception coming on Selenium:</strong></p>
  
  <pre><code>Only local connections are allowed.
  Jul 04, 2018 2:15:14 PM org.openqa.selenium.remote.ProtocolHandshake createSession
  INFO: Detected dialect: OSS
  Test Passed!
  Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[contains(@id, 'pvExplorationHost')]//li[1]/div"}
    (Session info: chrome=67.0.3396.99)
    (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
  Command duration or timeout: 0 milliseconds
  For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
  Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:03.216Z'
  System info: host: 'MACPK-WKS-0072', ip: '192.168.8.100', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '10'
  Driver info: org.openqa.selenium.chrome.ChromeDriver
  Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.38.552522 (437e6fbedfa876..., userDataDir: C:\Users\MOMNA~1.ARS\AppDat...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 67.0.3396.99, webStorageEnabled: true}
  Session ID: 2615a71e0f1b2d97c0611fc399cdda8b
  *** Element info: {Using=xpath, value=//*[contains(@id, 'pvExplorationHost')]//li[1]/div}
      at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
      at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
      at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
      at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
      at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
      at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
      at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
      at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
      at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
      at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:317)
      at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:419)
      at org.openqa.selenium.By$ByXPath.findElement(By.java:353)
      at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:309)
      at newpackage.DynamicXPath.main(DynamicXPath.java:74)
  </code></pre>
  
  <p>Please advise me I am over stuck here, As I am new to Selenium Web-Driver.</p>