package Testng
import java.awt.AWTException;
import java.awt.Robot;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.testng.annotations.Test;
public class Languagechange {
public static void main(String[] args) throws
IOException, AWTException{
// This will create firefox profile
FirefoxProfile fp=new FirefoxProfile();
// this will change the language
preference and fr is the locale for france
fp.setPreference("intl.accept_languages",
"fr");
// now pass this fp object to
FirefoxDriver
WebDriver driver=new FirefoxDriver(fp);
//will manage to maximize a window
driver.manage().window().maximize();
//getting the url
driver.get("https://www.gmail.com");
driver.findElement(By.id("Email")).clear();
driver.findElement(By.id("Email")).sendKeys("username");
driver.findElement(By.id("Passwd")).clear();
driver.findElement(By.id("Passwd")).sendKeys("password");
Robot robot = new Robot();
robot.keyPress(java.awt.event.KeyEvent.VK_ENTER);
driver.manage().timeouts().implicitlyWait(30,
TimeUnit.SECONDS);
driver.close();
}
}
Can you tell me how to achieve the same in IE. I wasn't able to do same it in IE. Your answer will bevery helpful
ReplyDelete