WD
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Sessions

Session class represents object that handles all information related to WD session. For each WD session new webdriver::Session object created and registered in webdriver::SessionManager. Valuable information stored in Session:

  • mapping ViewId into real window implementation.
  • mapping ElementId into real element implemenation.
  • session's wide options - timeouts, capabilities.
  • running context for all operations.

Running context

Most operations on views can be performed on separated thread(ie QT UI thread). For this purpose Session has RunSessionTask() method. And custom runnnig context can be added with webdriver::ViewRunner class:

webdriver::ViewRunner::RegisterCustomRunner<webdriver::QViewRunner>();
session->RunSessionTask(base::Bind(
&ViewFactory::CreateViewByClassName,
base::Unretained(ViewFactory::GetInstance()),
session->logger(),
window_class,
&viewHandle));

Custom capabilities handling

Base capabilities are handled in webdriver::Session::Init() method. But there is way to extend this behavior with webdriver::SessionLifeCycleActions class. There are two methods - PostInit() and BeforeTerminate(). These methods automatically included in session's init/terminate sequence. Customizer can implement subclass of SessionLifeCycleActions and register it.

webdriver::SessionLifeCycleActions::RegisterCustomLifeCycleActions<webdriver::QSessionLifeCycleActions>();

Beside capabilities handling there can be any other actions to be run on session's create or session's terminate.