Showing posts with label Selenium. Show all posts
Showing posts with label Selenium. Show all posts

Saturday, 5 December 2015

Set Browser language in Selenium

Chrome Browser -

        System.setProperty("webdriver.chrome.driver","<LOCATION OF CHROME DRIVER EXE FILE>");
        ChromeOptions options = new ChromeOptions();
        options.addArguments(“–lang= sl”);
        ChromeDriver driver = new ChromeDriver(options);
  
Firefox Browser -

        FirefoxProfile profile = new FirefoxProfile();
        profile.setPreference(“intl.accept_languages”,”fr”);
        driver = new FirefoxDriver(profile);


Type in Rich Text Editor in Selenium

How to type in Rich Text Editor that is located in iFrame ?

public void typeInRichTextEditor() {
        String baseURL = "http://www.speurders.nl/plaatsen";
        WebDriver driver = new FirefoxDriver();
        driver.get(baseURL);
        ((JavascriptExecutor) driver).executeScript("window.scrollTo(0,"
                + driver.findElement(
                        By.xpath("//iframe[@id='description_ifr']")).getLocation().y + ")");
        WebElement descriptionElement = driver.findElement(By
                .xpath("//iframe[@id='description_ifr']"));
        driver.switchTo().frame(descriptionElement);

        WebElement editable = driver.switchTo().activeElement();
        editable.sendKeys("Anand Somani");
        driver.switchTo().defaultContent();
        driver.quit();
    }