Accessing and using Drupal.settings properties in Selenium tests

PUBLISHED ON 18/4/2012 — WEB DEVELOPMENT

Selenium

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'].

Command Value Variable
storeEval this.browserbot.getUserWindow().Drupal.settings.nid nid
open javascript{'/node/'+ storedVars['nid']}