A
A
Andrew2017-04-09 18:46:52
Java
Andrew, 2017-04-09 18:46:52

setPreference() property not being set?

Test environment:
Firefox ver.47.0.2
Selenium WebDriver ver.2.53.1
Eclipse ver.Mars.2 Release (4.5.2)
Question:
To begin with, the default user.js file is missing in the Firefox profile. Why is that? Created it. Next, I run a code that should overwrite the default property "general.useragent.override" from the prefs.js file (although there is no such property in this file, also "why so?").

package com.webdriver.chapter4;

import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.FirefoxDriver;

public class SettingPreferences {

  public static void main(String[] args) {
    FirefoxProfile profile = new FirefoxProfile();
    
    profile.setPreference("general.useragent.override", "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7");
    
    FirefoxDriver driver = new FirefoxDriver(profile);
    driver.get("http://www.google.by");
  }
}

As a result, after running the code for execution, the "general.useragent.override" property should appear in the user.js file with the value specified in the code above - but it is not there, the file is empty! Although the displayed version of the search engine is mobile, which is true.
Has anyone experienced this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2017-05-10
@PrinceOFF

Looks like the site is "zero" or close to being in terms of answers - a month has passed since the question was posted. It's a pity...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question