What's the best way to get the text? getText () doesn't return link text in google.co.in

What's the best way to get the text? getText () does not return link text in google.co.in I am trying to get below text हिन्दी ব াং লা తెలుగు मराठी தமிழ் ગુજરાતી ಕನ್ನಡ മലയാളം ਪੰਜਾਬੀ I wrote a script for this as well, but I get output as ????. I don't know why this is happening. can someone suggest me get the text. Below is my script

public class LanguageLinks {

public static void main(String[] args) throws InterruptedException, IOException {

    WebDriver driver = new FirefoxDriver();

List<WebElement> links = driver.findElements(By.xpath("//*[@id='addlang']/a"));

        for(int i=0;i<links.size();i++){




Edit note: Added a code block to include the complete code.


source to share

1 answer

This is not Selenium related, but does not match the character encoding in Eclipse. Apply the following settings:

Navigate to: Window -> Preferences -> General -> Workspace . Under Text Encoding : select Other radio, select UTF-8 from the list → Click OK .

After applying the above settings, repeat the code execution. You should see the correct texts displayed on the screen.



All Articles