Accessing and using Drupal.settings properties in Selenium tests

selenium drupal testing


While writing a Selenium test I needed to access the nid of a newly created node from Drupal.settings to use as part of a URL in another method. Simply trying to access Drupal.settings.nid in the storeEval method didn’t work, but dgtlmoon eventually figured it out.

To access any global objects in the main browser scope, you need to access it from this.browserbot.getUserWindow(). Once you have stored a variable, you can access it with storedVars['key'].

openjavascript{'/node/'+ storedVars['nid']}