Saturday, 13 December 2014

Internationalization Testing Using WebDriver

Internationalization Testing Using WebDriver
One need to open browser in localized mode, in specific language.

there could be 2 approaches:
i. create profile and load it during launching browser.
    --ProfileIni pf = new ProfileIni();
    --FirefoxProfile fireFoxProfile = pf.getProfile(<profileName>);//<profileName is created using profile manager, "type firefox.exe -p on Windows+R "
 
    --WebDriver wd = new FireFoxDriver(fireFoxProfile);
ii. Create object of FirefoxProfile. Set the preference of FirefoxProfile to open in particular langauage.
--FireFoxProfile fireFoxProfile = new FireFoxProfile();
--fireFoxProfile.setPreference("intl.accept_languages","sl");
--WebDriver wd = new FireFoxDriver(fireFoxProfile);

package learn.I18n;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
/*
Internationalization Testing Using WebDriver
One need to open browser in localized mode, in specific language.

there could be 2 approaches:
i. create profile and load it during launching browser.
    --ProfileIni pf = new ProfileIni();
    --FirefoxProfile fireFoxProfile = pf.getProfile(<profileName>);//<profileName is created using profile manager, "type firefox.exe -p on Windows+R "
 
    --WebDriver wd = new FireFoxDriver(fireFoxProfile);
ii. Create object of FirefoxProfile. Set the preference of FirefoxProfile to open in particular langauage.
--FireFoxProfile fireFoxProfile = new FireFoxProfile();
--fireFoxProfile.setPreference("intl.accept_languages","sl");
--WebDriver wd = new FireFoxDriver(fireFoxProfile);



Profile setting can be done using ProfileIni Class in WebDriver
*/
public class Localization implements Constants
{

WebDriver wd = null;

@BeforeTest(enabled = true)
public void setup()
{
/*
ProfilesIni pf = new ProfilesIni();
FirefoxProfile fireFoxProfile = pf.getProfile(profileName);
wd = new FirefoxDriver(fireFoxProfile);
*/
FirefoxProfile fireFoxProfile = new FirefoxProfile();
fireFoxProfile.setPreference("intl.accept_languages","sl");
wd = new FirefoxDriver(fireFoxProfile);
}

@Test
public void testLoadApplication()
{
wd.get("http://www.gmail.com");

}


}

No comments:

Post a Comment