I need to click the link whose href has substring “long” in it. How can I do this?
With the beauty of CSS selectors.
your statement would be…
driver.findElement(By.cssSelector("a[href*='long']")).click();
This means, in english,
Find me any ‘a’ elements, that have the
hrefattribute, and that attributecontains‘long’
You can find a useful article about formulating your own selectors for automation effectively, as well as a list of all the other equality operators. contains, starts with, etc… You can find that at: http://ddavison.io/css/2014/02/18/effective-css-selectors.html