WD
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Views management and actions

View enumerator

Session contains map of ViewId to ViewHandle. View enumerator can update this map. It adds new views and removes closed. For each view type there should be separated view enumerator - class derived from webdriver::AbstractViewEnumeratorImpl. Custom AbstractViewEnumeratorImpl has only one virtual method EnumerateViews() that returns all found view of specific types.

Example of usage:

View executor

For separating session and view commands executor concept is used. webdriver::ViewCmdExecutor is pure virtual class that represents all actions that can be done on single view of specific type in one session. So for each view type there should be separated view executor implemented by customer. Exexcutor can be created only by webdriver::ViewCmdExecutorCreator which knows if it can create executor for passed view. All executor creators are registered in webdriver::ViewCmdExecutorFactory. This singleton is an entry point to get executor for view.

Error* error = NULL;
ExecutorPtr executor(ViewCmdExecutorFactory::GetInstance()->CreateExecutor(session, viewId));
if (NULL == executor.get()) {
// handle error
}
session->RunSessionTask(base::Bind(
&ViewCmdExecutor::GetWindowName,
base::Unretained(executor.get()),
title,
&error));
Remarks
ViewCmdExecutorFactory return only first found executor that can operate wit view, so if two executors can handle same view type - registration order is important.

Example of registration:

View factory

Each type of view should have own factory, class derived from webdriver::ViewCreator. Factory for single view type should be registered in singleton - webdriver::ViewFactory. View can be created by two methods:

  • by class name
  • by url (in this case it creates any view that can handle this url)
Remarks
Please note that if two factories can create view by same classname(or url) - only one view will be created from first registered factory.

CreateViewByClassName() and CreateViewForUrl() return ViewHandles. But these handles are not registered in session. User can register them manually or use view enumerator. After enumerating action all view created but not registered will be added to session's views map automatically.

Example of configuration:

webCreator->RegisterViewClass<QWebViewExt>("QWebViewExt");
widgetCreator->RegisterViewClass<QWidget>("QWidget");
widgetCreator->RegisterViewClass<WindowTestWidget>("WindowTestWidget");

View handles

Session contains map of ViewId to ViewHandle. webdriver::ViewHandle is abstraction intended to keep reference to real window implementation(ie pointer to QWidget). Customizer should implement this abstract class.

Example of custom implementation:

class QViewHandle : public ViewHandle {
public:
QViewHandle();
QViewHandle(QWidget* view);
virtual bool is_valid() const { return !view_.isNull(); };
virtual bool equals(const ViewHandle* other) const;
QWidget* get() { return view_.data(); };
protected:
QPointer<QWidget> view_;
virtual ~QViewHandle() {};
};