views:

58

answers:

2

I'd like to suppress the initialization of TinyMCE inside my tests and can do this easily if the Javascript can detect that I'm running inside a Selenium-automated page.

So, is there some JS code that I can use to detect the Selenium driver? Alternatively, how can I extend the userAgent string to include a pattern that I can detect from JS?

If it really matters, I'm running this through cucumber and capybara on Mac OS X.

+1  A: 
  1. Since webbriver automates normal browsers (just like iMacros), your website can not detect it directly.

  2. You can easily append a string to the useragent:

This is easy with the Firefox Driver:

FirefoxProfile profile = new FirefoxProfile(); profile.addAdditionalPreference("general.useragent.override", "some UA string"); WebDriver driver = new FirefoxDriver(profile);

SamMeiers
A: 

Since the question mentions Capybara, here's the equivalent code in Ruby:

profile = Selenium::WebDriver::Firefox::Profile.new
profile['general.useragent.override'] = "my ua string"

driver = Selenium::WebDriver.for :firefox, :profile => profile
jarib
Thanks, that does fit in well with the Capybara scenario.
Lee Iverson