Thi is your code :
Driver.findElement(By.xpath(//a[@href ='/docs/configuration']")).click();
You missed the Quotation mark
it should be as below
Driver.findElement(By.xpath("//a[@href='/docs/configuration']")).click();
Hope this helps!
webDriver.findElement(By.xpath("//a[@href='/docs/configuration']")).click();
The above line works fine. Please remove the space after href.
Is that element is visible in the page, if the element is not visible please scroll down the page then perform click action.
To click()
on the element with text as App Configuration you can use either of the following Locator Strategies:
linkText
:
driver.findElement(By.linkText("App Configuration")).click();
cssSelector
:
driver.findElement(By.cssSelector("a[href='/docs/configuration']")).click();
xpath
:
driver.findElement(By.xpath("//a[@href='/docs/configuration' and text()='App Configuration']")).click();
Ideally, to click()
on the element you need to induce WebDriverWait for the elementToBeClickable()
and you can use either of the following Locator Strategies:
linkText
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.linkText("App Configuration"))).click();
cssSelector
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("a[href='/docs/configuration']"))).click();
xpath
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@href='/docs/configuration' and text()='App Configuration']"))).click();
You can find a couple of relevant detailed discussions in:
Seems like the a
tag is hidden. Remember Selenium is not able to interact with hidden element. Javascript
is the only option in that case.
By css = By.cssSelector("a[href='/docs/configuration']");
WebElement element = driver.findElement(css);
((JavascriptExecutor)driver).executeScript("arguments[0].click();" , element);