I am trying to automate interaction with a site that generates documents using an application like MIME / vnd.wap.xhtml + xml. I am using Selenium 2, WebDriver and FirefoxProfile.
Since Firefox does not handle the aforementioned MIME type, I need to run Firefox with the XHTML mobile profile extension (https://addons.mozilla.org/en-US/firefox/addon/1345/).
After creating the FireFox profile — I named it “selenium” and installed the Mobile Profile extension, 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 No. 1 is as follows:
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 No. 2 is as follows:
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/");
Regardless of which piece of code I use, the launching browser instance cannot always process the generated content; The browser asks me for an action to accept the contents of an unrecognized MIME type, as if the extension were not configured correctly.
Any ideas on what I might be doing wrong?
Thanks in advance,
Edit : Link to a message from a Selenium user group .
source share