RE: how to get the exact text(languages written in their native sign) on Google home page?? The output which i had after getting the link text where something like mentioned below: ?????? ????????? ?????? ????????? ????? ????????…and so on.

Answered

import java.util.List;

import java.util.concurrent.TimeUnit;
import org.junit.Test;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;
public class Alert

{

@Test

public void test() throws Exception

{

WebDriver driver = new FirefoxDriver();

driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

driver.get("https://www.google.com");

driver.manage().window().maximize();

Thread.sleep(2000);

driver.findElement(By.xpath(".//*[@id='sb_ifc0']")).click();

driver.findElement(By.xpath(".//*[@id='sb_ifc0']")).sendKeys("Hello");

driver.findElement(By.xpath(".//*[@id='gbqfb']")).click();

Thread.sleep(2000);

List<WebElement> linkspresent = driver.findElements(By.tagName("a"));

System.out.println("No of links present on google page are "+linkspresent.size());

Thread.sleep(2000);

for(int i=1;i<linkspresent.size();i++ )

{

System.out.println(linkspresent.get(i).getText());

}

Thread.sleep(2000);

driver.navigate().back();

WebElement langsection=driver.findElement(By.xpath(".//*[@id='addlang']"));

List<WebElement> lang = langsection.findElements(By.tagName("a"));

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

{

System.out.println(lang.get(i).getText());

}

Thread.sleep(2000);
}

}

RE: how to get the exact text(languages written in their native sign) on Google home page?? The output which i had after getting the link text where something like mentioned below: ?????? ????????? ?????? ????????? ????? ????????...and so on.

roshan3506 Train Asked on September 19, 2014 in Selenium WebDriver.
Add Comment
2 Answers

Thanks a lot Sachin, it worked.
Do i have to change back the settings as it was or i can continue with my other work with this change.

Train Answered on September 19, 2014.

WC.. 🙂 You can continue with this, I don’t think it will affect to your work. Please “ACCEPT” the solution/answer.

on September 19, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.