Query in webdriver initially | Selenium Forum
M
Posted on 21/08/2015
I am new in web driver. I am trying to get text of a hyperlink from website bbc.com but code is throwing exception "Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"//li[@class='orb-nav-newsdotcom orb-w']/a"}". Please look into this.

Below are the code:

import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;

public class links_demo {

/**
* @param args
*/
public static void main(String[] args) {
FirefoxDriver driver = new FirefoxDriver();
driver.get("http://bbc.com");
String x1=driver.findElement(By.xpath("//li[@class='orb-nav-newsdotcom orb-w']/a")).getText();
System.out.println(x1);
}
}

M
Replied on 21/08/2015

Which Link are you trying to click
Please attach pic


M
Replied on 21/08/2015

Please find the attached screenshot

Responsive image

M
Replied on 22/08/2015

Take xpath from firebug and try
If it does not work then try complete xpath