Hi,
I'm trying to automate the interaction with a website that generates
documents with MIME type application/vnd.wap.xhtml+xml. I am using
Selenium 2, the WebDriver and the FirefoxProfile.
Because Firefox does not handle the above mentioned MIME type, I need
to run Firefox with the XHTML Mobile Profile extension (https://
addons.mozilla.org/en-US/firefox/addon/1345/).
After creating a FireFox profile -I named it 'selenium'- and
installing the Mobile Profile extension to it, I tried to use the code
snippets in the 'Tips and Tricks' section of the 'Selenium 2.0 and
WebDriver' document (
http://seleniumhq.org/docs/
09_webdriver.html#htmlunit-driver).
Approach #1 looks like this:
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("selenium");
profile.setPreference("general.useragent.override", "User Agent string
to force application/vnd.wap.xhtml+xml content..");
FirefoxDriver driver = new FirefoxDriver(profile);
driver.get("
http://www.mobilesite.com/");
WebElement element = driver.findElement(By.tagName("body"));
Approach #2 looks like this:
File profileDir = new File("/path/to/custom/profile/with/extension/
ffprofile");
FirefoxProfile profile = new FirefoxProfile(profileDir);
profile.setPreference("general.useragent.override", "same user agent
string as above");
FirefoxDriver driver = new FirefoxDriver(profile);
driver.get("
http://www.mobilesite.com/");
No matter what code snippet I use, the browser instance that starts up
is always unable to handle the generated content; the browser prompts
me for an action to take on the content of the unrecognized MIME type
as if the extension was not correctly configured.
Any ideas on what I could be doing wrong?
Thanks in advance,
P.S. I originally posted my question in the StackOverflow site (http://
stackoverflow.com/questions/4599763/selenium-2-webdriver-to-use-custom-
profile)